From: Thierry Lorthiois Date: Fri, 13 Feb 2009 21:54:42 +0000 (+0000) Subject: tint2 looks good for me. if you see bugs, report it. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=da65866b2388391052e3ce95818c1d5ebd2b26b5;p=chaz%2Ftint2 tint2 looks good for me. if you see bugs, report it. --- diff --git a/ChangeLog b/ChangeLog index 097d718..55a5ac9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-02-13 +- improved object oriented layout +- tint2 looks good for me. if you see bugs, report it. + 2009-02-12 - fixed issue 14 : no icons diff --git a/src/clock/clock.c b/src/clock/clock.c index e7bb32f..35fb595 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -52,6 +52,9 @@ void init_clock(Clock *clock, Area *parent) clock->area._resize = resize_clock; if (!time1_format) return; + // add clock to the panel + panel->area.list = g_slist_append(panel->area.list, clock); + if (strchr(time1_format, 'S') == NULL) time_precision = 60; else time_precision = 1; @@ -119,12 +122,13 @@ void draw_foreground_clock (void *obj, cairo_t *c, int active) void resize_clock (void *obj) { - Area *parent = ((Area*)obj)->parent; Clock *clock = obj; PangoLayout *layout; int time_width, date_width, new_width; time_width = date_width = 0; + clock->area.redraw = 1; + strftime(buf_time, sizeof(buf_time), time1_format, localtime(&time_clock.tv_sec)); if (time2_format) strftime(buf_date, sizeof(buf_date), time2_format, localtime(&time_clock.tv_sec)); @@ -156,11 +160,19 @@ void resize_clock (void *obj) new_width += (2*clock->area.paddingxlr) + (2*clock->area.pix.border.width); if (new_width > clock->area.width || new_width < (clock->area.width-3)) { - // resize clock + int i; + Panel *panel = ((Area*)obj)->panel; + //printf("clock_width %d, new_width %d\n", clock->area.width, new_width); + // resize clock clock->area.width = new_width; - clock->area.posx = parent->width - clock->area.width - parent->paddingxlr - parent->pix.border.width; - set_resize(parent); + clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.pix.border.width; + + // resize other objects on panel + for (i=0 ; i < nb_panel ; i++) { + panel1[i].area.resize = 1; + } + panel_refresh = 1; } g_object_unref (layout); diff --git a/src/config.c b/src/config.c index f423654..f93faf5 100644 --- a/src/config.c +++ b/src/config.c @@ -570,16 +570,17 @@ void config_finish () } init_panel(); + // force the resize + for (i=0 ; i < nb_panel ; i++) { + panel1[i].area.resize = 1; + resize_clock(&panel1[i].clock); + } + init_taskbar(); visible_object(); cleanup_config(); - // force the resize (using visible_object() order) - for (i=0 ; i < nb_panel ; i++) { - //init_systray(&panel1[i].trayer, &panel1[i].area); - set_resize(&panel1[i]); - } task_refresh_tasklist(); } diff --git a/src/panel.c b/src/panel.c index 881fdaf..b12f58a 100644 --- a/src/panel.c +++ b/src/panel.c @@ -58,8 +58,10 @@ void init_panel() for (i=0 ; i < nb_panel ; i++) { p = &panel1[i]; - p->area.parent = 0; + p->area.parent = p; p->area.panel = p; + p->area.visible = 1; + p->area._resize = resize_panel; p->g_taskbar.parent = p; p->g_taskbar.panel = p; p->g_task.area.panel = p; @@ -73,6 +75,7 @@ void init_panel() else p->area.height = p->initial_height; + // full width mode if (!p->area.width) p->area.width = server.monitor[p->monitor].width; @@ -125,52 +128,113 @@ void cleanup_panel() cleanup_taskbar(); + // font allocated once + if (panel1[0].g_task.font_desc) { + pango_font_description_free(panel1[0].g_task.font_desc); + panel1[0].g_task.font_desc = 0; + } + int i; Panel *p; for (i=0 ; i < nb_panel ; i++) { p = &panel1[i]; - // no free_area(&p->area) because it's the list of visible objects - if (p->area.list) { - g_slist_free(p->area.list); - p->area.list = 0; + // freed list of visible objects + if (p->list_visible) { + g_slist_free(p->list_visible); + p->list_visible = 0; } + free_area(&p->area); free_area(&p->g_task.area); free_area(&p->g_taskbar); - free_area(&p->clock.area); - if (p->area.pix.pmap) XFreePixmap(server.dsp, p->area.pix.pmap); - if (p->area.pix_active.pmap) XFreePixmap(server.dsp, p->area.pix_active.pmap); - if (p->root_pmap) XFreePixmap(server.dsp, p->root_pmap); - if (p->main_win) XDestroyWindow(server.dsp, p->main_win); - } - // font allocated once - if (panel1[0].g_task.font_desc) pango_font_description_free(panel1[0].g_task.font_desc); + if (p->temp_pmap) { + XFreePixmap(server.dsp, p->temp_pmap); + p->temp_pmap = 0; + } + if (p->main_win) { + XDestroyWindow(server.dsp, p->main_win); + p->main_win = 0; + } + } if (panel1) free(panel1); panel1 = 0; } -void visual_refresh (Panel *p) +void resize_panel(void *obj) { - if (p->root_pmap) XFreePixmap(server.dsp, p->root_pmap); - p->root_pmap = XCreatePixmap(server.dsp, server.root_win, p->area.width, p->area.height, server.depth); + Panel *panel = (Panel*)obj; + int taskbar_width, modulo_width, taskbar_on_screen; + +//printf("resize_panel : : posx et width des barres de taches\n"); + + if (panel_mode == MULTI_DESKTOP) taskbar_on_screen = panel->nb_desktop; + else taskbar_on_screen = 1; + + taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); + if (time1_format) + taskbar_width -= (panel->clock.area.width + panel->area.paddingx); + //taskbar_width -= (panel->trayer.area.width + panel->area.paddingx); + + taskbar_width = (taskbar_width - ((taskbar_on_screen-1) * panel->area.paddingx)) / taskbar_on_screen; + + if (taskbar_on_screen > 1) + modulo_width = (taskbar_width - ((taskbar_on_screen-1) * panel->area.paddingx)) % taskbar_on_screen; + else + modulo_width = 0; + + // change posx and width for all taskbar + int i, modulo=0, posx=0; + for (i=0 ; i < panel->nb_desktop ; i++) { + if ((i % taskbar_on_screen) == 0) { + posx = panel->area.pix.border.width + panel->area.paddingxlr; + modulo = modulo_width; + } + else posx += taskbar_width + panel->area.paddingx; + + panel->taskbar[i].area.posx = posx; + panel->taskbar[i].area.width = taskbar_width; + panel->taskbar[i].area.resize = 1; + if (modulo) { + panel->taskbar[i].area.width++; + modulo--; + } + } +} - XCopyArea (server.dsp, p->area.pix.pmap, p->root_pmap, server.gc, 0, 0, p->area.width, p->area.height, 0, 0); - // draw child object - GSList *l = p->area.list; - for (; l ; l = l->next) { - refresh (l->data); - } +void visible_object() +{ + Panel *panel; + int i, j; + + for (i=0 ; i < nb_panel ; i++) { + panel = &panel1[i]; - XCopyArea(server.dsp, p->root_pmap, p->main_win, server.gc, 0, 0, p->area.width, p->area.height, 0, 0); + // clock before taskbar because resize(clock) can resize others object + if (time1_format) + panel->clock.area.visible = 1; + else + panel->clock.area.visible = 0; + + //panel->area.list = g_slist_append(panel->area.list, &panel->trayer); - // main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right. - // this feature is disabled ! - //XCopyArea (server.dsp, server.pmap, p->main_win, server.gc, p->area.paddingxlr, 0, p->area.width-(2*p->area.paddingxlr), p->area.height, 0, 0); + Taskbar *taskbar; + for (j=0 ; j < panel->nb_desktop ; j++) { + taskbar = &panel->taskbar[j]; + if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) { + // (SINGLE_DESKTOP or SINGLE_MONITOR) and not current desktop + taskbar->area.visible = 0; + } + else { + taskbar->area.visible = 1; + } + } + } + panel_refresh = 1; } @@ -235,42 +299,6 @@ void set_panel_properties(Panel *p) } -void visible_object() -{ - Panel *panel; - int i, j; - - for (i=0 ; i < nb_panel ; i++) { - panel = &panel1[i]; - - if (panel->area.list) { - g_slist_free(panel->area.list); - panel->area.list = 0; - } - - // list of visible objects - // start with clock because draw(clock) can resize others object - if (time1_format) - panel->area.list = g_slist_append(panel->area.list, &panel->clock); - - //panel->area.list = g_slist_append(panel->area.list, &panel->trayer); - - Taskbar *taskbar; - for (j=0 ; j < panel->nb_desktop ; j++) { - taskbar = &panel->taskbar[j]; - if (panel_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) { - // (SINGLE_DESKTOP or SINGLE_MONITOR) and not current desktop - continue; - } - - panel->area.list = g_slist_append(panel->area.list, taskbar); - } - set_redraw(&panel->area); - } - panel_refresh = 1; -} - - void set_panel_background(Panel *p) { get_root_pixmap(); @@ -278,7 +306,7 @@ void set_panel_background(Panel *p) if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap); p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth); - // copy background (server.root_pmap) in panel + // copy background (server.root_pmap) in panel.area.pix.pmap Window dummy; int x, y; XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy); @@ -296,11 +324,13 @@ void set_panel_background(Panel *p) cairo_destroy (c); cairo_surface_destroy (cs); - // redraw panel - set_redraw (&p->area); - - // copy background panel on desktop window - //XCopyArea (server.dsp, p->area.pix.pmap, server.root_win, server.gc_root, 0, 0, p->area.width, p->area.height, p->posx, p->posy); + // redraw panel's object + GSList *l0; + Area *a; + for (l0 = p->area.list; l0 ; l0 = l0->next) { + a = l0->data; + set_redraw(a); + } } diff --git a/src/panel.h b/src/panel.h index 3a4b6dd..64ffcdb 100644 --- a/src/panel.h +++ b/src/panel.h @@ -46,12 +46,17 @@ extern Task *task_drag; typedef struct { // always start with area + // area.list own all objects of the panel according to config file Area area; + // list of visible objects + GSList *list_visible; + // -------------------------------------------------- // panel Window main_win; - Pixmap root_pmap; + Pixmap temp_pmap; + // position relative to root window int posx, posy; int marginx, marginy; @@ -90,13 +95,15 @@ extern int nb_panel; void init_panel(); void cleanup_panel(); -void visual_refresh(Panel *p); +void resize_panel(void *obj); + void set_panel_properties(Panel *p); void visible_object(); // draw background panel void set_panel_background(Panel *p); +// detect witch panel Panel *get_panel(Window win); #endif diff --git a/src/systray/systraybar.c b/src/systray/systraybar.c index 0c515e9..2406145 100644 --- a/src/systray/systraybar.c +++ b/src/systray/systraybar.c @@ -54,7 +54,7 @@ void init_systray(Systraybar *sysbar, Area *parent) sysbar->area.redraw = 1; -printf("init_systray"); +//printf("init_systray"); net_init(); } diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 2c039ab..50a64d4 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -77,11 +77,8 @@ void add_task (Window win) new_tsk2->icon_width = new_tsk.icon_width; new_tsk2->icon_height = new_tsk.icon_height; tskbar->area.list = g_slist_append(tskbar->area.list, new_tsk2); - + tskbar->area.resize = 1; //printf("add_task panel %d, desktop %d, task %s\n", i, j, new_tsk2->title); - // set_resize (&tskbar->area); - if (resize_tasks (tskbar)) - set_redraw (&tskbar->area); } } } @@ -97,7 +94,6 @@ void remove_task (Task *tsk) // free title and icon just for the first task // even with task_on_all_desktop and with task_on_all_panel //printf("remove_task %s %d\n", tsk->title, tsk->desktop); - //printf("remove_task %s \n", tsk->title); if (tsk->title) free (tsk->title); if (tsk->icon_data) @@ -117,8 +113,7 @@ void remove_task (Task *tsk) l0 = l0->next; if (win == tsk2->win) { tskbar->area.list = g_slist_remove(tskbar->area.list, tsk2); - set_resize (&tskbar->area); - set_redraw (&tskbar->area); + tskbar->area.resize = 1; if (tsk2 == task_active) task_active = 0; diff --git a/src/taskbar/taskbar.c b/src/taskbar/taskbar.c index 45d3b3d..70af337 100644 --- a/src/taskbar/taskbar.c +++ b/src/taskbar/taskbar.c @@ -42,11 +42,17 @@ void init_taskbar() for (i=0 ; i < nb_panel ; i++) { panel = &panel1[i]; + if (panel->taskbar) { + free(panel->taskbar); + panel->taskbar = 0; + } + // taskbar panel->g_taskbar._resize = resize_taskbar; panel->g_taskbar.posy = panel->area.pix.border.width + panel->area.paddingy; panel->g_taskbar.height = panel->area.height - (2 * panel->g_taskbar.posy); panel->g_taskbar.redraw = 1; + panel->g_taskbar.visible = 1; // task panel->g_task.area._draw_foreground = draw_foreground_task; @@ -54,6 +60,7 @@ void init_taskbar() panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy); panel->g_task.area.use_active = 1; panel->g_task.area.redraw = 1; + panel->g_task.area.visible = 1; if (panel->g_task.area.pix.border.rounded > panel->g_task.area.height/2) { panel->g_task.area.pix.border.rounded = panel->g_task.area.height/2; @@ -84,6 +91,9 @@ void init_taskbar() tskbar = &panel->taskbar[j]; memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area)); tskbar->desktop = j; + + // add taskbar to the panel + panel->area.list = g_slist_append(panel->area.list, tskbar); } } } @@ -92,6 +102,7 @@ void init_taskbar() void cleanup_taskbar() { Panel *panel; + Taskbar *tskbar; int i, j; GSList *l0; Task *tsk; @@ -100,14 +111,18 @@ void cleanup_taskbar() panel = &panel1[i]; for (j=0 ; j < panel->nb_desktop ; j++) { - l0 = panel->taskbar[j].area.list; + tskbar = &panel->taskbar[j]; + l0 = tskbar->area.list; while (l0) { tsk = l0->data; l0 = l0->next; // careful : remove_task change l0->next remove_task (tsk); } - free_area (&panel->taskbar[j].area); + free_area (&tskbar->area); + + // remove taskbar from the panel + panel->area.list = g_slist_remove(panel->area.list, tskbar); } } @@ -188,17 +203,21 @@ void task_refresh_tasklist () } -int resize_tasks (Taskbar *taskbar) +void resize_taskbar(void *obj) { - int ret, task_count, pixel_width, modulo_width=0; - int x, taskbar_width; - Task *tsk; + Taskbar *taskbar = (Taskbar*)obj; Panel *panel = (Panel*)taskbar->area.panel; + int task_count, pixel_width, modulo_width=0; + int x, taskbar_width; + Task *tsk; GSList *l; +//printf("resize_taskbar : posx et width des taches\n"); + + taskbar->area.redraw = 1; + // new task width for 'desktop' task_count = g_slist_length(taskbar->area.list); - if (!task_count) pixel_width = panel->g_task.maximum_width; else { taskbar_width = taskbar->area.width - (2 * panel->g_taskbar.pix.border.width) - (2 * panel->g_taskbar.paddingxlr); @@ -210,13 +229,10 @@ int resize_tasks (Taskbar *taskbar) else modulo_width = taskbar_width % task_count; } - //printf("monitor %d, resize_tasks %d %d\n", panel->monitor, task_count, pixel_width); if ((taskbar->task_width == pixel_width) && (taskbar->task_modulo == modulo_width)) { - ret = 0; } else { - ret = 1; taskbar->task_width = pixel_width; taskbar->task_modulo = modulo_width; taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->g_task.area.paddingx; @@ -228,6 +244,7 @@ int resize_tasks (Taskbar *taskbar) tsk = l->data; tsk->area.posx = x; tsk->area.width = pixel_width; + tsk->area.redraw = 1; if (modulo_width) { tsk->area.width++; modulo_width--; @@ -235,49 +252,7 @@ int resize_tasks (Taskbar *taskbar) x += tsk->area.width + panel->g_taskbar.paddingx; } - return ret; } -// initialise taskbar posx and width -void resize_taskbar(void *obj) -{ - Panel *panel = ((Area*)obj)->panel; - int taskbar_width, modulo_width, taskbar_on_screen; - - if (panel_mode == MULTI_DESKTOP) taskbar_on_screen = panel->nb_desktop; - else taskbar_on_screen = 1; - - taskbar_width = panel->area.width - (2 * panel->area.paddingxlr) - (2 * panel->area.pix.border.width); - if (time1_format) - taskbar_width -= (panel->clock.area.width + panel->area.paddingx); - //taskbar_width -= (panel->trayer.area.width + panel->area.paddingx); - - taskbar_width = (taskbar_width - ((taskbar_on_screen-1) * panel->area.paddingx)) / taskbar_on_screen; - - if (taskbar_on_screen > 1) - modulo_width = (taskbar_width - ((taskbar_on_screen-1) * panel->area.paddingx)) % taskbar_on_screen; - else - modulo_width = 0; - - int i, modulo=0, posx=0; - for (i=0 ; i < panel->nb_desktop ; i++) { - if ((i % taskbar_on_screen) == 0) { - posx = panel->area.pix.border.width + panel->area.paddingxlr; - modulo = modulo_width; - } - else posx += taskbar_width + panel->area.paddingx; - - panel->taskbar[i].area.posx = posx; - panel->taskbar[i].area.width = taskbar_width; - if (modulo) { - panel->taskbar[i].area.width++; - modulo--; - } - - set_redraw (&panel->taskbar[i].area); - resize_tasks(&panel->taskbar[i]); - } -} - diff --git a/src/taskbar/taskbar.h b/src/taskbar/taskbar.h index 807e285..2a08c27 100644 --- a/src/taskbar/taskbar.h +++ b/src/taskbar/taskbar.h @@ -31,9 +31,6 @@ void cleanup_taskbar(); Task *task_get_task (Window win); void task_refresh_tasklist (); -// return 1 if task_width changed -int resize_tasks (Taskbar *tskbar); - void resize_taskbar(void *obj); diff --git a/src/tint.c b/src/tint.c index b84ee18..20038c1 100644 --- a/src/tint.c +++ b/src/tint.c @@ -138,6 +138,7 @@ void event_button_press (XEvent *e) int y = e->xbutton.y; for (l0 = panel->area.list; l0 ; l0 = l0->next) { tskbar = l0->data; + if (!tskbar->area.visible) continue; if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width)) break; } @@ -187,6 +188,7 @@ void event_button_release (XEvent *e) GSList *l0; for (l0 = panel->area.list; l0 ; l0 = l0->next) { tskbar = l0->data; + if (!tskbar->area.visible) continue; if (x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width)) goto suite; } @@ -250,7 +252,7 @@ void event_property_notify (Window win, Atom at) init_taskbar(); visible_object(); for (i=0 ; i < nb_panel ; i++) { - set_resize(&panel1[i]); + panel1[i].area.resize = 1; } task_refresh_tasklist(); panel_refresh = 1; @@ -400,6 +402,11 @@ void event_configure_notify (Window win) // task on another monitor remove_task (tsk); add_task (win); + if (win == window_get_active ()) { + Task *tsk = task_get_task (win); + tsk->area.is_active = 1; + task_active = tsk; + } panel_refresh = 1; } } @@ -421,7 +428,6 @@ void event_timer() int i; for (i=0 ; i < nb_panel ; i++) { - panel1[i].clock.area.redraw = 1; panel1[i].clock.area.resize = 1; } panel_refresh = 1; @@ -483,9 +489,7 @@ load_config: case Expose: panel = get_panel(e.xany.window); if (!panel) break; - //XCopyArea (server.dsp, panel.area.pix.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy); - //XCopyArea (server.dsp, server.pmap, panel.main_win, server.gc, panel.area.paddingxlr, 0, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, 0); - XCopyArea (server.dsp, panel->root_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0); + XCopyArea (server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0); break; case PropertyNotify: @@ -532,14 +536,26 @@ load_config: } if (panel_refresh) { + panel_refresh = 0; + for (i=0 ; i < nb_panel ; i++) { - visual_refresh(&panel1[i]); - } + panel = &panel1[i]; + if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap); + panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth); + + refresh(panel); + XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0); + } XFlush (server.dsp); - panel_refresh = 0; } } } +// **************************************************** +// main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right. +// this feature is disabled ! +//XCopyArea (server.dsp, server.pmap, p->main_win, server.gc, p->area.paddingxlr, 0, p->area.width-(2*p->area.paddingxlr), p->area.height, 0, 0); +//XCopyArea (server.dsp, panel.area.pix.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy); +//XCopyArea (server.dsp, server.pmap, panel.main_win, server.gc, panel.area.paddingxlr, 0, panel.area.width-(2*panel.area.paddingxlr), panel.area.height, 0, 0); diff --git a/src/tint2 b/src/tint2 index c3248d4..42b9397 100755 Binary files a/src/tint2 and b/src/tint2 differ diff --git a/src/util/area.c b/src/util/area.c index 7606679..4cb3b41 100644 --- a/src/util/area.c +++ b/src/util/area.c @@ -32,15 +32,18 @@ void refresh (Area *a) { + if (!a->visible) return; if (a->resize) { // resize can generate a redraw - if (a->_resize) + if (a->_resize) { + //printf("resize area posx %d, width %d\n", a->posx, a->width); a->_resize(a); + } a->resize = 0; } if (a->redraw) { - //printf("draw pix\n"); + //printf("draw area posx %d, width %d\n", a->posx, a->width); draw(a, 0); if (a->use_active) draw(a, 1); @@ -49,7 +52,7 @@ void refresh (Area *a) // draw current Area Pixmap *pmap = (a->is_active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap); - XCopyArea (server.dsp, *pmap, ((Panel *)a->panel)->root_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy); + XCopyArea (server.dsp, *pmap, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy); // and then refresh child object GSList *l = a->list; @@ -68,26 +71,15 @@ void set_redraw (Area *a) } -void set_resize (Area *a) -{ - a->resize = 1; - - GSList *l; - for (l = a->list ; l ; l = l->next) - set_resize(l->data); -} - - void draw (Area *a, int active) { Pixmap *pmap = (active == 0) ? (&a->pix.pmap) : (&a->pix_active.pmap); - //printf("begin draw area\n"); if (*pmap) XFreePixmap (server.dsp, *pmap); *pmap = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth); // add layer of root pixmap - XCopyArea (server.dsp, ((Panel *)a->panel)->root_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); + XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, *pmap, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); cairo_surface_t *cs; cairo_t *c; @@ -151,7 +143,6 @@ void draw_background (Area *a, cairo_t *c, int active) x1 = X1 * ((double)a->height / 100); y0 = Y0 * ((double)a->width / 100); y1 = Y1 * ((double)a->width / 100); - printf("repère (%d, %d) points (%lf, %lf) (%lf, %lf)\n", a->width, a->height, x0, y0, x1, y1); cairo_pattern_t *linpat; linpat = cairo_pattern_create_linear (x0, y0, x1, y1); @@ -197,8 +188,14 @@ void free_area (Area *a) g_slist_free(a->list); a->list = 0; } - if (a->pix.pmap) XFreePixmap (server.dsp, a->pix.pmap); - if (a->pix_active.pmap) XFreePixmap (server.dsp, a->pix_active.pmap); + if (a->pix.pmap) { + XFreePixmap (server.dsp, a->pix.pmap); + a->pix.pmap = 0; + } + if (a->pix_active.pmap) { + XFreePixmap (server.dsp, a->pix_active.pmap); + a->pix_active.pmap = 0; + } } diff --git a/src/util/area.h b/src/util/area.h index acea08f..da32592 100644 --- a/src/util/area.h +++ b/src/util/area.h @@ -7,7 +7,7 @@ * Area manage the background and border drawing, size and padding. * Each Area have 2 Pixmap (pix and pix_active). * -* Area also manage the tree of visible objects. Parent object drawn before child object. +* Area manage the tree of all objects. Parent object drawn before child object. * panel -> taskbars -> tasks * -> systray -> icons * -> clock @@ -59,6 +59,7 @@ typedef struct { // list of child : Area object GSList *list; + int visible; // need compute position and width int resize; // need redraw Pixmap