]> Dogcows Code - chaz/tint2/commitdiff
SIGUSR1 does now a full restat of tint2
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 18 Apr 2010 14:28:45 +0000 (14:28 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 18 Apr 2010 14:28:45 +0000 (14:28 +0000)
17 files changed:
src/battery/battery.c
src/battery/battery.h
src/clock/clock.c
src/clock/clock.h
src/config.c
src/config.h
src/panel.c
src/panel.h
src/systray/systraybar.c
src/systray/systraybar.h
src/taskbar/taskbar.c
src/taskbar/taskbar.h
src/tint.c
src/tooltip/tooltip.c
src/tooltip/tooltip.h
src/util/timer.c
src/util/timer.h

index 82aabab322edd9db41d9945a19c119e15537db13..ff8e0a6d99a96b6294b9c0e8bfa6faf446f86473 100644 (file)
@@ -94,6 +94,7 @@ void default_battery()
 
 void cleanup_battery()
 {
+       printf("*** cleanup_battery()\n");
        if (bat1_font_desc) pango_font_description_free(bat1_font_desc);
        if (bat2_font_desc) pango_font_description_free(bat2_font_desc);
        if (path_energy_now) g_free(path_energy_now);
@@ -133,7 +134,6 @@ void init_battery()
        if (directory)
                g_dir_close(directory);
        if (!battery_dir) {
-               cleanup_battery();
                fprintf(stderr, "ERROR: battery applet can't found power_supply\n");
                return;
        }
@@ -166,6 +166,7 @@ void init_battery()
                fp4 = fopen(path_status, "r");
                if (fp1 == NULL || fp2 == NULL || fp3 == NULL || fp4 == NULL) {
                        cleanup_battery();
+                       default_battery();
                        fprintf(stderr, "ERROR: battery applet can't open energy_now\n");
                }
                fclose(fp1);
index 65a8a1eb17702231b42f8d0e2dc449733b4f2c45..fa46aeef67b4bed4da1d54102ec3f720cf0a7646 100644 (file)
@@ -57,8 +57,9 @@ extern int8_t battery_low_status;
 extern char *battery_low_cmd;
 extern char *path_energy_now, *path_energy_full, *path_current_now, *path_status;
 
-// default values
+// default global data
 void default_battery();
+
 // freed memory
 void cleanup_battery();
 
index 273fb818e17991089c391a52a85d1b9dc5ea9924..c7ac910468c4242b0e7f561edae711c3e676bab7 100644 (file)
@@ -71,6 +71,7 @@ void default_clock()
 
 void cleanup_clock()
 {
+printf("*** cleanup_clock()\n");
        if (time1_font_desc) pango_font_description_free(time1_font_desc);
        if (time2_font_desc) pango_font_description_free(time2_font_desc);
        if (time1_format) g_free(time1_format);
index 4db15c31614185518bb6acde84401eee4fc4a268..fa8c7969af8df7145618ec38a23a5de3ab88d5c2 100644 (file)
@@ -37,8 +37,9 @@ extern char *clock_rclick_command;
 extern int clock_enabled;
 
 
-// default values
+// default global data
 void default_clock();
+
 // freed memory
 void cleanup_clock();
 
index cc8cb5587ee50c50efe202954c0d72c3f840f08d..4ea8d84376001b0385c1796a3469489182313cd5 100644 (file)
@@ -57,9 +57,7 @@ char *snapshot_path;
 
 // --------------------------------------------------
 // backward compatibility
-static int old_task_icon_size;
-// detect if it's an old config file
-// ==1
+// detect if it's an old config file (==1)
 static int old_config_file;
 
 
@@ -77,43 +75,6 @@ void cleanup_config()
 }
 
 
-void init_config()
-{
-       if (backgrounds)
-               g_array_free(backgrounds, 1);
-       backgrounds = g_array_new(0, 0, sizeof(Background));
-
-       // append full transparency background
-       Background transparent_bg;
-       memset(&transparent_bg, 0, sizeof(Background));
-       g_array_append_val(backgrounds, transparent_bg);
-printf("*** init_config()\n");
-
-       // tint2 could reload config, so we cleanup objects
-       cleanup_systray();
-#ifdef ENABLE_BATTERY
-       cleanup_battery();
-#endif
-       cleanup_clock();
-       cleanup_tooltip();
-
-       // panel's default value
-       if (panel_config.g_task.font_desc) {
-               pango_font_description_free(panel_config.g_task.font_desc);
-       }
-       memset(&panel_config, 0, sizeof(Panel));
-
-       // window manager's menu default value == false
-       wm_menu = 0;
-       max_tick_urgent = 7;
-
-       // flush pango cache if possible
-       //pango_xft_shutdown_display(server.dsp, server.screen);
-       //PangoFontMap *font_map = pango_xft_get_font_map(server.dsp, server.screen);
-       //pango_fc_font_map_shutdown(font_map);
-}
-
-
 void extract_values (const char *value, char **value1, char **value2, char **value3)
 {
        char *b=0, *c=0;
@@ -705,9 +666,6 @@ int config_read_file (const char *path)
        }
        fclose (fp);
 
-       if (old_task_icon_size) {
-               panel_config.g_task.area.paddingy = ((int)panel_config.area.height - (2 * panel_config.area.paddingy) - old_task_icon_size) / 2;
-       }
        return 1;
 }
 
index 68bf8a0f8d73cf3eb0f12f92ee41f99c8ce3518d..0999fb69fc67b98d885d939e5f94972a0b9c252a 100644 (file)
 extern char *config_path;
 extern char *snapshot_path;
 
-// default values
+// default global data
 void default_config();
+
 // freed memory
 void cleanup_config();
 
-void init_config();
 int  config_read_file (const char *path);
 int  config_read ();
 
index 66fc90e6711676642b778f983d97ffd69c9748ab..db66fc33fd21967c424d27e2dd99d5f387e9a126 100644 (file)
@@ -46,18 +46,18 @@ int mouse_tilt_right;
 
 int panel_mode;
 int wm_menu;
-int panel_dock=0;  // default not in the dock
-int panel_layer=BOTTOM_LAYER;  // default is bottom layer
+int panel_dock;
+int panel_layer;
 int panel_position;
 int panel_horizontal;
 int panel_refresh;
-int task_dragged=0;
+int task_dragged;
 
-int panel_autohide = 0;
-int panel_autohide_show_timeout = 0;
-int panel_autohide_hide_timeout = 0;
-int panel_autohide_height = 5;  // for vertical panels this is of course the width
-int panel_strut_policy = STRUT_MINIMUM;
+int panel_autohide;
+int panel_autohide_show_timeout;
+int panel_autohide_hide_timeout;
+int panel_autohide_height;
+int panel_strut_policy;
 
 Task *task_active;
 Task *task_drag;
@@ -66,18 +66,67 @@ int  max_tick_urgent;
 // panel's initial config
 Panel panel_config;
 // panels (one panel per monitor)
-Panel *panel1 = 0;
-int  nb_panel = 0;
+Panel *panel1;
+int  nb_panel;
 
-GArray* backgrounds = 0;
+GArray* backgrounds;
 
-Imlib_Image default_icon = NULL;
+Imlib_Image default_icon;
 
 
 void autohide_hide(void* p);
 void autohide_show(void* p);
 
 
+void default_panel()
+{
+       panel1 = 0;
+       nb_panel = 0;
+       default_icon = NULL;
+       task_active = 0;
+       task_drag = 0;
+       task_dragged = 0;
+       panel_autohide = 0;
+       panel_autohide_show_timeout = 0;
+       panel_autohide_hide_timeout = 0;
+       panel_autohide_height;  // for vertical panels this is of course the width
+       panel_strut_policy = STRUT_MINIMUM;
+       panel_dock = 0;  // default not in the dock
+       panel_layer = BOTTOM_LAYER;  // default is bottom layer
+       wm_menu = 0;
+       max_tick_urgent = 7;
+       memset(&panel_config, 0, sizeof(Panel));
+       backgrounds = g_array_new(0, 0, sizeof(Background));
+
+       // append full transparency background
+       Background transparent_bg;
+       memset(&transparent_bg, 0, sizeof(Background));
+       g_array_append_val(backgrounds, transparent_bg);
+}
+
+void cleanup_panel()
+{
+       if (!panel1) return;
+
+printf("*** cleanup_panel()\n");
+       cleanup_taskbar();
+
+       int i;
+       Panel *p;
+       for (i=0 ; i < nb_panel ; i++) {
+               p = &panel1[i];
+
+               free_area(&p->area);
+               if (p->temp_pmap) XFreePixmap(server.dsp, p->temp_pmap);
+               if (p->hidden_pixmap) XFreePixmap(server.dsp, p->hidden_pixmap);
+               if (p->main_win) XDestroyWindow(server.dsp, p->main_win);
+       }
+
+       if (panel1) free(panel1);
+       if (backgrounds) g_array_free(backgrounds, 1);
+       if (panel_config.g_task.font_desc) pango_font_description_free(panel_config.g_task.font_desc);
+}
+
 void init_panel()
 {
        int i, old_nb_panel;
@@ -284,54 +333,6 @@ void init_panel_size_and_position(Panel *panel)
 }
 
 
-void cleanup_panel()
-{
-       if (!panel1) return;
-
-printf("*** cleanup_panel()\n");
-       task_active = 0;
-       task_drag = 0;
-
-       cleanup_taskbar();
-
-       int i;
-       Panel *p;
-       for (i=0 ; i < nb_panel ; i++) {
-               p = &panel1[i];
-
-               free_area(&p->area);
-
-               if (p->temp_pmap) {
-                       XFreePixmap(server.dsp, p->temp_pmap);
-                       p->temp_pmap = 0;
-               }
-               if (p->hidden_pixmap)
-                       XFreePixmap(server.dsp, p->hidden_pixmap);
-               p->hidden_pixmap = 0;
-               if (p->main_win) {
-                       XDestroyWindow(server.dsp, p->main_win);
-                       p->main_win = 0;
-               }
-       }
-
-       if (panel1) {
-               free(panel1);
-               panel1 = 0;
-               nb_panel = 0;
-       }
-
-       if (panel_config.g_task.font_desc) {
-               pango_font_description_free(panel_config.g_task.font_desc);
-               panel_config.g_task.font_desc = 0;
-       }
-
-       if (backgrounds) {
-               g_array_free(backgrounds, 1);
-               backgrounds = 0;
-       }
-}
-
-
 void resize_panel(void *obj)
 {
        Panel *panel = (Panel*)obj;
index 9e38fe08082cfae5f712d6576a0019959739dcb0..257563a2528dca4963b055847beacf523bc9e0cd 100644 (file)
@@ -121,12 +121,18 @@ extern Panel panel_config;
 extern Panel *panel1;
 extern int  nb_panel;
 
+
+// default global data
+void default_panel();
+
+// freed memory
+void cleanup_panel();
+
 // realloc panels according to number of monitor
 // use panel_config as default value
 void init_panel();
 
 void init_panel_size_and_position(Panel *panel);
-void cleanup_panel();
 void resize_panel(void *obj);
 
 void set_panel_properties(Panel *p);
index 81eba8f8edac0920c59af99d463b5a6c57bba1f4..cc1412294ffa75737704b680d5c817ffb125cdf5 100644 (file)
@@ -67,6 +67,7 @@ printf("*** default_systray()\n");
 
 void cleanup_systray()
 {
+printf("*** cleanup_systray()\n");
        systray_enabled = 0;
        systray_max_icon_size = 0;
        systray.area.on_screen = 0;
index 631e59864c9ed80514194ba782fd1a2e0b1e8d5d..7b5e9fcac5caf66a03809cd216a61b449f77358e 100644 (file)
@@ -52,8 +52,9 @@ extern int refresh_systray;
 extern int systray_enabled;
 extern int systray_max_icon_size;
 
-// default values
+// default global data
 void default_systray();
+
 // freed memory
 void cleanup_systray();
 
index 34f49b0a52accebe6e2230d33376c04b930c4ea3..10e0d13b0d292f338ecae947e70de1564a75ed12 100644 (file)
@@ -184,6 +184,7 @@ void cleanup_taskbar()
        Taskbar *tskbar;
        int i, j;
 
+printf("*** cleanup_taskbar()\n");
        if (win_to_task_table) g_hash_table_foreach(win_to_task_table, taskbar_remove_task, 0);
        for (i=0 ; i < nb_panel ; i++) {
                panel = &panel1[i];
index a04060c857cb7fa0bcd144760a697a3dda3d0e9c..e2c55bb448cc9f1f071ecfa684e3245a190c4ad1 100644 (file)
@@ -34,8 +34,9 @@ typedef struct {
 } Global_taskbar;
 
 
-// default values
+// default global data
 void default_taskbar();
+
 // freed memory
 void cleanup_taskbar();
 
index 35141b06829593afece63cfed2a2b55b03c5960b..f88b57fd7f3cb7fb1e549d25fbca40f205ae45d2 100644 (file)
@@ -55,6 +55,7 @@ void init (int argc, char *argv[])
        int i;
 
        // set global data
+       default_config();
        default_timeout();
        default_systray();
        memset(&server, 0, sizeof(Server_global));
@@ -62,7 +63,7 @@ void init (int argc, char *argv[])
        default_clock();
        default_taskbar();
        default_tooltip();
-       default_config();
+       default_panel();
 
        // read options
        for (i = 1; i < argc; ++i) {
@@ -86,6 +87,7 @@ void init (int argc, char *argv[])
                }
        }
        // Set signal handler
+       signal_pending = 0;
        struct sigaction sa = { .sa_handler = signal_handler };
        sigaction(SIGUSR1, &sa, 0);
        sigaction(SIGINT, &sa, 0);
@@ -147,7 +149,6 @@ void init_X11()
 
 void cleanup()
 {
-printf("*** cleanup()\n");
        cleanup_timeout();
        cleanup_systray();
        stop_net();
@@ -163,6 +164,7 @@ printf("*** cleanup()\n");
                imlib_context_set_image(default_icon);
                imlib_free_image();
        }
+       imlib_context_disconnect_display();
 
        cleanup_server();
        if (server.dsp) XCloseDisplay(server.dsp);
@@ -191,7 +193,6 @@ void get_snapshot(const char *path)
        }
        imlib_save_image(path);
        imlib_free_image();
-       XFreePixmap(server.dsp, panel->temp_pmap);
 }
 
 
@@ -624,11 +625,7 @@ void event_configure_notify (Window win)
 {
        // change in root window (xrandr)
        if (win == server.root_win) {
-               get_monitors();
-               init_config();
-               config_read_file (config_path);
-               init_panel();
-               cleanup_config();
+               signal_pending = SIGUSR1;
                return;
        }
 
@@ -704,8 +701,8 @@ int main (int argc, char *argv[])
        GSList *it;
        struct timeval* timeout;
 
+start:
        init (argc, argv);
-       init_config();
        init_X11();
 
        i = 0;
@@ -720,7 +717,6 @@ int main (int argc, char *argv[])
        }
 
        init_panel();
-       cleanup_config();
        if (snapshot_path) {
                get_snapshot(snapshot_path);
                cleanup();
@@ -899,19 +895,18 @@ int main (int argc, char *argv[])
 
                callback_timeout_expired();
 
-               switch (signal_pending) {
-               case SIGUSR1: // reload config file
-                       signal_pending = 0;
-                       init_config();
-                       config_read_file (config_path);
-                       init_panel();
-                       cleanup_config();
-                       break;
-               case SIGINT:
-               case SIGTERM:
-               case SIGHUP:
-                       cleanup ();
-                       return 0;
+               if (signal_pending) {
+                       cleanup();
+                       if (signal_pending == SIGUSR1) {
+                               // restart tint2
+                               // SIGUSR1 used when : user's signal, composite manager stop/start or xrandr
+                               FD_CLR (x11_fd, &fdset);
+                               goto start;
+                       }
+                       else {
+                               // SIGINT, SIGTERM, SIGHUP
+                               return 0;
+                       }
                }
        }
 }
index a724473c397cf4b7cc5ecda5cb8a0c56f65110a9..1c195047facedaf5af0155d8aa5a64d2496b8ee2 100644 (file)
@@ -50,6 +50,7 @@ void default_tooltip()
 
 void cleanup_tooltip()
 {
+printf("*** cleanup_tooltip()\n");
        stop_tooltip_timeout();
        tooltip_hide(0);
        tooltip_copy_text(0);
index e4e54d37ee6838aa40a7178776835cb3c63e3be7..fbf71b5794e17139ebe86afa1651329558f86a9d 100644 (file)
@@ -43,8 +43,9 @@ typedef struct {
 extern Tooltip g_tooltip;
 
 
-// default values
+// default global data
 void default_tooltip();
+
 // freed memory
 void cleanup_tooltip();
 
index b4db7f48dfa0915eec9692bbece3937781d4d63f..1dd2f11c36cb844286c0ac04603f47e4d75fc2cd 100644 (file)
@@ -55,6 +55,7 @@ void default_timeout()
 
 void cleanup_timeout()
 {
+printf("*** cleanup_timeout()\n");
        while (timeout_list) {
                timeout* t = timeout_list->data;
                if (t->multi_timeout)
index 251b732f72d8e4f04c8de0dfa9ab5ba4abea332d..250e7e0bd33d16894dad86d347e3e8caff8c173d 100644 (file)
@@ -36,8 +36,9 @@ typedef struct _timeout timeout;
   * integral multiple of the other.
 **/
 
-/** default values **/
+/** default global data **/
 void default_timeout();
+
 /** freed memory : stops all timeouts **/
 void cleanup_timeout();
 
This page took 0.049848 seconds and 4 git commands to generate.