summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Lisov <dennis.lissov@gmail.com>2021-12-16 01:33:32 +0300
committerBenBE <BenBE@geshi.org>2022-02-13 19:50:16 +0100
commita3a7958721607b8520199563d478a315dfac678f (patch)
tree46b62cc3320dbcd5183089bb88c82fbd1d918655
parent4aeb146ce838c9bedd98b9d2227e8aa57464f574 (diff)
ProcessList: sort before panel rebuild if needed
-rw-r--r--Action.c6
-rw-r--r--ProcessList.c5
-rw-r--r--ProcessList.h1
-rw-r--r--ScreenManager.c2
4 files changed, 9 insertions, 5 deletions
diff --git a/Action.c b/Action.c
index 13715361..9ee0cdb5 100644
--- a/Action.c
+++ b/Action.c
@@ -189,8 +189,7 @@ static Htop_Reaction actionSetSortColumn(State* st) {
}
Object_delete(sortPanel);
- if (st->pauseProcessUpdate)
- ProcessList_sort(st->pl);
+ st->pl->needsSort = true;
return reaction | HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
}
@@ -281,8 +280,7 @@ static Htop_Reaction actionLowerPriority(State* st) {
static Htop_Reaction actionInvertSortOrder(State* st) {
ScreenSettings_invertSortOrder(st->settings->ss);
- if (st->pauseProcessUpdate)
- ProcessList_sort(st->pl);
+ st->pl->needsSort = true;
return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING;
}
diff --git a/ProcessList.c b/ProcessList.c
index 1df1990d..ef714b46 100644
--- a/ProcessList.c
+++ b/ProcessList.c
@@ -27,6 +27,7 @@ ProcessList* ProcessList_init(ProcessList* this, const ObjectClass* klass, Users
this->processTable = Hashtable_new(200, false);
this->displayTreeSet = Hashtable_new(200, false);
this->draftingTreeSet = Hashtable_new(200, false);
+ this->needsSort = true;
this->usersTable = usersTable;
this->pidMatchList = pidMatchList;
@@ -496,6 +497,7 @@ void ProcessList_sort(ProcessList* this) {
} else {
Vector_insertionSort(this->processes);
}
+ this->needsSort = false;
}
ProcessField ProcessList_keyAt(const ProcessList* this, int at) {
@@ -531,6 +533,9 @@ void ProcessList_collapseAllBranches(ProcessList* this) {
}
void ProcessList_rebuildPanel(ProcessList* this) {
+ if (this->needsSort)
+ ProcessList_sort(this);
+
const char* incFilter = this->incFilter;
const int currPos = Panel_getSelectedIndex(this->panel);
diff --git a/ProcessList.h b/ProcessList.h
index a12ffa13..23203928 100644
--- a/ProcessList.h
+++ b/ProcessList.h
@@ -50,6 +50,7 @@ typedef struct ProcessList_ {
Hashtable* displayTreeSet;
Hashtable* draftingTreeSet;
+ bool needsSort;
Hashtable* dynamicMeters; /* runtime-discovered meters */
Hashtable* dynamicColumns; /* runtime-discovered Columns */
diff --git a/ScreenManager.c b/ScreenManager.c
index b5e73db3..396622e3 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -126,7 +126,7 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
// always update header, especially to avoid gaps in graph meters
Header_updateData(this->header);
if (!this->state->pauseProcessUpdate && (*sortTimeout == 0 || this->settings->ss->treeView)) {
- ProcessList_sort(pl);
+ pl->needsSort = true;
*sortTimeout = 1;
}
// force redraw if the number of UID digits was changed

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