]> Dogcows Code - chaz/tint2/commitdiff
cleanup duplicate code and fixed ALLDESKTOP task
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 26 Sep 2010 17:07:33 +0000 (17:07 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 26 Sep 2010 17:07:33 +0000 (17:07 +0000)
src/panel.c
src/taskbar/taskbar.c
src/util/area.c
src/util/area.h

index c388c4459c24d539d33205601eeb51431c93f058..f5eaf9a16277bf299ba98dab0e05e2120544defc 100644 (file)
@@ -304,7 +304,7 @@ void init_panel_size_and_position(Panel *panel)
 
 int resize_panel(void *obj)
 {      
-       int ret = resize_by_layout(obj);
+       resize_by_layout(obj, 0);
        
        //printf("resize_panel\n");
        if (panel_mode != MULTI_DESKTOP) {
@@ -319,7 +319,7 @@ int resize_panel(void *obj)
                        panel->taskbar[i].area.resize = 1;
                }
        }
-       return ret;
+       return 0;
 }
 
 
index 60a74060bd5d59682dada024e499cd9e61dbc2c2..6605b5befcaf93dadeb45799489f0faad4eb6173 100644 (file)
@@ -261,95 +261,27 @@ void task_refresh_tasklist ()
 
 int resize_taskbar(void *obj)
 {
-       //int ret = resize_by_layout(obj);
-       // on_changed
-       // taskbar->text_width = pixel_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx;
-       //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;
-       //return ret;
-       
        Taskbar *taskbar = (Taskbar*)obj;
        Panel *panel = (Panel*)taskbar->area.panel;
+       int text_width;
        Task *tsk;
-       GSList *l;
-       int  task_count, border_width;
 
        //printf("resize_taskbar %d %d\n", taskbar->area.posx, taskbar->area.posy);
-//     taskbar->area.redraw = 1;
-       border_width = taskbar->area.bg->border.width;
-
        if (panel_horizontal) {
-               int  pixel_width, modulo_width=0;
-               int  taskbar_width, old_width;
-
-               // 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 * border_width) - (2 * panel->g_taskbar.area.paddingxlr);
-                       if (task_count>1) taskbar_width -= ((task_count-1) * panel->g_taskbar.area.paddingx);
-
-                       pixel_width = taskbar_width / task_count;
-                       if (pixel_width > panel->g_task.maximum_width)
-                               pixel_width = panel->g_task.maximum_width;
-                       else
-                               modulo_width = taskbar_width % task_count;
-               }
-
-               taskbar->task_width = pixel_width;
-               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
-               for (l = taskbar->area.list; l ; l = l->next) {
-                       tsk = l->data;
-                       if (!tsk->area.on_screen) continue;
-                       old_width = tsk->area.width;
-                       tsk->area.width = pixel_width;
-                       if (modulo_width) {
-                               tsk->area.width++;
-                               modulo_width--;
-                       }
-                       if (tsk->area.width != old_width)
-                               tsk->area.on_changed = 1;
+               resize_by_layout(obj, panel->g_task.maximum_width);
+               
+               text_width = panel->g_task.maximum_width;
+               if (taskbar->area.list != NULL) {
+                       tsk = taskbar->area.list->data;
+                       text_width = tsk->area.width;
                }
+               taskbar->text_width = text_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingx;
        }
        else {
-               int  pixel_height, modulo_height=0;
-               int  taskbar_height, old_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 * border_width) - (2 * panel->g_taskbar.area.paddingxlr);
-                       if (task_count>1) taskbar_height -= ((task_count-1) * panel->g_taskbar.area.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;
-               }
-
-               taskbar->task_width = pixel_height;
-               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
-               for (l = taskbar->area.list; l ; l = l->next) {
-                       tsk = l->data;
-                       if (!tsk->area.on_screen) continue;
-                       old_height = tsk->area.height;
-                       tsk->area.height = pixel_height;
-                       if (modulo_height) {
-                               tsk->area.height++;
-                               modulo_height--;
-                       }
-                       if (tsk->area.height != old_height)
-                               tsk->area.on_changed = 1;
-               }
+               resize_by_layout(obj, panel->g_task.maximum_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;
        }
-       
        return 0;
 }
 
index f98e1613e06088954fdbbd52e1618d80c759366a..9b70b1210f54d44c8e43fe3d739ce4b5f91707ee 100644 (file)
@@ -221,7 +221,7 @@ void refresh (Area *a)
 }
 
 
-int resize_by_layout(void *obj)
+int resize_by_layout(void *obj, int maximum_size)
 {
        Area *child, *a = (Area*)obj;
        int size, nb_by_content=0, nb_by_layout=0;
@@ -247,6 +247,10 @@ int resize_by_layout(void *obj)
                if (nb_by_layout) {
                        width = size / nb_by_layout;
                        modulo = size % nb_by_layout;
+                       if (width > maximum_size && maximum_size != 0) {
+                               width = maximum_size;
+                               modulo = 0;
+                       }
                }
 
                // resize SIZE_BY_LAYOUT objects
@@ -284,6 +288,10 @@ int resize_by_layout(void *obj)
                if (nb_by_layout) {
                        height = size / nb_by_layout;
                        modulo = size % nb_by_layout;
+                       if (height > maximum_size && maximum_size != 0) {
+                               height = maximum_size;
+                               modulo = 0;
+                       }
                }
 
                // resize SIZE_BY_LAYOUT objects
index 37e1dc42132f00db8df59e97f54f5d79ae4003df..da437aa7118c6cea0da3e7c6aa9d47c4e2f303bf 100644 (file)
@@ -101,7 +101,7 @@ void size_by_layout (Area *a, int pos, int level);
 void refresh (Area *a);
  
 // generic resize for SIZE_BY_LAYOUT objects
-int resize_by_layout(void *obj);
+int resize_by_layout(void *obj, int maximum_size);
 
 // set 'redraw' on an area and childs
 void set_redraw (Area *a);
This page took 0.0283 seconds and 4 git commands to generate.