summaryrefslogtreecommitdiffstats
path: root/Settings.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-12-16 16:09:32 +0100
committercgzones <cgzones@googlemail.com>2021-12-17 14:45:15 +0100
commit5b78ad2d53b751e8b07d67ab8070e47f77036b84 (patch)
tree70def1b55be92e6e23e629b831a98ea8ac78889a /Settings.c
parent1ef8c0e12f29606cb5bfb77d9bce78ae5e6bbb0e (diff)
Set correct default sorting direction
Respect the field option defaultSortDesc for the default screen sort direction, e.g. for CPU%.
Diffstat (limited to 'Settings.c')
-rw-r--r--Settings.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Settings.c b/Settings.c
index ee2fe1b5..54ae0515 100644
--- a/Settings.c
+++ b/Settings.c
@@ -262,22 +262,23 @@ static void ScreenSettings_readFields(ScreenSettings* ss, Hashtable* columns, co
String_freeArray(ids);
}
-ScreenSettings* Settings_newScreen(Settings* this, const char* name, const char* line) {
+ScreenSettings* Settings_newScreen(Settings* this, const ScreenDefaults* defaults) {
+ int sortKey = defaults->sortKey ? toFieldIndex(this->dynamicColumns, defaults->sortKey) : PID;
ScreenSettings* ss = xMalloc(sizeof(ScreenSettings));
*ss = (ScreenSettings) {
- .name = xStrdup(name),
+ .name = xStrdup(defaults->name),
.fields = xCalloc(LAST_PROCESSFIELD, sizeof(ProcessField)),
.flags = 0,
- .direction = 1,
+ .direction = (Process_fields[sortKey].defaultSortDesc) ? -1 : 1,
.treeDirection = 1,
- .sortKey = PID,
+ .sortKey = sortKey,
.treeSortKey = PID,
.treeView = false,
.treeViewAlwaysByPID = false,
.allBranchesCollapsed = false,
};
- ScreenSettings_readFields(ss, this->dynamicColumns, line);
+ ScreenSettings_readFields(ss, this->dynamicColumns, defaults->columns);
this->screens[this->nScreens] = ss;
this->nScreens++;
this->screens = xRealloc(this->screens, sizeof(ScreenSettings*) * (this->nScreens + 1));
@@ -296,8 +297,7 @@ static ScreenSettings* Settings_defaultScreens(Settings* this) {
return this->screens[0];
for (unsigned int i = 0; i < Platform_numberOfDefaultScreens; i++) {
const ScreenDefaults* defaults = &Platform_defaultScreens[i];
- ScreenSettings* settings = Settings_newScreen(this, defaults->name, defaults->columns);
- settings->sortKey = toFieldIndex(this->dynamicColumns, defaults->sortKey);
+ Settings_newScreen(this, defaults);
}
return this->screens[0];
}
@@ -466,7 +466,7 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
this->topologyAffinity = !!atoi(option[1]);
#endif
} else if (strncmp(option[0], "screen:", 7) == 0) {
- screen = Settings_newScreen(this, option[0] + 7, option[1]);
+ screen = Settings_newScreen(this, &(const ScreenDefaults){ .name = option[0] + 7, .columns = option[1] });
} else if (String_eq(option[0], ".sort_key")) {
if (screen)
screen->sortKey = toFieldIndex(this->dynamicColumns, option[1]);

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