From: Andreas Fink Date: Thu, 19 Nov 2009 13:53:01 +0000 (+0000) Subject: *fix* tooltip copys the displayed text X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=fe019d7c8ab1bc45aa0690028e108f44bb99a467;p=chaz%2Ftint2 *fix* tooltip copys the displayed text *fix* remove urgent windows from list if closed --- diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 317cd8f..a59f28f 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -143,6 +143,8 @@ void remove_task (Task *tsk) task_active = 0; if (tsk2 == task_drag) task_drag = 0; + if (is_urgent(tsk2)) + del_urgent(tsk2); XFreePixmap (server.dsp, tsk2->area.pix.pmap); XFreePixmap (server.dsp, tsk2->area.pix_active.pmap); diff --git a/src/tooltip/tooltip.c b/src/tooltip/tooltip.c index 61e21b5..06a67d3 100644 --- a/src/tooltip/tooltip.c +++ b/src/tooltip/tooltip.c @@ -17,6 +17,8 @@ #include #include +#include +#include #include #include @@ -31,9 +33,11 @@ static int x, y, width, height; void start_show_timeout(); void start_hide_timeout(); void stop_timeouts(); +void tooltip_copy_text(Area* area); // give the tooltip some reasonable default values Tooltip g_tooltip = { + .tooltip_text = 0, .area = 0, .panel = 0, .window = 0, @@ -74,7 +78,7 @@ void cleanup_tooltip() stop_timeouts(); tooltip_hide(); g_tooltip.enabled = False; - g_tooltip.area = 0; + tooltip_copy_text(0); if (g_tooltip.window) { XDestroyWindow(server.dsp, g_tooltip.window); g_tooltip.window = 0; @@ -92,7 +96,7 @@ void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root) y = y_root; g_tooltip.panel = p; if (g_tooltip.mapped && g_tooltip.area != area) { - g_tooltip.area = area; + tooltip_copy_text(area); tooltip_update(); stop_timeouts(); } @@ -107,7 +111,7 @@ void tooltip_show() Area* area = click_area(g_tooltip.panel, x, y); stop_timeouts(); if (!g_tooltip.mapped && area->_get_tooltip_text) { - g_tooltip.area = area; + tooltip_copy_text(area); g_tooltip.mapped = True; XMapWindow(server.dsp, g_tooltip.window); XFlush(server.dsp); @@ -124,7 +128,7 @@ void tooltip_update_geometry() c = cairo_create(cs); layout = pango_cairo_create_layout(c); pango_layout_set_font_description(layout, g_tooltip.font_desc); - pango_layout_set_text(layout, g_tooltip.area->_get_tooltip_text(g_tooltip.area), -1); + pango_layout_set_text(layout, g_tooltip.tooltip_text, -1); PangoRectangle r1, r2; pango_layout_get_pixel_extents(layout, &r1, &r2); width = 2*g_tooltip.border.width + 2*g_tooltip.paddingx + r2.width; @@ -194,7 +198,7 @@ void tooltip_adjust_geometry() void tooltip_update() { - if (!g_tooltip.area->_get_tooltip_text) { + if (!g_tooltip.tooltip_text) { tooltip_hide(); return; } @@ -224,7 +228,7 @@ void tooltip_update() cairo_set_source_rgba(c, fc.color[0], fc.color[1], fc.color[2], fc.alpha); layout = pango_cairo_create_layout(c); pango_layout_set_font_description(layout, g_tooltip.font_desc); - pango_layout_set_text(layout, g_tooltip.area->_get_tooltip_text(g_tooltip.area), -1); + pango_layout_set_text(layout, g_tooltip.tooltip_text, -1); PangoRectangle r1, r2; pango_layout_get_pixel_extents(layout, &r1, &r2); pango_layout_set_width(layout, width*PANGO_SCALE); @@ -243,7 +247,7 @@ void tooltip_update() void tooltip_trigger_hide(Tooltip* tooltip) { if (g_tooltip.mapped) { - g_tooltip.area = 0; + tooltip_copy_text(0); start_hide_timeout(); } else { @@ -290,3 +294,14 @@ void stop_timeouts() reset_timer(g_tooltip.show_timer_id, 0, 0, 0, 0); reset_timer(g_tooltip.hide_timer_id, 0, 0, 0, 0); } + + +void tooltip_copy_text(Area* area) +{ + free(g_tooltip.tooltip_text); + if (area && area->_get_tooltip_text) + g_tooltip.tooltip_text = strdup(area->_get_tooltip_text(area)); + else + g_tooltip.tooltip_text = 0; + g_tooltip.area = area; +} diff --git a/src/tooltip/tooltip.h b/src/tooltip/tooltip.h index 462857b..82752d6 100644 --- a/src/tooltip/tooltip.h +++ b/src/tooltip/tooltip.h @@ -25,7 +25,8 @@ typedef struct { - Area* area; + Area* area; // never ever use the area attribut if you are not 100% sure that this area was not freed + char* tooltip_text; Panel* panel; Window window; struct timespec show_timeout; diff --git a/src/util/timer.c b/src/util/timer.c index 59064dd..e218877 100644 --- a/src/util/timer.c +++ b/src/util/timer.c @@ -25,7 +25,7 @@ GSList* timer_list = 0; int install_timer(int value_sec, int value_nsec, int interval_sec, int interval_nsec, void (*_callback)()) { - if ( value_sec < 0 || interval_sec < 0 ) + if ( value_sec < 0 || interval_sec < 0 || _callback == 0 ) return -1; int timer_fd;