diff --git a/ChangeLog b/ChangeLog index d13d5007..568ec872 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ What's new in version 1.0.1 * Safer behavior on the kill screen, to make it harder to kill the wrong process. * Fix for building in FreeBSD 8.2 (thanks to Trond Endrestol) +* BUGFIX: behavior of 'F' (follow) key was broken, also affecting the + persistence of mouse selections. * BUGFIX: keep main panel up-to-date when running the screen manager, to fix crash when processes die while on the F9/Kill screen. diff --git a/ProcessList.c b/ProcessList.c index 04f761c6..1f47408b 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -109,7 +109,7 @@ typedef struct ProcessList_ { UsersTable* usersTable; Panel* panel; - bool follow; + int following; bool userOnly; uid_t userId; bool filtering; @@ -899,15 +899,15 @@ void ProcessList_expandTree(ProcessList* this) { } } -void ProcessList_rebuildPanel(ProcessList* this, bool flags, bool follow, bool userOnly, uid_t userId, bool filtering, const char* incFilter) { +void ProcessList_rebuildPanel(ProcessList* this, bool flags, int following, bool userOnly, uid_t userId, bool filtering, const char* incFilter) { if (!flags) { - follow = this->follow; + following = this->following; userOnly = this->userOnly; userId = this->userId; filtering = this->filtering; incFilter = this->incFilter; } else { - this->follow = follow; + this->following = following; this->userOnly = userOnly; this->userId = userId; this->filtering = filtering; @@ -915,10 +915,8 @@ void ProcessList_rebuildPanel(ProcessList* this, bool flags, bool follow, bool u } int currPos = Panel_getSelectedIndex(this->panel); - pid_t currPid = 0; + pid_t currPid = following ? following : 0; int currScrollV = this->panel->scrollV; - if (follow) - currPid = ProcessList_get(this, currPos)->pid; Panel_prune(this->panel); int size = ProcessList_size(this); @@ -934,7 +932,7 @@ void ProcessList_rebuildPanel(ProcessList* this, bool flags, bool follow, bool u if (!hidden) { Panel_set(this->panel, idx, (Object*)p); - if ((!follow && idx == currPos) || (follow && p->pid == currPid)) { + if ((following == -1 && idx == currPos) || (following != -1 && p->pid == currPid)) { Panel_setSelected(this->panel, idx); this->panel->scrollV = currScrollV; } diff --git a/ProcessList.h b/ProcessList.h index 719783b7..d7a5ef94 100644 --- a/ProcessList.h +++ b/ProcessList.h @@ -92,7 +92,7 @@ typedef struct ProcessList_ { UsersTable* usersTable; Panel* panel; - bool follow; + int following; bool userOnly; uid_t userId; bool filtering; @@ -183,6 +183,6 @@ ProcessField ProcessList_keyAt(ProcessList* this, int at); void ProcessList_expandTree(ProcessList* this); -void ProcessList_rebuildPanel(ProcessList* this, bool flags, bool follow, bool userOnly, uid_t userId, bool filtering, const char* incFilter); +void ProcessList_rebuildPanel(ProcessList* this, bool flags, int following, bool userOnly, uid_t userId, bool filtering, const char* incFilter); #endif diff --git a/htop.c b/htop.c index dda99c8f..dd760713 100644 --- a/htop.c +++ b/htop.c @@ -440,6 +440,7 @@ int main(int argc, char** argv) { gettimeofday(&tv, NULL); newTime = ((double)tv.tv_sec * 10) + ((double)tv.tv_usec / 100000); recalculate = (newTime - oldTime > CRT_delay); + int following = follow ? ((Process*)Panel_getSelected(panel))->pid : -1; if (recalculate) oldTime = newTime; if (doRefresh) { @@ -451,7 +452,7 @@ int main(int argc, char** argv) { ProcessList_sort(pl); refreshTimeout = 1; } - ProcessList_rebuildPanel(pl, true, follow, userOnly, userId, filtering, incFilter.buffer); + ProcessList_rebuildPanel(pl, true, following, userOnly, userId, filtering, incFilter.buffer); } doRefresh = true;