all repos — tint2 @ aabe6b11b9c98b8505a712915713166bd2e54902

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

add comment

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

aabe6b11b9c98b8505a712915713166bd2e54902

parent

906ee82dbf571e820d85988aae5a258fd1412205

M src/battery/battery.csrc/battery/battery.c

@@ -449,11 +449,11 @@ g_object_unref(layout);

} -void resize_battery(void *obj) +int resize_battery(void *obj) { Battery *battery = obj; PangoLayout *layout; - int percentage_width, time_width, new_width; + int percentage_width, time_width, new_width, ret = 0; percentage_width = time_width = 0; battery->area.redraw = 1;

@@ -465,7 +465,7 @@ } else {

snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes); } // vertical panel doen't adjust width - if (!panel_horizontal) return; + if (!panel_horizontal) return ret; cairo_surface_t *cs; cairo_t *c;

@@ -500,18 +500,17 @@ battery->area.posx = panel->area.width - battery->area.width - panel->area.paddingxlr - panel->area.bg->border.width;

if (panel->clock.area.on_screen) battery->area.posx -= (panel->clock.area.width + panel->area.paddingx); - if(new_width > old_width || new_width < (old_width-6)) { + if (new_width > old_width || new_width < (old_width-6)) { // refresh and resize other objects on panel // we try to limit the number of refresh // printf("battery_width %d, new_width %d\n", battery->area.width, new_width); - panel->area.resize = 1; - systray.area.resize = 1; - panel_refresh = 1; + ret = 1; } g_object_unref (layout); cairo_destroy (c); cairo_surface_destroy (cs); XFreePixmap (server.dsp, pmap); + return ret; }
M src/battery/battery.hsrc/battery/battery.h

@@ -71,6 +71,6 @@ void init_battery_panel(void *panel);

void draw_battery(void *obj, cairo_t *c); -void resize_battery(void *obj); +int resize_battery(void *obj); #endif
M src/clock/clock.csrc/clock/clock.c

@@ -225,11 +225,11 @@ g_object_unref (layout);

} -void resize_clock (void *obj) +int resize_clock (void *obj) { Clock *clock = obj; PangoLayout *layout; - int time_width, date_width, new_width; + int time_width, date_width, new_width, ret = 0; clock->area.redraw = 1; time_width = date_width = 0;

@@ -238,7 +238,7 @@ if (time2_format)

strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone)); // vertical panel doen't adjust width - if (!panel_horizontal) return; + if (!panel_horizontal) return ret; //printf(" resize_clock\n"); cairo_surface_t *cs;

@@ -274,11 +274,7 @@ // printf("clock_width %d, new_width %d\n", clock->area.width, new_width);

clock->area.width = new_width + 1; // resize other objects on panel - panel->area.resize = 1; -#ifdef ENABLE_BATTERY - panel->battery.area.resize = 1; -#endif - systray.area.resize = 1; + ret = 1; panel_refresh = 1; } clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.bg->border.width;

@@ -288,6 +284,7 @@ g_object_unref (layout);

cairo_destroy (c); cairo_surface_destroy (cs); XFreePixmap (server.dsp, pmap); + return ret; }
M src/clock/clock.hsrc/clock/clock.h

@@ -49,7 +49,7 @@ void init_clock_panel(void *panel);

void draw_clock (void *obj, cairo_t *c); -void resize_clock (void *obj); +int resize_clock (void *obj); void clock_action(int button);
M src/launcher/launcher.csrc/launcher/launcher.c

@@ -149,7 +149,7 @@ }

launcher_enabled = 0; } -void resize_launcher(void *obj) +int resize_launcher(void *obj) { Launcher *launcher = obj; Panel *panel = launcher->area.panel;

@@ -274,9 +274,7 @@ posy += (icon_size + launcher->area.paddingx);

} } } - - // resize force the redraw - launcher->area.redraw = 1; + return 1; }
M src/launcher/launcher.hsrc/launcher/launcher.h

@@ -66,7 +66,7 @@ void init_launcher();

void init_launcher_panel(void *panel); void cleanup_launcher(); -void resize_launcher(void *obj); +int resize_launcher(void *obj); void draw_launcher (void *obj, cairo_t *c); void launcher_action(LauncherIcon *icon);
M src/panel.csrc/panel.c

@@ -301,7 +301,7 @@ // printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, panel->area.height);

} -void resize_panel(void *obj) +int resize_panel(void *obj) { Panel *panel = (Panel*)obj; //printf("resize_panel : taskbar\n");

@@ -385,6 +385,7 @@ if (panel_mode == MULTI_DESKTOP)

posy += panel->taskbar[i].area.height + panel->area.paddingx; } } + return 0; }

