all repos — tint2 @ 7ee42e8ca143b02f5545e2b7ba74dda1a8905450

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

SIGUSR1 does now a full restat of tint2

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

7ee42e8ca143b02f5545e2b7ba74dda1a8905450

parent

c298a39d00db8856133cee0da18b1db55ee5ac67

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

@@ -94,6 +94,7 @@ }

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 @@ }

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 @@ fp3 = fopen(path_current_now, "r");

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);
M src/battery/battery.hsrc/battery/battery.h

@@ -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();
M src/clock/clock.csrc/clock/clock.c

@@ -71,6 +71,7 @@ }

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);
M src/clock/clock.hsrc/clock/clock.h

@@ -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();
M src/config.csrc/config.c

@@ -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;

@@ -74,43 +72,6 @@ void cleanup_config()

{ if (config_path) g_free(config_path); if (snapshot_path) g_free(snapshot_path); -} - - -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); }

@@ -705,9 +666,6 @@ }

} 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; }
M src/config.hsrc/config.h

@@ -12,12 +12,12 @@

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 ();
M src/panel.csrc/panel.c

@@ -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,17 +66,66 @@

// 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() {

@@ -281,54 +330,6 @@ panel->hidden_height = panel->area.height;

} } // printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, panel->area.height); -} - - -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; - } }
M src/panel.hsrc/panel.h

@@ -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);
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -67,6 +67,7 @@ }

void cleanup_systray() { +printf("*** cleanup_systray()\n"); systray_enabled = 0; systray_max_icon_size = 0; systray.area.on_screen = 0;
M src/systray/systraybar.hsrc/systray/systraybar.h

@@ -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();
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -184,6 +184,7 @@ Panel *panel;

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];
M src/taskbar/taskbar.hsrc/taskbar/taskbar.h

@@ -34,8 +34,9 @@ int use_active;

} Global_taskbar; -// default values +// default global data void default_taskbar(); + // freed memory void cleanup_taskbar();
M src/tint.csrc/tint.c

@@ -55,6 +55,7 @@ {

int i; // set global data + default_config(); default_timeout(); default_systray(); memset(&server, 0, sizeof(Server_global));

@@ -62,7 +63,7 @@ default_battery();

default_clock(); default_taskbar(); default_tooltip(); - default_config(); + default_panel(); // read options for (i = 1; i < argc; ++i) {

@@ -86,6 +87,7 @@ snapshot_path = strdup(argv[i]);

} } // 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 cleanup() { -printf("*** cleanup()\n"); cleanup_timeout(); cleanup_systray(); stop_net();

@@ -163,6 +164,7 @@ if (default_icon) {

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 @@ imlib_image_flip_diagonal();

} 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 @@ Panel *panel;

GSList *it; struct timeval* timeout; +start: init (argc, argv); - init_config(); init_X11(); i = 0;

@@ -720,7 +717,6 @@ exit(1);

} init_panel(); - cleanup_config(); if (snapshot_path) { get_snapshot(snapshot_path); cleanup();

@@ -899,19 +895,18 @@ }

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; + } } } }
M src/tooltip/tooltip.csrc/tooltip/tooltip.c

@@ -50,6 +50,7 @@ }

void cleanup_tooltip() { +printf("*** cleanup_tooltip()\n"); stop_tooltip_timeout(); tooltip_hide(0); tooltip_copy_text(0);
M src/tooltip/tooltip.hsrc/tooltip/tooltip.h

@@ -43,8 +43,9 @@

extern Tooltip g_tooltip; -// default values +// default global data void default_tooltip(); + // freed memory void cleanup_tooltip();
M src/util/timer.csrc/util/timer.c

@@ -55,6 +55,7 @@ }

void cleanup_timeout() { +printf("*** cleanup_timeout()\n"); while (timeout_list) { timeout* t = timeout_list->data; if (t->multi_timeout)
M src/util/timer.hsrc/util/timer.h

@@ -36,8 +36,9 @@ * Periodic timeouts are aligned to each other whenever possible, i.e. one interval_msec is an

* integral multiple of the other. **/ -/** default values **/ +/** default global data **/ void default_timeout(); + /** freed memory : stops all timeouts **/ void cleanup_timeout();