top: ensure collapsed children cpu reported accurately

Parent tasks with collapsed children should have their
cpu reflect any unseen tasks only under the following:

1) When built without TREE_VCPUOFF having been defined

2) Exclusively when 'Show_FOREST' display mode was set

3) And only under the current window when in alternate
display mode (except if TREE_VWINALL has been defined)

So, this commit just ensures these objectives are met.

Reference(s):
. issue that began odyssey
https://gitlab.com/procps-ng/procps/issues/99
. original cpu implementation
commit 3da7318683

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2018-07-18 00:00:00 -05:00 committed by Craig Small
parent 786bffc253
commit 4a44f9e3fa

View File

@ -6001,7 +6001,9 @@ static const char *task_show (const WIN_t *q, const int idx) {
case EU_CPU:
{ float u = (float)p->pcpu;
#ifndef TREE_VCPUOFF
// Hide_cpu entry is always zero, unless we're a collapsed parent
#ifndef TREE_VWINALL
if (q == Curwin) // note: the following is NOT indented
#endif
if (CHKw(q, Show_FOREST)) u += Hide_cpu[idx];
u *= Frame_etscale;
if (p->pad_2 != 'x' && u > 100.0 * p->nlwp) u = 100.0 * p->nlwp;