Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/htop-dev#1597' into htop-dev#1597
Browse files Browse the repository at this point in the history
  • Loading branch information
aestriplex committed Feb 9, 2025
2 parents 0015cba + 8fa9b0e commit 4d21026
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
13 changes: 12 additions & 1 deletion AffinityPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,20 @@ static void AffinityPanel_update(AffinityPanel* this, bool keepSelected) {

static HandlerResult AffinityPanel_eventHandler(Panel* super, int ch) {
AffinityPanel* this = (AffinityPanel*) super;

HandlerResult result = IGNORED;
MaskItem* selected = (MaskItem*) Panel_getSelected(super);

bool keepSelected = true;

switch (ch) {
case KEY_MOUSE:
case KEY_RECLICK:
case ' ':
if (!selected) {
return result;
}

#ifdef HAVE_LIBHWLOC
if (selected->value == 2) {
/* Item was selected, so remove this mask from the top cpuset. */
Expand Down Expand Up @@ -240,8 +246,13 @@ static HandlerResult AffinityPanel_eventHandler(Panel* super, int ch) {
case KEY_F(3):
case '-':
case '+':
if (selected->sub_tree)
if (!selected) {
break;
}

if (selected->sub_tree) {
selected->sub_tree = 1 + !(selected->sub_tree - 1); /* toggle between 1 and 2 */
}

result = HANDLED;
break;
Expand Down
4 changes: 4 additions & 0 deletions DisplayOptionsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) {
HandlerResult result = IGNORED;
OptionItem* selected = (OptionItem*) Panel_getSelected(super);

if (!selected) {
return result;
}

switch (ch) {
case '\n':
case '\r':
Expand Down
16 changes: 7 additions & 9 deletions GPUMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ in the source distribution for its full text.


static size_t activeMeters;

bool GPUMeter_active(void) {
return activeMeters > 0;
}

static double totalUsage;
static unsigned long long int totalGPUTimeDiff;

static const int GPUMeter_attributes[] = {
GPU_ENGINE_1,
GPU_ENGINE_2,
Expand All @@ -30,6 +22,12 @@ static const int GPUMeter_attributes[] = {
GPU_RESIDUE,
};

bool GPUMeter_active(void) {
return activeMeters > 0;
}

static double totalUsage;

static void GPUMeter_updateValues(Meter* this) {
char* buffer = this->txtBuffer;
size_t size = sizeof(this->txtBuffer);
Expand Down Expand Up @@ -67,7 +65,7 @@ const MeterClass GPUMeter_class = {
.updateValues = GPUMeter_updateValues,
.defaultMode = BAR_METERMODE,
.supportedModes = METERMODE_DEFAULT_SUPPORTED,
.maxItems = 5,
.maxItems = ARRAYSIZE(GPUMeter_attributes),
.total = 100.0,
.attributes = GPUMeter_attributes,
.name = "GPU",
Expand Down

0 comments on commit 4d21026

Please sign in to comment.