all repos — tint2 @ 52eb84304720ad42138ead5147a7e57b4f7b54f7

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

order of panel items : position of each object is update by layering engine (area)

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

52eb84304720ad42138ead5147a7e57b4f7b54f7

parent

438dbfed027606e5e3a142bb0e0ec06dbf14cb0f

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

@@ -38,11 +38,8 @@ #endif

#include "window.h" #include "server.h" -#include "area.h" #include "panel.h" -#include "taskbar.h" #include "battery.h" -#include "clock.h" #include "timer.h" #include "common.h"

@@ -76,8 +73,6 @@ for (i=0 ; i < nb_panel ; i++) {

if (battery_state.percentage >= percentage_hide) { if (panel1[i].battery.area.on_screen == 1) { panel1[i].battery.area.on_screen = 0; - // force resize on panel - panel1[i].area.resize = 1; panel_refresh = 1; } continue;

@@ -85,8 +80,6 @@ }

else { if (panel1[i].battery.area.on_screen == 0) { panel1[i].battery.area.on_screen = 1; - // force resize on panel - panel1[i].area.resize = 1; panel_refresh = 1; } }

@@ -250,8 +243,6 @@ battery->area.height = panel->area.height - (2 * battery->area.posy);

} else { // panel vertical => fixed width, height, posy and posx - battery->area.posy = panel->clock.area.posy + panel->clock.area.height + panel->area.paddingx; - battery->area.height = (2 * battery->area.paddingxlr) + (bat_time_height + bat_percentage_height); battery->area.posx = panel->area.bg->border.width + panel->area.paddingy; battery->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy); }

@@ -465,7 +456,11 @@ } 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 ret; + if (!panel_horizontal) { +// battery->area.posy = panel->clock.area.posy + panel->clock.area.height + panel->area.paddingx; +// battery->area.height = (2 * battery->area.paddingxlr) + (bat_time_height + bat_percentage_height); + return ret; + } cairo_surface_t *cs; cairo_t *c;

@@ -490,16 +485,11 @@

if(percentage_width > time_width) new_width = percentage_width; else new_width = time_width; - new_width += (2*battery->area.paddingxlr) + (2*battery->area.bg->border.width); - int old_width = battery->area.width; - - Panel *panel = ((Area*)obj)->panel; + + new_width += (2*battery->area.paddingxlr) + (2*battery->area.bg->border.width); battery->area.width = new_width + 1; - 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)) { // refresh and resize other objects on panel // we try to limit the number of refresh
M src/clock/clock.csrc/clock/clock.c

@@ -26,9 +26,7 @@ #include <stdlib.h>

#include "window.h" #include "server.h" -#include "area.h" #include "panel.h" -#include "taskbar.h" #include "clock.h" #include "timer.h" #include "common.h"

@@ -169,8 +167,8 @@ clock->area.height = panel->area.height - (2 * clock->area.posy);

} else { // panel vertical => fixed width, height, posy and posx - clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr; - clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height); +// clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr; +// clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height); clock->area.posx = panel->area.bg->border.width + panel->area.paddingy; clock->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy); }

@@ -266,7 +264,6 @@ if (time_width > date_width) new_width = time_width;

else new_width = date_width; new_width += (2*clock->area.paddingxlr) + (2*clock->area.bg->border.width); - Panel *panel = ((Area*)obj)->panel; if (new_width > clock->area.width || new_width < (clock->area.width-6)) { // resize clock // we try to limit the number of resize

@@ -277,8 +274,6 @@ // resize other objects on panel

ret = 1; panel_refresh = 1; } - clock->area.posx = panel->area.width - clock->area.width - panel->area.paddingxlr - panel->area.bg->border.width; - g_object_unref (layout); cairo_destroy (c);
M src/launcher/launcher.csrc/launcher/launcher.c

@@ -223,7 +223,7 @@ icons_per_row = count / icons_per_column + (count%icons_per_column != 0);

launcher->area.width = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * launcher->area.paddingx); } - launcher->area.posx = panel->area.bg->border.width + panel->area.paddingxlr; +// launcher->area.posx = panel->area.bg->border.width + panel->area.paddingxlr; launcher->area.posy = panel->area.bg->border.width; } else {

@@ -238,7 +238,7 @@ launcher->area.height = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * launcher->area.paddingx);

} launcher->area.posx = panel->area.bg->border.width; - launcher->area.posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - launcher->area.height; +// launcher->area.posy = panel->area.height - panel->area.bg->border.width - panel->area.paddingxlr - launcher->area.height; } int i, posx, posy;
M src/panel.csrc/panel.c

