From aa7ff688db2e9f372621f151125165928ee9be84 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 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': -- 2.40.0