From: Jim Warner Date: Sun, 12 Jul 2015 09:44:44 +0000 (-0500) Subject: top: improve vertical scroll management for 'i' toggle X-Git-Tag: v4.0.0~1082 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa7ff688db2e9f372621f151125165928ee9be84;p=procps-ng 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 --- diff --git a/top/top.c b/top/top.c index 4589b6c7..ac583d1e 100644 --- a/top/top.c +++ b/top/top.c @@ -4590,6 +4590,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':