-// 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]);
- }
+ // change pos_x and width for all tasks
+ x = taskbar->area.posx + taskbar->area.pix.border.width + taskbar->area.paddingxlr;
+ for (l = taskbar->area.list; l ; l = l->next) {
+ tsk = l->data;
+ tsk->area.posx = x;
+ tsk->area.width = pixel_width;
+ tsk->area.redraw = 1;
+ if (modulo_width) {
+ tsk->area.width++;
+ modulo_width--;
+ }
+
+ x += tsk->area.width + panel->g_taskbar.paddingx;
+ }
+ }
+ else {
+ int pixel_height, modulo_height=0;
+ int y, taskbar_height;
+
+ // new task width for 'desktop'
+ task_count = g_slist_length(taskbar->area.list);
+ if (!task_count) pixel_height = panel->g_task.maximum_height;
+ else {
+ taskbar_height = taskbar->area.height - (2 * panel->g_taskbar.pix.border.width) - (2 * panel->g_taskbar.paddingxlr);
+ if (task_count>1) taskbar_height -= ((task_count-1) * panel->g_taskbar.paddingx);
+
+ pixel_height = taskbar_height / task_count;
+ if (pixel_height > panel->g_task.maximum_height)
+ pixel_height = panel->g_task.maximum_height;
+ else
+ modulo_height = taskbar_height % task_count;
+ }
+
+ if ((taskbar->task_width == pixel_height) && (taskbar->task_modulo == modulo_height)) {
+ }
+ else {
+ taskbar->task_width = pixel_height;
+ taskbar->task_modulo = modulo_height;
+ taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.paddingy) - panel->g_task.text_posx - panel->g_task.area.pix.border.width - panel->g_task.area.paddingx;
+ }
+
+ // change pos_y and height for all tasks
+ y = taskbar->area.posy + taskbar->area.pix.border.width + taskbar->area.paddingxlr;
+ for (l = taskbar->area.list; l ; l = l->next) {
+ tsk = l->data;
+ tsk->area.posy = y;
+ tsk->area.height = pixel_height;
+ tsk->area.redraw = 1;
+ if (modulo_height) {
+ tsk->area.height++;
+ modulo_height--;
+ }
+
+ y += tsk->area.height + panel->g_taskbar.paddingx;
+ }
+ }