From 4a014adc2616c77ab80ce31b1d4a817250dcd31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sat, 21 Aug 2021 22:00:09 +0200 Subject: [PATCH] Add setting to show only active CPUs Closes: #757 --- CPUMeter.c | 2 +- DisplayOptionsPanel.c | 1 + Settings.c | 4 ++++ Settings.h | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CPUMeter.c b/CPUMeter.c index 4f299d9c3..5034a3487 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -215,7 +215,7 @@ static void AllCPUsMeter_updateValues(Meter* this) { } static void CPUMeterCommonInit(Meter* this, int ncol) { - unsigned int cpus = this->pl->existingCPUs; + unsigned int cpus = this->pl->settings->showOnlyActiveCPUs ? this->pl->activeCPUs : this->pl->existingCPUs; CPUMeterData* data = this->meterData; if (!data) { data = this->meterData = xMalloc(sizeof(CPUMeterData)); diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c index 23b16bb2f..d71127618 100644 --- a/DisplayOptionsPanel.c +++ b/DisplayOptionsPanel.c @@ -115,6 +115,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* Panel_add(super, (Object*) CheckItem_newByRef("Leave a margin around header", &(settings->headerMargin))); Panel_add(super, (Object*) CheckItem_newByRef("Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest)", &(settings->detailedCPUTime))); Panel_add(super, (Object*) CheckItem_newByRef("Count CPUs from 1 instead of 0", &(settings->countCPUsFromOne))); + Panel_add(super, (Object*) CheckItem_newByRef("Show only active CPUs", &(settings->showOnlyActiveCPUs))); Panel_add(super, (Object*) CheckItem_newByRef("Update process names on every refresh", &(settings->updateProcessNames))); Panel_add(super, (Object*) CheckItem_newByRef("Add guest time in CPU meter percentage", &(settings->accountGuestInCPUMeter))); Panel_add(super, (Object*) CheckItem_newByRef("Also show CPU percentage numerically", &(settings->showCPUUsage))); diff --git a/Settings.c b/Settings.c index 3931bbf23..fd0387365 100644 --- a/Settings.c +++ b/Settings.c @@ -225,6 +225,8 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini } else if (String_eq(option[0], "cpu_count_from_zero")) { // old (inverted) naming also supported for backwards compatibility this->countCPUsFromOne = !atoi(option[1]); + } else if (String_eq(option[0], "show_only_active_cpu")) { + this->showOnlyActiveCPUs = atoi(option[1]); } else if (String_eq(option[0], "show_cpu_usage")) { this->showCPUUsage = atoi(option[1]); } else if (String_eq(option[0], "show_cpu_frequency")) { @@ -352,6 +354,7 @@ int Settings_write(const Settings* this, bool onCrash) { fprintf(fd, "header_margin=%d\n", (int) this->headerMargin); fprintf(fd, "detailed_cpu_time=%d\n", (int) this->detailedCPUTime); fprintf(fd, "cpu_count_from_one=%d\n", (int) this->countCPUsFromOne); + fprintf(fd, "show_only_active_cpu=%d\n", (int) this->showOnlyActiveCPUs); fprintf(fd, "show_cpu_usage=%d\n", (int) this->showCPUUsage); fprintf(fd, "show_cpu_frequency=%d\n", (int) this->showCPUFrequency); #ifdef BUILD_WITH_CPU_TEMP @@ -407,6 +410,7 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicColumns) this->highlightMegabytes = true; this->detailedCPUTime = false; this->countCPUsFromOne = false; + this->showOnlyActiveCPUs = false; this->showCPUUsage = true; this->showCPUFrequency = false; #ifdef BUILD_WITH_CPU_TEMP diff --git a/Settings.h b/Settings.h index 97ef58a0e..96703bac0 100644 --- a/Settings.h +++ b/Settings.h @@ -40,6 +40,7 @@ typedef struct Settings_ { ProcessField treeSortKey; bool countCPUsFromOne; + bool showOnlyActiveCPUs; bool detailedCPUTime; bool showCPUUsage; bool showCPUFrequency;