]> Dogcows Code - chaz/tint2/commitdiff
cleanup code
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Thu, 23 Sep 2010 18:09:30 +0000 (18:09 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Thu, 23 Sep 2010 18:09:30 +0000 (18:09 +0000)
src/battery/battery.c
src/config.c
src/panel.c
src/panel.h
src/taskbar/task.c
src/taskbar/taskbar.c
src/taskbar/taskbar.h
src/tint.c
src/util/area.c
src/util/area.h

index fd4d59b26be8612418840b840b90266a969a3bb6..9bb024e5c567f498694aecdae56e7946065a5932 100644 (file)
@@ -237,6 +237,8 @@ void init_battery_panel(void *p)
        battery->area._draw_foreground = draw_battery;
        battery->area.size_mode = SIZE_BY_CONTENT;
        battery->area._resize = resize_battery;
+       battery->area.on_screen = 1;
+       battery->area.resize = 1;
 }
 
 
index 37a30eff74d31dc2228d5e45356eaf44996d8568..04ec056173607730db02dafcf57b9b5becf27500 100644 (file)
@@ -451,13 +451,14 @@ void add_entry (char *key, char *value)
                int id = atoi (value);
                id = (id < backgrounds->len && id >= 0) ? id : 0;
                panel_config.g_taskbar.bg = &g_array_index(backgrounds, Background, id);
+               if (panel_config.g_taskbar.bg_active == 0)
+                       panel_config.g_taskbar.bg_active = panel_config.g_taskbar.bg;
                panel_config.g_taskbar.area.bg = panel_config.g_taskbar.bg;
        }
        else if (strcmp (key, "taskbar_active_background_id") == 0) {
                int id = atoi (value);
                id = (id < backgrounds->len && id >= 0) ? id : 0;
                panel_config.g_taskbar.bg_active = &g_array_index(backgrounds, Background, id);
-               panel_config.g_taskbar.use_active = 1;
        }
 
        /* Task */
index 797b96a2c11f8bcca73e7f99037660b001dce01a..6a98a26191aaf43ad2efc13daa1b5f3d4b8c019a 100644 (file)
@@ -219,9 +219,10 @@ void init_panel()
 
                if (panel_autohide)
                        add_timeout(panel_autohide_hide_timeout, 0, autohide_hide, p);
+               
+               visible_taskbar(p);
        }
 
-       visible_object();
        task_refresh_tasklist();
        active_task();
 }
@@ -301,29 +302,6 @@ void init_panel_size_and_position(Panel *panel)
 }
 
 
-void visible_object()
-{
-       Panel *panel;
-       int i, j;
-
-       for (i=0 ; i < nb_panel ; i++) {
-               panel = &panel1[i];
-
-               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 and not current desktop
-                               taskbar->area.on_screen = 0;
-                       }
-                       else {
-                               taskbar->area.on_screen = 1;
-                       }
-               }
-       }
-       panel_refresh = 1;
-}
-
 void update_strut(Panel* p)
 {
        if (panel_strut_policy == STRUT_NONE) {
index aedb1f2eba6bf5dec6b170534a1bc107e1002734..833666644ff2b98800b640bb7cb2f30395d5a95b 100644 (file)
@@ -138,7 +138,6 @@ void init_panel_size_and_position(Panel *panel);
 
 void set_panel_items_order(Panel *p);
 void set_panel_properties(Panel *p);
-void visible_object();
 
 // draw background panel
 void set_panel_background(Panel *p);
index 5f92233647cd9167c19ed7e23c2f512eb1b296b6..83e827f5247ef181e1df0e51e5c95186f0c8b823 100644 (file)
@@ -342,6 +342,7 @@ void draw_task (void *obj, cairo_t *c)
        Color *config_text;
        int width=0, height;
        Panel *panel = (Panel*)tsk->area.panel;
+       //printf("draw_task %d %d\n", tsk->area.posx, tsk->area.posy);
 
        if (panel->g_task.text) {
                /* Layout */
index aa65991ad5fe4483b7a903c6eb498af4c304f12a..6901fccabb134ceeef8f303ec4f45f1f239c32bb 100644 (file)
@@ -198,7 +198,7 @@ void init_taskbar_panel(void *p)
                tskbar = &panel->taskbar[j];
                memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
                tskbar->desktop = j;
-               if (j == server.desktop && panel->g_taskbar.use_active)
+               if (j == server.desktop)
                        tskbar->area.bg = panel->g_taskbar.bg_active;
        }
 }
@@ -266,9 +266,7 @@ int resize_taskbar(void *obj)
        GSList *l;
        int  task_count, border_width;
 
-       //printf("resize_taskbar : posx et width des taches\n");
-       taskbar->area.redraw = 1;
-
+//     taskbar->area.redraw = 1;
        border_width = taskbar->area.bg->border.width;
 
        if (panel_horizontal) {
@@ -297,7 +295,7 @@ int resize_taskbar(void *obj)
                for (l = taskbar->area.list; l ; l = l->next) {
                        tsk = l->data;
                        if (!tsk->area.on_screen) continue;
-                       set_task_redraw(tsk);  // always redraw task, because the background could have changed (taskbar_active_id)
+                       //set_task_redraw(tsk);  // always redraw task, because the background could have changed (taskbar_active_id)
                        tsk->area.width = pixel_width;
 // TODO : move later (when posx is known)
 //                     long value[] = { panel->posx+x, panel->posy, pixel_width, panel->area.height };
@@ -335,7 +333,7 @@ int resize_taskbar(void *obj)
                for (l = taskbar->area.list; l ; l = l->next) {
                        tsk = l->data;
                        if (!tsk->area.on_screen) continue;
-                       set_task_redraw(tsk);  // always redraw task, because the background could have changed (taskbar_active_id)
+                       //set_task_redraw(tsk);  // always redraw task, because the background could have changed (taskbar_active_id)
                        tsk->area.height = pixel_height;
 // TODO : move later (when posy is known)
 //                     long value[] = { panel->posx, panel->posy+y, panel->area.width, pixel_height };
@@ -347,6 +345,27 @@ int resize_taskbar(void *obj)
                        }
                }
        }
+       
        return 0;
 }
 
