From 1ff868fdb78adbe0f49682d7aa35f1b53670cfad Mon Sep 17 00:00:00 2001 From: o9000 Date: Sun, 3 Jan 2016 02:44:14 +0100 Subject: [PATCH] Do not use negative values for task state since it is used as array index --- src/taskbar/task.c | 4 ++-- src/taskbar/task.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 5056e90..9ab29d0 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -104,7 +104,7 @@ Task *add_task(Window win) task_instance->win_y = task_template.win_y; task_instance->win_w = task_template.win_w; task_instance->win_h = task_template.win_h; - task_instance->current_state = -1; // to update the current state later in set_task_state... + task_instance->current_state = TASK_UNDEFINED; // to update the current state later in set_task_state... if (task_instance->desktop == ALL_DESKTOPS && server.desktop != j) { // fprintf(stderr, "%s %d: win = %ld hiding task: another desktop\n", __FUNCTION__, __LINE__, win); task_instance->area.on_screen = FALSE; @@ -549,7 +549,7 @@ void reset_active_task() void set_task_state(Task *task, TaskState state) { - if (!task || state < 0 || state >= TASK_STATE_COUNT) + if (!task || state == TASK_UNDEFINED || state >= TASK_STATE_COUNT) return; if (state == TASK_ACTIVE && task->current_state != state) { diff --git a/src/taskbar/task.h b/src/taskbar/task.h index 25d3d2a..6c97c01 100644 --- a/src/taskbar/task.h +++ b/src/taskbar/task.h @@ -18,6 +18,7 @@ typedef enum TaskState { TASK_ACTIVE, TASK_ICONIFIED, TASK_URGENT, + TASK_UNDEFINED, TASK_STATE_COUNT, } TaskState;