summaryrefslogtreecommitdiffstats
path: root/ProcessList.c
diff options
context:
space:
mode:
authorDenis Lisov <dennis.lissov@gmail.com>2021-12-16 18:48:47 +0300
committerBenBE <BenBE@geshi.org>2022-02-13 19:50:16 +0100
commit2477a5a0183cee5834e7a5480a295dd8195ee968 (patch)
tree606ab8ae3bd48b3d3869947fb0154c4c20dc343a /ProcessList.c
parent1a403eb7eb605927a79424144570b354c8143caa (diff)
ProcessList_buildTree: handle every process once
Special-casing hidden processes does not serve any obvious purpose and depends on the move from processes to processes2 which will be removed in a later commit.
Diffstat (limited to 'ProcessList.c')
-rw-r--r--ProcessList.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/ProcessList.c b/ProcessList.c
index 04d618c7..a330fa32 100644
--- a/ProcessList.c
+++ b/ProcessList.c
@@ -340,10 +340,13 @@ static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, int level,
Vector* children = Vector_new(Class(Process), false, DEFAULT_SIZE);
+ int lastShown = 0;
for (int i = Vector_size(this->processes) - 1; i >= 0; i--) {
Process* process = (Process*)Vector_get(this->processes, i);
- if (process->show && Process_isChildOf(process, pid)) {
+ if (Process_isChildOf(process, pid)) {
process = (Process*)Vector_take(this->processes, i);
+ if (process->show)
+ lastShown = Vector_size(children);
Vector_add(children, process);
}
}
@@ -369,8 +372,8 @@ static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, int level,
assert(Vector_size(this->processes2) == s + 1); (void)s;
int nextIndent = indent | (1 << level);
- ProcessList_buildTreeBranch(this, process->pid, level + 1, (i < size - 1) ? nextIndent : indent, direction, show ? process->showChildren : false, node_counter, node_index);
- if (i == size - 1) {
+ ProcessList_buildTreeBranch(this, process->pid, level + 1, (i < lastShown) ? nextIndent : indent, direction, process->show && process->showChildren, node_counter, node_index);
+ if (i == lastShown) {
process->indent = -nextIndent;
} else {
process->indent = nextIndent;
@@ -418,20 +421,6 @@ static void ProcessList_buildTree(ProcessList* this) {
for (i = 0; i < size; i++) {
Process* process = (Process*)Vector_get(this->processes, i);
- // Immediately consume processes hidden from view
- if (!process->show) {
- process = (Process*)Vector_take(this->processes, i);
- process->indent = 0;
- process->tree_depth = 0;
- process->tree_left = node_counter++;
- process->tree_index = node_index++;
- Vector_add(this->processes2, process);
- ProcessList_buildTreeBranch(this, process->pid, 0, 0, direction, false, &node_counter, &node_index);
- process->tree_right = node_counter++;
- Hashtable_put(this->displayTreeSet, process->tree_index, process);
- break;
- }
-
pid_t ppid = Process_getParentPid(process);
bool isRoot = false;

© 2014-2024 Faster IT GmbH | imprint | privacy policy