+
+void visible_taskbar(void *p)
+{
+       Panel *panel =(Panel*)p;
+       int j;
+
+       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 and not current desktop
+                       taskbar->area.on_screen = 0;
+               }
+               else {
+                       taskbar->area.on_screen = 1;
+               }
+       }
+       panel_refresh = 1;
+}
+
index f863684c12a002d7f0036efd0cc4d463f5a295f4..8407819114a996f94907636c2a0aff00bf5ade72 100644 (file)
@@ -34,7 +34,6 @@ typedef struct {
        Area area;
        Background* bg;
        Background* bg_active;
-       int use_active;
 } Global_taskbar;
 
 
@@ -54,6 +53,9 @@ void task_refresh_tasklist ();
 
 int  resize_taskbar(void *obj);
 
+// show/hide taskbar according to current desktop
+void visible_taskbar(void *p);
+
 
 #endif
 
index 80a7dd9488592bdef3fa91c376562e9a0af11f63..2f5edc6f0991cf429611982a31808646399dbca9 100644 (file)
@@ -494,9 +494,9 @@ void event_property_notify (XEvent *e)
                        for (i=0 ; i < nb_panel ; i++) {
                                init_taskbar_panel(&panel1[i]);
                                set_panel_items_order(&panel1[i]);
+                               visible_taskbar(&panel1[i]);
                                panel1[i].area.resize = 1;
                        }
-                       visible_object();
                        task_refresh_tasklist();
                        active_task();
                        panel_refresh = 1;
@@ -508,7 +508,7 @@ void event_property_notify (XEvent *e)
                        server.desktop = server_get_current_desktop ();
                        for (i=0 ; i < nb_panel ; i++) {
                                Panel *panel = &panel1[i];
-                               if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) {
+                               if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.bg != panel->g_taskbar.bg_active) {
                                        // redraw both taskbar
                                        if (server.nb_desktop > old_desktop) {
                                                // can happen if last desktop is deleted and we've been on the last desktop
@@ -542,9 +542,8 @@ void event_property_notify (XEvent *e)
                                                tskbar->area.resize = 1;
                                        }
                                }
-                       }
-                       if (panel_mode != MULTI_DESKTOP) {
-                               visible_object();
+                               if (panel_mode != MULTI_DESKTOP) 
+                                       visible_taskbar(panel);
                        }
                }
                // Window list
index 34a4d13211e60e8b918a2805417686f5d5fc3f5d..adec3c9ae55da5720aa28179e0be3f132788f9d8 100644 (file)
@@ -220,7 +220,6 @@ int resize_by_layout(void *obj)
        Area *child, *a = (Area*)obj;
        int size, nb_by_content=0, nb_by_layout=0;
 
-       printf("resize_by_layout\n");
        if (panel_horizontal) {         
                // detect free size for SIZE_BY_LAYOUT's Area
                size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
index 2f8d822671b3ef75b486d3fa1535d0b97ab355f5..7270419d9ee6b20bb63c6a3d2ab3d0351f4c221a 100644 (file)
@@ -82,7 +82,8 @@ typedef struct {
 
        // each object can overwrite following function
        void (*_draw_foreground)(void *obj, cairo_t *c);
-       // calculate size. return '1' if size changed, '0' otherwise.
+       // update area's content and update size (width/heith). 
+       // return '1' if size changed, '0' otherwise.
        int (*_resize)(void *obj);
        void (*_add_child)(void *obj);
        int (*_remove_child)(void *obj);
This page took 0.042632 seconds and 4 git commands to generate.