all repos — tint2 @ f9ca3a2c0e598b4b9b21b403662a1c28bb448181

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

*fix* tooltip copys the displayed text
*fix* remove urgent windows from list if closed



git-svn-id: http://tint2.googlecode.com/svn/trunk@278 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
Andreas.Fink85 Andreas.Fink85@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
commit

f9ca3a2c0e598b4b9b21b403662a1c28bb448181

parent

f43facc27755f11dd70bb7574e2f6acb74303fcb

4 files changed, 27 insertions(+), 9 deletions(-)

jump to
M src/taskbar/task.csrc/taskbar/task.c

@@ -143,6 +143,8 @@ if (tsk2 == task_active)

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);
M src/tooltip/tooltip.csrc/tooltip/tooltip.c

@@ -17,6 +17,8 @@ **************************************************************************/

#include <stdio.h> #include <unistd.h> +#include <string.h> +#include <stdlib.h> #include <cairo.h> #include <cairo-xlib.h>

@@ -31,9 +33,11 @@ // the next functions are helper functions for tooltip handling

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 @@ {

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 @@ x = x_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 @@ {

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 @@ cs = cairo_xlib_surface_create(server.dsp, g_tooltip.window, server.visual, width, height);

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_update() { - if (!g_tooltip.area->_get_tooltip_text) { + if (!g_tooltip.tooltip_text) { tooltip_hide(); return; }

@@ -224,7 +228,7 @@ config_color fc = g_tooltip.font_color;

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_trigger_hide(Tooltip* tooltip) { if (g_tooltip.mapped) { - g_tooltip.area = 0; + tooltip_copy_text(0); start_hide_timeout(); } else {

@@ -290,3 +294,14 @@ {

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; +}
M src/tooltip/tooltip.hsrc/tooltip/tooltip.h

@@ -25,7 +25,8 @@ #include "panel.h"

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;
M src/util/timer.csrc/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;