From c07f6c5e6d6170ef3f2373b4d86988184c3235bf Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 12 Jul 2015 04:44:44 -0500 Subject: [PATCH] top: improve vertical scroll management for 'i' toggle When a user is taking advantage of the scroll features it is likely a scrolled vertical position is well past the first displayable task. That is especially true of top's forest view ('V') mode where those early systemd attached processes are generally not very interesting. As such, should the idle mode toggle ('i') be employed a distorted display is almost guaranteed because tasks that have used some cpu, and thus should be displayed, have already been skipped by virtue of their position. So this patch temporarily nullifies vertical scrolling during the period when idle tasks are not being shown. Signed-off-by: Jim Warner --- top/top.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/top/top.c b/top/top.c index 273c4a54..5a805345 100644 --- a/top/top.c +++ b/top/top.c @@ -4612,6 +4612,12 @@ static void keys_task (int ch) { VIZTOGw(w, Show_CMDLIN); break; case 'i': + { static WIN_t *w_sav; + static int beg_sav; + if (w_sav != w) { beg_sav = 0; w_sav = w; } + if (CHKw(w, Show_IDLEPS)) { beg_sav = w->begtask; w->begtask = 0; } + else { w->begtask = beg_sav; beg_sav = 0; } + } VIZTOGw(w, Show_IDLEPS); break; case 'J':