From a4173f52097fd78d0dab2e3296514e7dc7e54660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Fri, 12 Mar 2021 18:02:39 +0100 Subject: 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 --- ProcessList.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'ProcessList.c') 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) -- cgit v1.2.3