From 280d1d6e2e2cf7eed76e1def50a4b9547094d185 Mon Sep 17 00:00:00 2001 From: Thierry Lorthiois Date: Sun, 18 Jan 2009 22:12:41 +0000 Subject: [PATCH] fixed bug with "task on all desktop" (issue 39), fixed memory corruption --- ChangeLog | 5 ++ src/clock/clock.c | 2 +- src/clock/clock.h | 2 +- src/panel.c | 6 ++- src/server.c | 6 --- src/server.h | 1 - src/taskbar/task.c | 52 +++++++++++++++------ src/taskbar/task.h | 1 + src/taskbar/taskbar.c | 3 +- src/tint.c | 105 ++++++++++++++++++++++++++++++++++++------ src/tint2 | Bin 47528 -> 47528 bytes src/util/area.c | 28 +++++++++-- src/util/area.h | 9 ++-- src/util/window.c | 26 ++--------- src/util/window.h | 5 -- 15 files changed, 177 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index c60fa67..e48dba3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ +2009-01-18 +- update documentation for new config format +- fixed memory corruption +- fixed bug with "task on all desktop" (issue 39) + 2009-01-17 - fixed drawing of active task (with new layout) diff --git a/src/clock/clock.c b/src/clock/clock.c index 2ec86a4..5fb6cb1 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -64,7 +64,7 @@ void init_clock(Clock *clock, int panel_height) } -void draw_foreground_clock (void *obj, cairo_t *c) +void draw_foreground_clock (void *obj, cairo_t *c, int active) { Clock *clock = obj; PangoLayout *layout; diff --git a/src/clock/clock.h b/src/clock/clock.h index 742a224..b886d4a 100644 --- a/src/clock/clock.h +++ b/src/clock/clock.h @@ -32,7 +32,7 @@ typedef struct Clock { // initialize clock : y position, precision, ... void init_clock(Clock *clock, int panel_height); -void draw_foreground_clock (void *obj, cairo_t *c); +void draw_foreground_clock (void *obj, cairo_t *c, int active); #endif diff --git a/src/panel.c b/src/panel.c index 6e0b45c..71802e6 100644 --- a/src/panel.c +++ b/src/panel.c @@ -35,7 +35,8 @@ void visual_refresh () set_panel_background(); if (server.pmap) XFreePixmap (server.dsp, server.pmap); - server.pmap = server_create_pixmap (panel.area.width, panel.area.height); + server.pmap = XCreatePixmap (server.dsp, server.root_win, panel.area.width, panel.area.height, server.depth); + XCopyArea (server.dsp, panel.area.pix.pmap, server.pmap, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0); // draw child object @@ -176,7 +177,8 @@ void set_panel_background() { Pixmap wall = get_root_pixmap(); - panel.area.pix.pmap = server_create_pixmap (panel.area.width, panel.area.height); + if (panel.area.pix.pmap) XFreePixmap (server.dsp, panel.area.pix.pmap); + panel.area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, panel.area.width, panel.area.height, server.depth); // add layer of root pixmap XCopyArea (server.dsp, wall, panel.area.pix.pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0); diff --git a/src/server.c b/src/server.c index aaa1863..6767f9d 100644 --- a/src/server.c +++ b/src/server.c @@ -135,12 +135,6 @@ void *server_get_property (Window win, Atom at, Atom type, int *num_results) } -Pixmap server_create_pixmap (int width, int height) -{ - return XCreatePixmap (server.dsp, server.root_win, width, height, server.depth); -} - - Pixmap get_root_pixmap () { Pixmap ret; diff --git a/src/server.h b/src/server.h index 435aefd..d042f70 100644 --- a/src/server.h +++ b/src/server.h @@ -97,7 +97,6 @@ void server_refresh_root_pixmap (); void server_refresh_main_pixmap (); void server_catch_error (Display *d, XErrorEvent *ev); void server_init_atoms (); -Pixmap server_create_pixmap (int width, int height); void get_monitors(); Pixmap get_root_pixmap(); diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 2a7119a..9bfc703 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -39,7 +39,8 @@ void add_task (Window win) Task *new_tsk; int desktop, monitor; - if (!win || window_is_hidden (win) || win == window.main_win) return; + if (!win) return; + if (window_is_hidden (win) || win == window.main_win) return; new_tsk = malloc(sizeof(Task)); new_tsk->win = win; @@ -55,31 +56,46 @@ void add_task (Window win) //if (panel.mode == MULTI_MONITOR) monitor = window_get_monitor (new_tsk->win); //else monitor = 0; //printf("task %s : desktop %d, monitor %d\n", new_tsk->title, desktop, monitor); - XSelectInput (server.dsp, new_tsk->win, PropertyChangeMask|StructureNotifyMask); + Taskbar *tskbar; if (desktop == 0xFFFFFFFF) { - if (new_tsk->title) { - free (new_tsk->title); - new_tsk->title = 0; - } - if (new_tsk->icon_data) { - free (new_tsk->icon_data); - new_tsk->icon_data = 0; - } - free(new_tsk); - fprintf(stderr, "task on all desktop : ignored\n"); - return; + tskbar = &panel.taskbar[index(0, monitor)]; + new_tsk->all_desktop = 1; + } + else { + tskbar = &panel.taskbar[index(desktop, monitor)]; + new_tsk->all_desktop = 0; } //printf("add_task %d %s\n", index(desktop, monitor), new_tsk->title); - Taskbar *tskbar; - tskbar = &panel.taskbar[index(desktop, monitor)]; new_tsk->area.parent = tskbar; tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk); if (resize_tasks (tskbar)) set_redraw (&tskbar->area); + + if (desktop == 0xFFFFFFFF) { + // task on all desktop + int i; + Task *new_tsk2; + for (i = 1 ; i < server.nb_desktop ; i++) { + new_tsk2 = malloc(sizeof(Task)); + memcpy(new_tsk2, new_tsk, sizeof(Task)); + + new_tsk2->title = 0; + new_tsk2->icon_data = 0; + get_icon(new_tsk2); + get_title(new_tsk2); + + tskbar = &panel.taskbar[index(i, monitor)]; + new_tsk2->area.parent = tskbar; + tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2); + + if (resize_tasks (tskbar)) + set_redraw (&tskbar->area); + } + } } @@ -94,6 +110,11 @@ void remove_task (Task *tsk) set_redraw (&tskbar->area); //printf("remove_task %d %s\n", index(tskbar->desktop, tskbar->monitor), tsk->title); + if (tsk == panel.task_active) + panel.task_active = 0; + if (tsk == panel.task_drag) + panel.task_drag = 0; + if (tsk->title) { free (tsk->title); tsk->title = 0; @@ -102,6 +123,7 @@ void remove_task (Task *tsk) free (tsk->icon_data); tsk->icon_data = 0; } + XFreePixmap (server.dsp, tsk->area.pix.pmap); XFreePixmap (server.dsp, tsk->area.pix_active.pmap); free(tsk); diff --git a/src/taskbar/task.h b/src/taskbar/task.h index ec1544d..2948906 100644 --- a/src/taskbar/task.h +++ b/src/taskbar/task.h @@ -46,6 +46,7 @@ typedef struct { int icon_width; int icon_height; char *title; + int all_desktop; } Task; diff --git a/src/taskbar/taskbar.c b/src/taskbar/taskbar.c index 7118182..fe2383c 100644 --- a/src/taskbar/taskbar.c +++ b/src/taskbar/taskbar.c @@ -43,7 +43,8 @@ Task *task_get_task (Window win) for (i=0 ; i < nb ; i++) { for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) { tsk = l0->data; - if (win == tsk->win) return tsk; + if (win == tsk->win) + return tsk; } } return 0; diff --git a/src/tint.c b/src/tint.c index badfa7f..a85771d 100644 --- a/src/tint.c +++ b/src/tint.c @@ -190,10 +190,12 @@ suite: // drag and drop task if (panel.task_drag) { if (tskbar != panel.task_drag->area.parent && action == TOGGLE_ICONIFY) { - windows_set_desktop(panel.task_drag->win, tskbar->desktop); - if (tskbar->desktop == server.desktop) - set_active(panel.task_drag->win); - panel.task_drag = 0; + if (!panel.task_drag->all_desktop && panel.mode == MULTI_DESKTOP) { + windows_set_desktop(panel.task_drag->win, tskbar->desktop); + if (tskbar->desktop == server.desktop) + set_active(panel.task_drag->win); + panel.task_drag = 0; + } return; } else panel.task_drag = 0; @@ -249,7 +251,20 @@ void event_property_notify (Window win, Atom at) /* Change active */ else if (at == server.atom._NET_ACTIVE_WINDOW) { if (panel.task_active) { - panel.task_active->area.is_active = 0; + if (panel.task_active->all_desktop) { + Task *tsk; + GSList *l0; + int i, nb; + nb = server.nb_desktop * server.nb_monitor; + for (i=0 ; i < nb ; i++) { + for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) { + tsk = l0->data; + tsk->area.is_active = 0; + } + } + } + else + panel.task_active->area.is_active = 0; panel.task_active = 0; } Window w1 = window_get_active (); @@ -260,7 +275,21 @@ void event_property_notify (Window win, Atom at) if (w2) t = task_get_task(w2); } if (t) { - t->area.is_active = 1; + if (t->all_desktop) { + Task *tsk; + GSList *l0; + int i, nb; + nb = server.nb_desktop * server.nb_monitor; + for (i=0 ; i < nb ; i++) { + for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) { + tsk = l0->data; + if (tsk->win == t->win) + tsk->area.is_active = 1; + } + } + } + else + t->area.is_active = 1; panel.task_active = t; } panel.refresh = 1; @@ -280,17 +309,49 @@ void event_property_notify (Window win, Atom at) /* 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); - tsk->area.redraw = 1; + if (tsk->all_desktop) { + Task *tsk2; + GSList *l0; + int i, nb; + nb = server.nb_desktop * server.nb_monitor; + for (i=0 ; i < nb ; i++) { + for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) { + tsk2 = l0->data; + if (tsk->win == tsk2->win) { + get_title(tsk2); + tsk2->area.redraw = 1; + } + } + } + } + else { + get_title(tsk); + tsk->area.redraw = 1; + } panel.refresh = 1; } /* Iconic state */ else if (at == server.atom.WM_STATE) { if (window_is_iconified (win)) - if (panel.task_active == tsk) { - tsk->area.is_active = 0; - panel.task_active = 0; - } + if (panel.task_active) { + if (panel.task_active->win == tsk->win) { + if (tsk->all_desktop) { + Task *tsk2; + GSList *l0; + int i, nb; + nb = server.nb_desktop * server.nb_monitor; + for (i=0 ; i < nb ; i++) { + for (l0 = panel.taskbar[i].area.list; l0 ; l0 = l0->next) { + tsk2 = l0->data; + tsk2->area.is_active = 0; + } + } + } + else + panel.task_active->area.is_active = 0; + panel.task_active = 0; + } + } } /* Window icon changed */ else if (at == server.atom._NET_WM_ICON) { @@ -303,8 +364,24 @@ void event_property_notify (Window win, Atom at) } /* Window desktop changed */ else if (at == server.atom._NET_WM_DESKTOP) { - add_task (tsk->win); - remove_task (tsk); + Window win2 = tsk->win; + if (tsk->all_desktop) { + Task *tsk2; + GSList *l0; + int i, nb; + nb = server.nb_desktop * server.nb_monitor; + for (i=0 ; i < nb ; i++) { + for (l0 = panel.taskbar[i].area.list; l0 ; ) { + tsk2 = l0->data; + l0 = l0->next; + if (win2 == tsk2->win) + remove_task (tsk2); + } + } + } + else + remove_task (tsk); + add_task (win); panel.refresh = 1; } diff --git a/src/tint2 b/src/tint2 index 6bdf2d3e1c6d292f836a86f1c9969cd12e0e6b91..771467014466afe70644b38ad8686bcf2e9f92a6 100755 GIT binary patch delta 14241 zcmaJ|3tUvi_g}6ctAdb%f`X#*6dz!sB9aeWHPc*JSrB~XBezwv2c(v|=t7DY6dg5F zQ#SHZX_07ZnP8Y`TKV&pW}24fY+zBEQDOW4p1F5-vH$<~=kwX!x#yfY@0mF>ci44T z+I3ed$#1^mU5#eNyC1Av+g$1!T+zvUvWGMyxMGR6WuTPvO2x|17qqQQg1oe*QhcQv zO?e+ww2Tb*kd{2b;-W&r;!GNi^_YKRbxydo&PU#GMx)WB@xMlCG=+V``EMiHoTwg_ z9`Ym~S*K0(y4lZ5>zCi?fj%JCY4!Zi(V(mWhk`1<{5T*IL-YC*Q4h3}LKlg4m}r-Z zc7SNl5bZyj5zPwG-T=W#p;M_{a0G3+oK%tXZfZ0Z4KaVl6OV!SNQ3tS8}U<^{%yh8 zB_nHemq4hAci5`>dTHe?19su5;7U%Y+)U2)OcHEze}TSw{$PYKw%|(c4-Va>r8VHK zk#(06b>HTGN(N2R8u;ar8cmJYZm@!)WIjbcXnb$Oq^u;hMjKY8Mw?_4`HGw{6OU}beGW3?Rf7u31uia(^T#g+8!(4AST zyRO)NCQ)}jca=TZ;c&Imt<(Ap|S% z1{Z6cRt`M#sFya)cDfC=IGqcf1b$3;-JqtL8Y6ZsY?APaR)`sIH{Y#z?M(*D-Fi zi3XEKGfbnGeXqj>seJh#Y-&t<3$)GPg~Q-VSJsg$M?P>kc%MWV^~NI_jeQOtYphQ8 zg`s4!+xPadgjSpc>Gn&A15cQ)(UftBvL+t`wTEAR6!CnL*o9K-*y9jtag7ao3jm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1^ug=uNY$W zF!JGS#kSrplR_yPzI@JFc5vG(KKnvYo^L8-6J8Cs#qIIZPQz~me*XAP#!ri%VV{?F zE`I+1 #include #include -#include +#include -#include "window.h" -#include "server.h" #include "area.h" +#include "server.h" void refresh (Area *a) @@ -69,7 +68,7 @@ void draw (Area *a, int active) //printf("begin draw area\n"); if (*pmap) XFreePixmap (server.dsp, *pmap); - *pmap = server_create_pixmap (a->width, a->height); + *pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth); // add layer of root pixmap XCopyArea (server.dsp, server.pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); @@ -186,3 +185,24 @@ void free_area (Area *a) } } + +void draw_rect(cairo_t *c, double x, double y, double w, double h, double r) +{ + if (r > 0.0) { + double c1 = 0.55228475 * r; + + cairo_move_to(c, x+r, y); + cairo_rel_line_to(c, w-2*r, 0); + cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r); + cairo_rel_line_to(c, 0, h-2*r); + cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r); + cairo_rel_line_to (c, -w +2*r, 0); + cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r); + cairo_rel_line_to (c, 0, -h + 2 * r); + cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r); + } + else + cairo_rectangle(c, x, y, w, h); +} + + diff --git a/src/util/area.h b/src/util/area.h index 9a29ebd..0294353 100644 --- a/src/util/area.h +++ b/src/util/area.h @@ -30,10 +30,10 @@ #ifndef AREA_H #define AREA_H +#include #include -#include - -#include "common.h" +#include +#include typedef struct @@ -101,5 +101,8 @@ void remove_area (Area *a); void add_area (Area *a); void free_area (Area *a); +// draw rounded rectangle +void draw_rect(cairo_t *c, double x, double y, double w, double h, double r); + #endif diff --git a/src/util/window.c b/src/util/window.c index b265d6f..e60dc2c 100644 --- a/src/util/window.c +++ b/src/util/window.c @@ -24,7 +24,10 @@ #include #include #include + #include +#include +#include #include "common.h" #include "window.h" @@ -217,31 +220,12 @@ long *get_best_icon (long *data, int icon_count, int num, int *iw, int *ih, int } -void draw_rect(cairo_t *c, double x, double y, double w, double h, double r) -{ - if (r > 0.0) { - double c1 = 0.55228475 * r; - - cairo_move_to(c, x+r, y); - cairo_rel_line_to(c, w-2*r, 0); - cairo_rel_curve_to(c, c1, 0.0, r, c1, r, r); - cairo_rel_line_to(c, 0, h-2*r); - cairo_rel_curve_to(c, 0.0, c1, c1-r, r, -r, r); - cairo_rel_line_to (c, -w +2*r, 0); - cairo_rel_curve_to (c, -c1, 0, -r, -c1, -r, -r); - cairo_rel_line_to (c, 0, -h + 2 * r); - cairo_rel_curve_to (c, 0, -c1, r - c1, -r, r, -r); - } - else - cairo_rectangle(c, x, y, w, h); -} - - void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len) { PangoRectangle rect_ink, rect; - Pixmap pmap = server_create_pixmap (panel_height, panel_height); + Pixmap pmap = XCreatePixmap (server.dsp, server.root_win, panel_height, panel_height, server.depth); + cairo_surface_t *cs = cairo_xlib_surface_create (server.dsp, pmap, server.visual, panel_height, panel_height); cairo_t *c = cairo_create (cs); diff --git a/src/util/window.h b/src/util/window.h index fd596c0..8f3bba3 100644 --- a/src/util/window.h +++ b/src/util/window.h @@ -9,8 +9,6 @@ #ifndef WINDOW_H #define WINDOW_H -#include -#include #include @@ -37,9 +35,6 @@ void windows_set_desktop (Window win, int desktop); int window_get_monitor (Window win); Window window_get_active (); -// draw rounded rectangle -void draw_rect(cairo_t *c, double x, double y, double w, double h, double r); - void get_text_size(PangoFontDescription *font, int *height_ink, int *height, int panel_height, char *text, int len); -- 2.45.2