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);
if (directory)
g_dir_close(directory);
if (!battery_dir) {
- cleanup_battery();
fprintf(stderr, "ERROR: battery applet can't found power_supply\n");
return;
}
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);
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();
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);
extern int clock_enabled;
-// default values
+// default global data
void default_clock();
+
// freed memory
void cleanup_clock();
// --------------------------------------------------
// 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;
}
-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;
}
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;
}
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 ();
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;
// 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;
}
-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;
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);
void cleanup_systray()
{
+printf("*** cleanup_systray()\n");
systray_enabled = 0;
systray_max_icon_size = 0;
systray.area.on_screen = 0;
extern int systray_enabled;
extern int systray_max_icon_size;
-// default values
+// default global data
void default_systray();
+
// freed memory
void cleanup_systray();
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];
} Global_taskbar;
-// default values
+// default global data
void default_taskbar();
+
// freed memory
void cleanup_taskbar();
int i;
// set global data
+ default_config();
default_timeout();
default_systray();
memset(&server, 0, sizeof(Server_global));
default_clock();
default_taskbar();
default_tooltip();
- default_config();
+ default_panel();
// read options
for (i = 1; i < argc; ++i) {
}
}
// Set signal handler
+ signal_pending = 0;
struct sigaction sa = { .sa_handler = signal_handler };
sigaction(SIGUSR1, &sa, 0);
sigaction(SIGINT, &sa, 0);
void cleanup()
{
-printf("*** cleanup()\n");
cleanup_timeout();
cleanup_systray();
stop_net();
imlib_context_set_image(default_icon);
imlib_free_image();
}
+ imlib_context_disconnect_display();
cleanup_server();
if (server.dsp) XCloseDisplay(server.dsp);
}
imlib_save_image(path);
imlib_free_image();
- XFreePixmap(server.dsp, panel->temp_pmap);
}
{
// 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;
}
GSList *it;
struct timeval* timeout;
+start:
init (argc, argv);
- init_config();
init_X11();
i = 0;
}
init_panel();
- cleanup_config();
if (snapshot_path) {
get_snapshot(snapshot_path);
cleanup();
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;
+ }
}
}
}
void cleanup_tooltip()
{
+printf("*** cleanup_tooltip()\n");
stop_tooltip_timeout();
tooltip_hide(0);
tooltip_copy_text(0);
extern Tooltip g_tooltip;
-// default values
+// default global data
void default_tooltip();
+
// freed memory
void cleanup_tooltip();
void cleanup_timeout()
{
+printf("*** cleanup_timeout()\n");
while (timeout_list) {
timeout* t = timeout_list->data;
if (t->multi_timeout)
* integral multiple of the other.
**/
-/** default values **/
+/** default global data **/
void default_timeout();
+
/** freed memory : stops all timeouts **/
void cleanup_timeout();