@@ -393,7 +393,7 @@ if (panel_mode == MULTI_DESKTOP)

posy += panel->taskbar[i].area.height + panel->area.paddingx; } } - return 1; + return 0; }
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -116,6 +116,53 @@

void draw_systray(void *obj, cairo_t *c) { + // TODO : position and size the icon window when position of systray is known + Systraybar *sysbar = obj; + Panel *panel = sysbar->area.panel; + int i, posx, posy, marging=3, icons_per_column=1, icons_per_row=1; + int icon_size = 24; + int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +marging/2; + if (panel_horizontal) { + posy = start; + posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr; + } + else { + posx = start; + posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr; + } + + TrayWindow *traywin; + GSList *l; + for (i=1, l = systray.list_icons; l ; i++, l = l->next) { + traywin = (TrayWindow*)l->data; + if (traywin->hide) continue; + + traywin->y = posy; + traywin->x = posx; + traywin->width = icon_size; + traywin->height = icon_size; + if (panel_horizontal) { + if (i % icons_per_column) + posy += icon_size + sysbar->area.paddingx; + else { + posy = start; + posx += (icon_size + systray.area.paddingx); + } + } + else { + if (i % icons_per_row) + posx += icon_size + systray.area.paddingx; + else { + posx = start; + posy += (icon_size + systray.area.paddingx); + } + } + + // 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); + } + if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { if (render_background) XFreePixmap(server.dsp, render_background); render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);

@@ -129,8 +176,6 @@

int resize_systray(void *obj) { Systraybar *sysbar = obj; - Panel *panel = sysbar->area.panel; - TrayWindow *traywin; GSList *l; int count, icon_size; int icons_per_column=1, icons_per_row=1, marging=0;

@@ -159,14 +204,6 @@ marging = height - (icons_per_column-1)*(icon_size+sysbar->area.paddingx) - icon_size;

icons_per_row = count / icons_per_column + (count%icons_per_column != 0); systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * systray.area.paddingx); } - - systray.area.posx = panel->area.width - panel->area.bg->border.width - panel->area.paddingxlr - systray.area.width; - if (panel->clock.area.on_screen) - systray.area.posx -= (panel->clock.area.width + panel->area.paddingx); -#ifdef ENABLE_BATTERY - if (panel->battery.area.on_screen) - systray.area.posx -= (panel->battery.area.width + panel->area.paddingx); -#endif } else { if (!count) systray.area.height = 0;

@@ -178,55 +215,6 @@ marging = width - (icons_per_row-1)*(icon_size+sysbar->area.paddingx) - icon_size;

icons_per_column = count / icons_per_row+ (count%icons_per_row != 0); systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * systray.area.paddingx); } - - systray.area.posy = panel->area.bg->border.width + panel->area.paddingxlr; - if (panel->clock.area.on_screen) - systray.area.posy += (panel->clock.area.height + panel->area.paddingx); -#ifdef ENABLE_BATTERY - if (panel->battery.area.on_screen) - systray.area.posy += (panel->battery.area.height + panel->area.paddingx); -#endif - } - - int i, posx, posy; - int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width + systray.area.paddingy +marging/2; - if (panel_horizontal) { - posy = start; - posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr; - } - else { - posx = start; - posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr; - } - - for (i=1, l = systray.list_icons; l ; i++, l = l->next) { - traywin = (TrayWindow*)l->data; - if (traywin->hide) continue; - - traywin->y = posy; - traywin->x = posx; - traywin->width = icon_size; - traywin->height = icon_size; - if (panel_horizontal) { - if (i % icons_per_column) - posy += icon_size + sysbar->area.paddingx; - else { - posy = start; - posx += (icon_size + systray.area.paddingx); - } - } - else { - if (i % icons_per_row) - posx += icon_size + systray.area.paddingx; - else { - posx = start; - posy += (icon_size + systray.area.paddingx); - } - } - - // 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); } return 1; }
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -266,7 +266,7 @@ border_width = taskbar->area.bg->border.width;

