From 54c21917514f31f3c69ef747e609e93dc4b38dbe Mon Sep 17 00:00:00 2001 From: Thierry Lorthiois Date: Sat, 23 Oct 2010 13:39:09 +0000 Subject: [PATCH] cleanup : remove unneeded title change --- src/config.c | 1 - src/taskbar/task.c | 20 +++++++++++++------- src/taskbar/task.h | 2 +- src/tint.c | 11 ++++++----- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/config.c b/src/config.c index d2b3414..2ff77f5 100644 --- a/src/config.c +++ b/src/config.c @@ -457,7 +457,6 @@ void add_entry (char *key, char *value) panel_config.g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); if (panel_config.g_taskbar.background[TASKBAR_ACTIVE] == 0) panel_config.g_taskbar.background[TASKBAR_ACTIVE] = panel_config.g_taskbar.background[TASKBAR_NORMAL]; - //panel_config.g_taskbar.area.bg = panel_config.g_taskbar.bg; } else if (strcmp (key, "taskbar_active_background_id") == 0) { int id = atoi (value); diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 7a5212e..bdc0fde 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -159,12 +159,12 @@ void remove_task (Task *tsk) } -void get_title(Task *tsk) +int get_title(Task *tsk) { Panel *panel = tsk->area.panel; char *title, *name; - if (!panel->g_task.text && !g_tooltip.enabled) return; + if (!panel->g_task.text && !g_tooltip.enabled) return 0; name = server_get_property (tsk->win, server.atom._NET_WM_VISIBLE_NAME, server.atom.UTF8_STRING, 0); if (!name || !strlen(name)) { @@ -184,9 +184,16 @@ void get_title(Task *tsk) else title[0] = 0; strcat(title, name); if (name) XFree (name); - - if (tsk->title) - free(tsk->title); + + if (tsk->title) { + // check unecessary title change + if (strcmp(tsk->title, title) == 0) { + free(title); + return 0; + } + else + free(tsk->title); + } tsk->title = title; GPtrArray* task_group = task_get_tasks(tsk->win); @@ -198,7 +205,7 @@ void get_title(Task *tsk) set_task_redraw(tsk2); } } - set_task_redraw(tsk); + return 1; } @@ -303,7 +310,6 @@ void get_icon (Task *tsk) set_task_redraw(tsk2); } } - set_task_redraw(tsk); } diff --git a/src/taskbar/task.h b/src/taskbar/task.h index 3de591b..9fe7896 100644 --- a/src/taskbar/task.h +++ b/src/taskbar/task.h @@ -72,7 +72,7 @@ void draw_task (void *obj, cairo_t *c); void on_change_task (void *obj); void get_icon (Task *tsk); -void get_title(Task *tsk); +int get_title(Task *tsk); void active_task(); void set_task_state(Task* tsk, int state); void set_task_redraw(Task* tsk); diff --git a/src/tint.c b/src/tint.c index b975fec..cc12d44 100644 --- a/src/tint.c +++ b/src/tint.c @@ -584,12 +584,13 @@ void event_property_notify (XEvent *e) // Window title changed if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) { - get_title(tsk); - if (g_tooltip.mapped && (g_tooltip.area == (Area*)tsk)) { - tooltip_copy_text((Area*)tsk); - tooltip_update(); + if (get_title(tsk)) { + if (g_tooltip.mapped && (g_tooltip.area == (Area*)tsk)) { + tooltip_copy_text((Area*)tsk); + tooltip_update(); + } + panel_refresh = 1; } - panel_refresh = 1; } // Demand attention else if (at == server.atom._NET_WM_STATE) { -- 2.45.2