cleanup code
git-svn-id: http://tint2.googlecode.com/svn/trunk@439 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
4d5fe440c8
commit
885377a234
3 changed files with 17 additions and 46 deletions
58
src/panel.c
58
src/panel.c
|
@ -97,9 +97,10 @@ void default_panel()
|
||||||
panel_layer = BOTTOM_LAYER; // default is bottom layer
|
panel_layer = BOTTOM_LAYER; // default is bottom layer
|
||||||
wm_menu = 0;
|
wm_menu = 0;
|
||||||
max_tick_urgent = 7;
|
max_tick_urgent = 7;
|
||||||
memset(&panel_config, 0, sizeof(Panel));
|
|
||||||
backgrounds = g_array_new(0, 0, sizeof(Background));
|
backgrounds = g_array_new(0, 0, sizeof(Background));
|
||||||
|
|
||||||
|
memset(&panel_config, 0, sizeof(Panel));
|
||||||
|
|
||||||
// append full transparency background
|
// append full transparency background
|
||||||
Background transparent_bg;
|
Background transparent_bg;
|
||||||
memset(&transparent_bg, 0, sizeof(Background));
|
memset(&transparent_bg, 0, sizeof(Background));
|
||||||
|
@ -130,8 +131,8 @@ void cleanup_panel()
|
||||||
|
|
||||||
void init_panel()
|
void init_panel()
|
||||||
{
|
{
|
||||||
int i, old_nb_panel;
|
int i;
|
||||||
Panel *new_panel, *p;
|
Panel *p;
|
||||||
|
|
||||||
if (panel_config.monitor > (server.nb_monitor-1)) {
|
if (panel_config.monitor > (server.nb_monitor-1)) {
|
||||||
// server.nb_monitor minimum value is 1 (see get_monitors())
|
// server.nb_monitor minimum value is 1 (see get_monitors())
|
||||||
|
@ -146,46 +147,20 @@ void init_panel()
|
||||||
init_battery();
|
init_battery();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cleanup_taskbar();
|
// number of panels (one monitor or 'all' monitors)
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
|
||||||
autohide_show(&panel1[i]);
|
|
||||||
free_area(&panel1[i].area);
|
|
||||||
if (panel1[i].temp_pmap) {
|
|
||||||
XFreePixmap(server.dsp, panel1[i].temp_pmap);
|
|
||||||
panel1[i].temp_pmap = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// number of panels
|
|
||||||
old_nb_panel = nb_panel;
|
|
||||||
if (panel_config.monitor >= 0)
|
if (panel_config.monitor >= 0)
|
||||||
nb_panel = 1;
|
nb_panel = 1;
|
||||||
else
|
else
|
||||||
nb_panel = server.nb_monitor;
|
nb_panel = server.nb_monitor;
|
||||||
|
|
||||||
// freed old panels
|
panel1 = malloc(nb_panel * sizeof(Panel));
|
||||||
for (i=nb_panel ; i < old_nb_panel ; i++) {
|
|
||||||
if (panel1[i].main_win) {
|
|
||||||
XDestroyWindow(server.dsp, panel1[i].main_win);
|
|
||||||
panel1[i].main_win = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// alloc & init new panel
|
|
||||||
Window old_win;
|
|
||||||
if (nb_panel != old_nb_panel)
|
|
||||||
new_panel = realloc(panel1, nb_panel * sizeof(Panel));
|
|
||||||
else
|
|
||||||
new_panel = panel1;
|
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
old_win = new_panel[i].main_win;
|
memcpy(&panel1[i], &panel_config, sizeof(Panel));
|
||||||
memcpy(&new_panel[i], &panel_config, sizeof(Panel));
|
|
||||||
new_panel[i].main_win = old_win;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n", server.nb_monitor, nb_panel, server.nb_desktop);
|
fprintf(stderr, "tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n", server.nb_monitor, nb_panel, server.nb_desktop);
|
||||||
for (i=0 ; i < nb_panel ; i++) {
|
for (i=0 ; i < nb_panel ; i++) {
|
||||||
p = &new_panel[i];
|
p = &panel1[i];
|
||||||
|
|
||||||
if (panel_config.monitor < 0)
|
if (panel_config.monitor < 0)
|
||||||
p->monitor = i;
|
p->monitor = i;
|
||||||
|
@ -216,16 +191,10 @@ void init_panel()
|
||||||
refresh_systray = 1;
|
refresh_systray = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= old_nb_panel) {
|
// catch some events
|
||||||
// new panel : catch some events
|
XSetWindowAttributes att = { .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
|
||||||
XSetWindowAttributes att = { .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
|
unsigned long mask = CWEventMask|CWColormap|CWBackPixel|CWBorderPixel;
|
||||||
unsigned long mask = CWEventMask|CWColormap|CWBackPixel|CWBorderPixel;
|
p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, server.visual, mask, &att);
|
||||||
p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, server.visual, mask, &att);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// old panel
|
|
||||||
XMoveResizeWindow(server.dsp, p->main_win, p->posx, p->posy, p->area.width, p->area.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask|ButtonMotionMask;
|
long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask|ButtonMotionMask;
|
||||||
if (g_tooltip.enabled)
|
if (g_tooltip.enabled)
|
||||||
|
@ -241,7 +210,7 @@ void init_panel()
|
||||||
//printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
|
//printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
|
||||||
set_panel_properties(p);
|
set_panel_properties(p);
|
||||||
set_panel_background(p);
|
set_panel_background(p);
|
||||||
if (i >= old_nb_panel && snapshot_path == 0) {
|
if (snapshot_path == 0) {
|
||||||
// if we are not in 'snapshot' mode then map new panel
|
// if we are not in 'snapshot' mode then map new panel
|
||||||
XMapWindow (server.dsp, p->main_win);
|
XMapWindow (server.dsp, p->main_win);
|
||||||
}
|
}
|
||||||
|
@ -250,7 +219,6 @@ void init_panel()
|
||||||
add_timeout(panel_autohide_hide_timeout, 0, autohide_hide, p);
|
add_timeout(panel_autohide_hide_timeout, 0, autohide_hide, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
panel1 = new_panel;
|
|
||||||
panel_refresh = 1;
|
panel_refresh = 1;
|
||||||
init_taskbar();
|
init_taskbar();
|
||||||
visible_object();
|
visible_object();
|
||||||
|
|
|
@ -66,6 +66,7 @@ void default_systray()
|
||||||
|
|
||||||
void cleanup_systray()
|
void cleanup_systray()
|
||||||
{
|
{
|
||||||
|
stop_net();
|
||||||
systray_enabled = 0;
|
systray_enabled = 0;
|
||||||
systray_max_icon_size = 0;
|
systray_max_icon_size = 0;
|
||||||
systray.area.on_screen = 0;
|
systray.area.on_screen = 0;
|
||||||
|
@ -372,6 +373,7 @@ gboolean add_icon(Window id)
|
||||||
if ( XGetWindowAttributes(server.dsp, id, &attr) == False ) return FALSE;
|
if ( XGetWindowAttributes(server.dsp, id, &attr) == False ) return FALSE;
|
||||||
unsigned long mask = 0;
|
unsigned long mask = 0;
|
||||||
XSetWindowAttributes set_attr;
|
XSetWindowAttributes set_attr;
|
||||||
|
//printf("icon with depth: %d, width %d, height %d\n", attr.depth, attr.width, attr.height);
|
||||||
printf("icon with depth: %d\n", attr.depth);
|
printf("icon with depth: %d\n", attr.depth);
|
||||||
if (attr.depth != server.depth || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
if (attr.depth != server.depth || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
|
||||||
set_attr.colormap = attr.colormap;
|
set_attr.colormap = attr.colormap;
|
||||||
|
@ -575,6 +577,8 @@ void systray_render_icon_now(void* t)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
imlib_context_set_image(image);
|
imlib_context_set_image(image);
|
||||||
|
//if (traywin->depth == 24)
|
||||||
|
//imlib_save_image("/home/thil77/test.jpg");
|
||||||
imlib_image_set_has_alpha(1);
|
imlib_image_set_has_alpha(1);
|
||||||
DATA32* data = imlib_image_get_data();
|
DATA32* data = imlib_image_get_data();
|
||||||
if (traywin->depth == 24) {
|
if (traywin->depth == 24) {
|
||||||
|
|
|
@ -151,7 +151,6 @@ void cleanup()
|
||||||
{
|
{
|
||||||
cleanup_timeout();
|
cleanup_timeout();
|
||||||
cleanup_systray();
|
cleanup_systray();
|
||||||
stop_net();
|
|
||||||
cleanup_panel();
|
cleanup_panel();
|
||||||
cleanup_tooltip();
|
cleanup_tooltip();
|
||||||
cleanup_clock();
|
cleanup_clock();
|
||||||
|
|
Loading…
Reference in a new issue