diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-03-12 18:02:39 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-03-14 14:47:15 +0100 |
commit | a4173f52097fd78d0dab2e3296514e7dc7e54660 (patch) | |
tree | e2510b2cb977a59c34226ea8a632578e097aefe5 /ProcessList.c | |
parent | 1275139795e9b751af13ec10f96806d852591e39 (diff) |
Improve process following
- stay in follow mode on sort inversion (I)
- stay in follow mode after viewing help screen (h)
- select parent process (where available) when having followed a thread
and hiding these (H)
Closes: #560
Diffstat (limited to 'ProcessList.c')
-rw-r--r-- | ProcessList.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/ProcessList.c b/ProcessList.c index cb89b720..7c12c7bf 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -507,16 +507,26 @@ void ProcessList_collapseAllBranches(ProcessList* this) { void ProcessList_rebuildPanel(ProcessList* this) { const char* incFilter = this->incFilter; - int currPos = Panel_getSelectedIndex(this->panel); - int currScrollV = this->panel->scrollV; - int currSize = Panel_size(this->panel); + const int currPos = Panel_getSelectedIndex(this->panel); + const int currScrollV = this->panel->scrollV; + const int currSize = Panel_size(this->panel); Panel_prune(this->panel); - int size = ProcessList_size(this); + + /* Follow main process if followed a userland thread and threads are now hidden */ + const Settings* settings = this->settings; + if (this->following != -1 && settings->hideUserlandThreads) { + const Process* followedProcess = (const Process*) Hashtable_get(this->processTable, this->following); + if (followedProcess && Process_isThread(followedProcess) && Hashtable_get(this->processTable, followedProcess->tgid) != NULL) { + this->following = followedProcess->tgid; + } + } + + const int processCount = ProcessList_size(this); int idx = 0; bool foundFollowed = false; - for (int i = 0; i < size; i++) { + for (int i = 0; i < processCount; i++) { Process* p = ProcessList_get(this, i); if ( (!p->show) |