if (panel_horizontal) { int pixel_width, modulo_width=0; - int x, taskbar_width; + int taskbar_width; // new task width for 'desktop' task_count = g_slist_length(taskbar->area.list);

@@ -287,27 +287,24 @@ taskbar->task_modulo = modulo_width;

taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx; // change pos_x and width for all tasks - x = taskbar->area.posx + border_width + taskbar->area.paddingxlr; for (l = taskbar->area.list; l ; l = l->next) { tsk = l->data; if (!tsk->area.on_screen) continue; - tsk->area.posx = x; set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id) tsk->area.width = pixel_width; - long value[] = { panel->posx+x, panel->posy, pixel_width, panel->area.height }; - XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4); +// TODO : move later (when posx is known) +// long value[] = { panel->posx+x, panel->posy, pixel_width, panel->area.height }; +// XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4); if (modulo_width) { tsk->area.width++; modulo_width--; } - - x += tsk->area.width + panel->g_taskbar.area.paddingx; } } else { int pixel_height, modulo_height=0; - int y, taskbar_height; + int taskbar_height; // new task width for 'desktop' task_count = g_slist_length(taskbar->area.list);

@@ -328,23 +325,21 @@ taskbar->task_modulo = modulo_height;

taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx; // change pos_y and height for all tasks - y = taskbar->area.posy + border_width + taskbar->area.paddingxlr; for (l = taskbar->area.list; l ; l = l->next) { tsk = l->data; if (!tsk->area.on_screen) continue; - tsk->area.posy = y; set_task_redraw(tsk); // always redraw task, because the background could have changed (taskbar_active_id) tsk->area.height = pixel_height; - long value[] = { panel->posx, panel->posy+y, panel->area.width, pixel_height }; - XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4); +// TODO : move later (when posy is known) +// long value[] = { panel->posx, panel->posy+y, panel->area.width, pixel_height }; +// XChangeProperty (server.dsp, tsk->win, server.atom._NET_WM_ICON_GEOMETRY, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)value, 4); if (modulo_height) { tsk->area.height++; modulo_height--; } - - y += tsk->area.height + panel->g_taskbar.area.paddingx; } } return 0; } +
M src/tint.csrc/tint.c

@@ -186,9 +186,7 @@ if (panel->area.width > server.monitor[0].width)

panel->area.width = server.monitor[0].width; panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth); - size_by_content(&panel->area); - size_by_layout(&panel->area); - refresh(&panel->area); + rendering(panel); Imlib_Image img = NULL; imlib_context_set_drawable(panel->temp_pmap);

@@ -777,9 +775,7 @@ }

else { 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); - size_by_content(&panel->area); - size_by_layout(&panel->area); - refresh(&panel->area); + rendering(panel); XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0); } }
M src/util/area.csrc/util/area.c

@@ -77,6 +77,16 @@ * size_by_layout peut-il modifier redraw ?

* ************************************************************/ +void rendering(void *obj) +{ + Panel *panel = (Panel*)obj; + + size_by_content(&panel->area); + size_by_layout(&panel->area, 0, 0); + + refresh(&panel->area); +} + void size_by_content (Area *a) {

@@ -94,16 +104,16 @@ a->resize = 0;

if (a->_resize) { if (a->_resize(a)) { - // 'size' changed then 'resize = 1' on the parent + // 'size' changed => 'resize = 1' on the parent and redraw object ((Area*)a->parent)->resize = 1; + a->redraw = 1; } - a->redraw = 1; } } } -void size_by_layout (Area *a) +void size_by_layout (Area *a, int pos, int level) { // don't resize hiden objects if (!a->on_screen) return;

@@ -125,8 +135,24 @@ }

} } - for (l = a->list; l ; l = l->next) - size_by_layout(l->data); + // update position of childs + pos += a->paddingxlr + a->bg->border.width; + int i=0; + for (l = a->list; l ; l = l->next) { + Area *child = ((Area*)l->data); + i++; + + if (pos != child->posx) { + // pos changed => redraw + child->posx = pos; + child->redraw = 1; + } + //printf("level %d, object %d, pos %d\n", level, i, pos); + + size_by_layout(child, pos, level+1); + + pos += child->width + a->paddingx; + } }
M src/util/area.hsrc/util/area.h

@@ -89,9 +89,9 @@ const char* (*_get_tooltip_text)(void *obj);

} Area; - +void rendering(void *panel); void size_by_content (Area *a); -void size_by_layout (Area *a); +void size_by_layout (Area *a, int pos, int level); // draw background and foreground void refresh (Area *a);