@@ -580,12 +581,14 @@ XCopyArea(server.dsp, p->area.pix, p->hidden_pixmap, server.gc, xoff, yoff, p->hidden_width, p->hidden_height, 0, 0);

} // redraw panel's object + //p->area.redraw = 1; GSList *l0; Area *a; for (l0 = p->area.list; l0 ; l0 = l0->next) { a = l0->data; set_redraw(a); } + // reset task 'state_pix' int i; Taskbar *tskbar;
M src/panel.hsrc/panel.h

@@ -134,7 +134,7 @@ // use panel_config as default value

void init_panel(); void init_panel_size_and_position(Panel *panel); -void resize_panel(void *obj); +int resize_panel(void *obj); void set_panel_properties(Panel *p); void visible_object();
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -126,7 +126,7 @@ refresh_systray = 1;

} -void resize_systray(void *obj) +int resize_systray(void *obj) { Systraybar *sysbar = obj; Panel *panel = sysbar->area.panel;

@@ -228,8 +228,7 @@ // position and size the icon window

XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, icon_size, icon_size); XResizeWindow(server.dsp, traywin->tray_id, icon_size, icon_size); } - // resize force the redraw - systray.area.redraw = 1; + return 1; }
M src/systray/systraybar.hsrc/systray/systraybar.h

@@ -63,7 +63,7 @@ void init_systray();

void init_systray_panel(void *p); void draw_systray(void *obj, cairo_t *c); -void resize_systray(void *obj); +int resize_systray(void *obj); // systray protocol
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -261,7 +261,7 @@ XFree (win);

} -void resize_taskbar(void *obj) +int resize_taskbar(void *obj) { Taskbar *taskbar = (Taskbar*)obj; Panel *panel = (Panel*)taskbar->area.panel;

@@ -356,4 +356,5 @@

y += tsk->area.height + panel->g_taskbar.area.paddingx; } } + return 0; }
M src/taskbar/taskbar.hsrc/taskbar/taskbar.h

@@ -49,7 +49,7 @@ Task *task_get_task (Window win);

GPtrArray* task_get_tasks(Window win); void task_refresh_tasklist (); -void resize_taskbar(void *obj); +int resize_taskbar(void *obj); #endif
M src/util/area.csrc/util/area.c

@@ -34,79 +34,53 @@

