diff --git a/top/top.c b/top/top.c index f75516a9..a8e26b5b 100644 --- a/top/top.c +++ b/top/top.c @@ -4625,7 +4625,7 @@ static void forest_config (WIN_t *q) { if (i == PIDSmaxt) q->focus_pid = q->begtask = 0; else { -#ifdef TREE_FOCUS_X +#ifdef FOCUS_TREE_X q->focus_lvl = rSv(i); #endif while (i+1 < PIDSmaxt && rSv(i+1) > level) @@ -4636,6 +4636,15 @@ static void forest_config (WIN_t *q) { q->begtask = q->focus_beg; q->begnext = 0; // as 'mkVIZoff' but in any window } +#ifdef FOCUS_HARD_Y + // if some task 'above' us ended, try to maintain focus + // ( but allow scrolling when there are many children ) + if (q->begtask > q->focus_beg + && (Screen_rows > (q->focus_end - q->focus_beg))) { + q->begtask = q->focus_beg; + q->begnext = 0; // as 'mkVIZoff' but in any window + } +#endif } #undef rSv } // end: forest_config @@ -4658,7 +4667,7 @@ static inline const char *forest_display (const WIN_t *q, int idx) { const char *which = (CHKw(q, Show_CMDLIN)) ? rSv(eu_CMDLINE) : rSv(EU_CMD); int level = rSv_Lvl; -#ifdef TREE_FOCUS_X +#ifdef FOCUS_TREE_X if (q->focus_pid) { if (idx >= q->focus_beg && idx < q->focus_end) level -= q->focus_lvl; diff --git a/top/top.h b/top/top.h index a2b8fa95..5709961c 100644 --- a/top/top.h +++ b/top/top.h @@ -29,6 +29,8 @@ //#define CASEUP_HEXES /* show all those hex values in upper case */ //#define CASEUP_SUFIX /* show time/mem/cnts suffix in upper case */ //#define EQUCOLHDRYES /* yes, equalize the column header lengths */ +//#define FOCUS_HARD_Y /* 'F' will avoid topmost task distortions */ +//#define FOCUS_TREE_X /* 'F' resets forest view indentation to 0 */ //#define GETOPTFIX_NO /* do not address getopt_long deficiencies */ //#define INSP_JUSTNOT /* do not smooth unprintable right margins */ //#define INSP_OFFDEMO /* disable demo screens, issue msg instead */ @@ -57,7 +59,6 @@ //#define TOG4_NOTRUNC /* ensure no truncation for 2 abreast mode */ //#define TOG4_OFF_MEM /* don't show two abreast memory statistic */ //#define TOG4_OFF_SEP /* don't show two abreast visual separator */ -//#define TREE_FOCUS_X /* 'F' resets forest view indentation to 0 */ //#define TREE_NORESET /* sort keys should not force 'V' view off */ //#define TREE_SCANALL /* rescan array w/ forest view, avoid sort */ //#define TREE_VALTMRK /* use an indented '+' with collapsed pids */ @@ -373,7 +374,7 @@ typedef struct WIN_t { int focus_pid; // target pid when 'F' toggle is active int focus_beg; // ppt index where 'F' toggle has begun int focus_end; // ppt index where 'F' toggle has ended -#ifdef TREE_FOCUS_X +#ifdef FOCUS_TREE_X int focus_lvl; // the indentation level of parent task #endif struct pids_stack **ppt; // this window's stacks ptr array