From 69978e365043f27305e487709474947bb377084d Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Thu, 23 Sep 2021 00:00:00 -0500 Subject: [PATCH] top: ensure those potential focused tasks stay focused When that 'F' focus command has been applied to a task in forest view it should remain as the topmost process in a particular window. But without this patch that is not guaranteed. Newly forked/cloned tasks 'above' such a process result in task(s) appearing which shouldn't. The effect was as if that up arrow key scrolled beyond the topmost parent task, which would never be allowed. [ since scrolling is permitted within a focus range, ] [ when any task 'above' our focus/topmost task ends, ] [ we respond as if scrolled with the down arrow key. ] [ that result is completely appropriate. if the user ] [ wishes to return to a focused parent, the up arrow ] [ or home key can be used to accomplish such a goal. ] Signed-off-by: Jim Warner --- top/top.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index b5bc0656..c52b4eef 100644 --- a/top/top.c +++ b/top/top.c @@ -4598,6 +4598,11 @@ static void forest_config (WIN_t *q) { while (i+1 < PIDSmaxt && rSv(i+1) > level) ++i; q->focus_end = i + 1; // make 'focus_end' a proper fencpost + // watch out for newly forked/cloned tasks 'above' us ... + if (q->begtask < q->focus_beg) { + q->begtask = q->focus_beg; + q->begnext = 0; // as 'mkVIZoff' but in any window + } } #undef rSv } // end: forest_config @@ -6213,7 +6218,7 @@ static void window_hlp (void) { reversed = 0; // potentially scroll forward ... - if (w->begnext > beg) { + if (w->begnext > 0) { fwd_redux: for (i = w->begtask; i < end; i++) { if (wins_usrselect(w, i) -- 2.40.0