/************************************************************ * !!! This design is experimental and not yet fully implemented !!!!!!!!!!!!! * - * AREA : + * DATA ORGANISATION : * Areas in tint2 are similar to widgets in a GUI. - * Graphical objects (panel, taskbar, task, systray, clock, ...) in tint2 'inherit' an Area class. - * Area is an abstract class of objects. It's at the begining of each object (&object == &area). - * Area manage the background and border drawing, size and padding. + * All graphical objects (panel, taskbar, task, systray, clock, ...) 'inherit' an abstract class 'Area'. + * This class 'Area' manage the background, border, size, position and padding. + * Area is at the begining of each object (&object == &area). * - * DATA ORGANISATION : - * tint2 define one panel per monitor. And each panel have a tree of Area (nodes). + * tint2 define one panel per monitor. And each panel have a tree of Area. * The root of the tree is Panel.Area. And task, clock, systray, taskbar,... are nodes. * + * The tree give the localisation of each object : + * - tree's root is in the background while tree's leafe are foreground objects + * - position of a node/Area depend on the layout : parent's position (posx, posy), size of previous brothers and parent's padding + * - size of a node/Area depend on the content (SIZE_BY_CONTENT objects) or on the layout (SIZE_BY_LAYOUT objects) + * + * DRAWING AND LAYERING ENGINE : + * Redrawing an object (like the clock) could come from an 'external event' (date change) + * or from a 'layering event' (position change). + * The following 'drawing engine' take care of all 'layering event'. + * 1) browse tree SIZE_BY_CONTENT + * - resize SIZE_BY_CONTENT node : children are resized before parent + * - if 'size' changed then 'resize = 1' on the parent + * 2) browse tree SIZE_BY_LAYOUT and POSITION + * - resize SIZE_BY_LAYOUT node : parent is resized before children + * - if 'size' changed then 'resize = 1' on childs with SIZE_BY_LAYOUT + * - calculate position (posx,posy) : parent is calculated before children + * - if 'position' changed then 'redraw = 1' + * 3) browse tree REDRAW + * - redraw needed objects : parent is drawn before children + * + * CONFIGURE PANEL'S LAYOUT : * 'panel_items' parameter (in config) define the list and the order of nodes in tree's panel. * 'panel_items = SC' define a panel with just Systray and Clock. - * So the root Panel.Area will have 2 childs (Systray and Clock). + * So the tree 'Panel.Area' will have 2 childs (Systray and Clock). * - * The tree allow to browse panel's objects from background to foreground and from left to right. - * The position of each node/Area depend on parent's position and brothers on the left. - * - * DRAWING EVENT : - * In the end, redrawing an object (like the clock) could come from an external event (date change) - * or from a layering event (size or position change). - * - * DRAWING LOOP : - * 1) browse tree and resize SIZE_BY_CONTENT node - * - children node are resized before its parent - * - if 'size' changed then 'redraw = 1' and 'resize = 1' on the parent - * 2) browse tree and resize SIZE_BY_LAYOUT node - * - parent node is resized before its children - * - if 'size' changed then 'redraw = 1' and 'resize = 1' on childs with SIZE_BY_LAYOUT - * 3) calculate posx of objects - * - parent's position is calculated before children's position - * - if 'position' changed then 'redraw = 1' - * 4) redraw needed objects - * - parent node is drawn before its children - * - * perhaps 2) and 3) can be merged... + * 1) ok + * 2) ?? + * 3) ?? * répartition entre niveau global et niveau local ?? * size_by_content peut-il modifier redraw=1 en cas de changement ? ou est ce géré par chaque composant ? * size_by_layout peut-il modifier redraw ? - * + * ************************************************************/ -void refresh (Area *a) -{ - // don't draw and resize hide objects - if (!a->on_screen) return; - - // don't draw transparent objects (without foreground and without background) - if (a->redraw) { - a->redraw = 0; - // force redraw of child - GSList *l; - for (l = a->list ; l ; l = l->next) - set_redraw(l->data); - - //printf("draw area posx %d, width %d\n", a->posx, a->width); - draw(a); - } - - // draw current Area - if (a->pix == 0) printf("empty area posx %d, width %d\n", a->posx, a->width); - XCopyArea (server.dsp, a->pix, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy); - - // and then refresh child object - GSList *l; - for (l = a->list; l ; l = l->next) - refresh(l->data); -} - - void size_by_content (Area *a) { - // don't draw and resize hide objects + // don't resize hiden objects if (!a->on_screen) return; // children node are resized before its parent

@@ -114,15 +88,16 @@ GSList *l;

for (l = a->list; l ; l = l->next) size_by_content(l->data); - // calculate current area's size + // calculate area's size if (a->resize && a->size_mode == SIZE_BY_CONTENT) { a->resize = 0; - // if 'size' changed then 'resize = 1' on the parent if (a->_resize) { - a->_resize(a); + if (a->_resize(a)) { + // 'size' changed then 'resize = 1' on the parent + ((Area*)a->parent)->resize = 1; + } a->redraw = 1; - ((Area*)a->parent)->resize = 1; } } }

@@ -130,27 +105,57 @@

void size_by_layout (Area *a) { - // don't draw and resize hide objects + // don't resize hiden objects if (!a->on_screen) return; // parent node is resized before its children - // calculate current area's size + // calculate area's size GSList *l; if (a->resize && a->size_mode == SIZE_BY_LAYOUT) { a->resize = 0; - // if 'size' changed then 'resize = 1' on childs with SIZE_BY_LAYOUT if (a->_resize) { - a->_resize(a); - for (l = a->list; l ; l = l->next) { - if (((Area*)l->data)->size_mode == SIZE_BY_LAYOUT) - ((Area*)l->data)->resize = 1; + if (a->_resize(a)) { + // if 'size' changed then 'resize = 1' on childs with SIZE_BY_LAYOUT + for (l = a->list; l ; l = l->next) { + if (((Area*)l->data)->size_mode == SIZE_BY_LAYOUT) + ((Area*)l->data)->resize = 1; + } } } } for (l = a->list; l ; l = l->next) size_by_layout(l->data); +} + + +void refresh (Area *a) +{ + // don't draw and resize hide objects + if (!a->on_screen) return; + + // don't draw transparent objects (without foreground and without background) + if (a->redraw) { + a->redraw = 0; + // force redraw of child + GSList *l; + for (l = a->list ; l ; l = l->next) + ((Area*)l->data)->redraw = 1; +// set_redraw(l->data); + + //printf("draw area posx %d, width %d\n", a->posx, a->width); + draw(a); + } + + // draw current Area + if (a->pix == 0) printf("empty area posx %d, width %d\n", a->posx, a->width); + XCopyArea (server.dsp, a->pix, ((Panel *)a->panel)->temp_pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy); + + // and then refresh child object + GSList *l; + for (l = a->list; l ; l = l->next) + refresh(l->data); }
M src/util/area.hsrc/util/area.h

@@ -81,7 +81,8 @@ void *panel;

// each object can overwrite following function void (*_draw_foreground)(void *obj, cairo_t *c); - void (*_resize)(void *obj); + // calculate size. return '1' if size changed, '0' otherwise. + int (*_resize)(void *obj); void (*_add_child)(void *obj); int (*_remove_child)(void *obj); const char* (*_get_tooltip_text)(void *obj);