panel_items : fixed segfault (panel without clock, change number desktop)

git-svn-id: http://tint2.googlecode.com/svn/trunk@550 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
thilor77 2010-09-18 18:06:29 +00:00
parent 500981b052
commit b98d2001cb
8 changed files with 216 additions and 183 deletions

View file

@ -157,7 +157,6 @@ void cleanup_launcher()
int resize_launcher(void *obj) int resize_launcher(void *obj)
{ {
Launcher *launcher = obj; Launcher *launcher = obj;
Panel *panel = launcher->area.panel;
GSList *l; GSList *l;
int count, icon_size; int count, icon_size;
int icons_per_column=1, icons_per_row=1, marging=0; int icons_per_column=1, icons_per_row=1, marging=0;

View file

@ -126,7 +126,7 @@ void cleanup_panel()
void init_panel() void init_panel()
{ {
int i, j; int i;
Panel *p; Panel *p;
if (panel_config.monitor > (server.nb_monitor-1)) { if (panel_config.monitor > (server.nb_monitor-1)) {
@ -142,6 +142,7 @@ void init_panel()
#ifdef ENABLE_BATTERY #ifdef ENABLE_BATTERY
init_battery(); init_battery();
#endif #endif
init_taskbar();
// number of panels (one monitor or 'all' monitors) // number of panels (one monitor or 'all' monitors)
if (panel_config.monitor >= 0) if (panel_config.monitor >= 0)
@ -172,38 +173,8 @@ void init_panel()
p->g_taskbar.area.panel = p; p->g_taskbar.area.panel = p;
p->g_task.area.panel = p; p->g_task.area.panel = p;
init_panel_size_and_position(p); init_panel_size_and_position(p);
// add childs occording to panel_items_order // add childs according to panel_items
int k; set_panel_items(p);
for (k=0 ; k < strlen(panel_items_order) ; k++) {
if (panel_items_order[k] == 'L') {
init_launcher_panel(p);
p->area.list = g_slist_append(p->area.list, &p->launcher);
}
if (panel_items_order[k] == 'T') {
p->nb_desktop = server.nb_desktop;
p->taskbar = calloc(p->nb_desktop, sizeof(Taskbar));
for (j=0 ; j < p->nb_desktop ; j++) {
p->area.list = g_slist_append(p->area.list, &p->taskbar[j]);
}
//printf("init taskbar\n");
}
#ifdef ENABLE_BATTERY
if (panel_items_order[k] == 'B') {
init_battery_panel(p);
p->area.list = g_slist_append(p->area.list, &p->battery);
}
#endif
if (panel_items_order[k] == 'S') {
// TODO : check systray is only on 1 panel
init_systray_panel(p);
p->area.list = g_slist_append(p->area.list, &systray);
refresh_systray = 1;
}
if (panel_items_order[k] == 'C') {
init_clock_panel(p);
p->area.list = g_slist_append(p->area.list, &p->clock);
}
}
// catch some events // 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 };
@ -234,7 +205,6 @@ void init_panel()
} }
panel_refresh = 1; panel_refresh = 1;
init_taskbar();
visible_object(); visible_object();
task_refresh_tasklist(); task_refresh_tasklist();
active_task(); active_task();
@ -483,6 +453,45 @@ void update_strut(Panel* p)
} }
void set_panel_items(Panel *p)
{
int k, j;
if (p->area.list) {
g_slist_free(p->area.list);
p->area.list = 0;
}
for (k=0 ; k < strlen(panel_items_order) ; k++) {
if (panel_items_order[k] == 'L') {
init_launcher_panel(p);
p->area.list = g_slist_append(p->area.list, &p->launcher);
}
if (panel_items_order[k] == 'T') {
init_taskbar_panel(p);
for (j=0 ; j < p->nb_desktop ; j++)
p->area.list = g_slist_append(p->area.list, &p->taskbar[j]);
}
#ifdef ENABLE_BATTERY
if (panel_items_order[k] == 'B') {
init_battery_panel(p);
p->area.list = g_slist_append(p->area.list, &p->battery);
}
#endif
if (panel_items_order[k] == 'S') {
// TODO : check systray is only on 1 panel
init_systray_panel(p);
refresh_systray = 1;
p->area.list = g_slist_append(p->area.list, &systray);
}
if (panel_items_order[k] == 'C') {
init_clock_panel(p);
p->area.list = g_slist_append(p->area.list, &p->clock);
}
}
}
void set_panel_properties(Panel *p) void set_panel_properties(Panel *p)
{ {
XStoreName (server.dsp, p->main_win, "tint2"); XStoreName (server.dsp, p->main_win, "tint2");

View file

@ -137,6 +137,7 @@ void init_panel();
void init_panel_size_and_position(Panel *panel); void init_panel_size_and_position(Panel *panel);
int resize_panel(void *obj); int resize_panel(void *obj);
void set_panel_items(Panel *p);
void set_panel_properties(Panel *p); void set_panel_properties(Panel *p);
void visible_object(); void visible_object();

View file

@ -90,10 +90,6 @@ void init_systray()
systray.alpha = 100; systray.alpha = 100;
systray.brightness = systray.saturation = 0; systray.brightness = systray.saturation = 0;
} }
systray.area.resize = 1;
systray.area.redraw = 1;
systray.area.on_screen = 1;
refresh_systray = 0;
} }
@ -111,6 +107,18 @@ void init_systray_panel(void *p)
} }
systray.area.parent = p; systray.area.parent = p;
systray.area.panel = p; systray.area.panel = p;
GSList *l;
int count = 0;
for (l = systray.list_icons; l ; l = l->next) {
if (!((TrayWindow*)l->data)->hide)
count++;
}
if (count == 0)
systray.area.on_screen = 0;
else
systray.area.on_screen = 1;
refresh_systray = 0;
} }
@ -195,26 +203,20 @@ int resize_systray(void *obj)
//printf("count %d\n", count); //printf("count %d\n", count);
if (panel_horizontal) { if (panel_horizontal) {
if (!count) systray.area.width = 0; int height = sysbar->area.height - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
else { // here icons_per_column always higher than 0
int height = sysbar->area.height - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy; icons_per_column = (height+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
// here icons_per_column always higher than 0 marging = height - (icons_per_column-1)*(icon_size+sysbar->area.paddingx) - icon_size;
icons_per_column = (height+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx); icons_per_row = count / icons_per_column + (count%icons_per_column != 0);
marging = height - (icons_per_column-1)*(icon_size+sysbar->area.paddingx) - icon_size; systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * systray.area.paddingx);
icons_per_row = count / icons_per_column + (count%icons_per_column != 0);
systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * systray.area.paddingx);
}
} }
else { else {
if (!count) systray.area.height = 0; int width = sysbar->area.width - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy;
else { // here icons_per_row always higher than 0
int width = sysbar->area.width - 2*sysbar->area.bg->border.width - 2*sysbar->area.paddingy; icons_per_row = (width+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx);
// here icons_per_row always higher than 0 marging = width - (icons_per_row-1)*(icon_size+sysbar->area.paddingx) - icon_size;
icons_per_row = (width+sysbar->area.paddingx) / (icon_size+sysbar->area.paddingx); icons_per_column = count / icons_per_row+ (count%icons_per_row != 0);
marging = width - (icons_per_row-1)*(icon_size+sysbar->area.paddingx) - icon_size; systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * systray.area.paddingx);
icons_per_column = count / icons_per_row+ (count%icons_per_row != 0);
systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * systray.area.paddingx);
}
} }
return 1; return 1;
} }
@ -433,6 +435,9 @@ gboolean add_icon(Window id)
traywin->depth = attr.depth; traywin->depth = attr.depth;
traywin->damage = 0; traywin->damage = 0;
if (systray.area.on_screen == 0)
systray.area.on_screen = 1;
if (systray.sort == 3) if (systray.sort == 3)
systray.list_icons = g_slist_prepend(systray.list_icons, traywin); systray.list_icons = g_slist_prepend(systray.list_icons, traywin);
else if (systray.sort == 2) else if (systray.sort == 2)
@ -488,6 +493,17 @@ void remove_icon(TrayWindow *traywin)
stop_timeout(traywin->render_timeout); stop_timeout(traywin->render_timeout);
g_free(traywin); g_free(traywin);
// check empty systray
int count = 0;
GSList *l;
for (l = systray.list_icons; l ; l = l->next) {
if (!((TrayWindow*)l->data)->hide)
count++;
}
if (count == 0) {
systray.area.on_screen = 0;
systray.area.width = 0;
}
// changed in systray force resize on panel // changed in systray force resize on panel
Panel *panel = systray.area.panel; Panel *panel = systray.area.panel;
panel->area.resize = 1; panel->area.resize = 1;

View file

@ -46,128 +46,6 @@ guint win_hash(gconstpointer key) { return (guint)*((Window*)key); }
gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); } gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); }
void free_ptr_array(gpointer data) { g_ptr_array_free(data, 1); } void free_ptr_array(gpointer data) { g_ptr_array_free(data, 1); }
void init_taskbar()
{
Panel *panel;
int i, j;
if (win_to_task_table == 0)
win_to_task_table = g_hash_table_new_full(win_hash, win_compare, free, free_ptr_array);
task_active = 0;
task_drag = 0;
for (i=0 ; i < nb_panel ; i++) {
panel = &panel1[i];
if (panel->g_taskbar.bg == 0) {
panel->g_taskbar.bg = &g_array_index(backgrounds, Background, 0);
panel->g_taskbar.area.bg = panel->g_taskbar.bg;
}
if (panel->g_taskbar.bg_active == 0)
panel->g_taskbar.bg_active = panel->g_taskbar.bg;
if (panel->g_task.area.bg == 0)
panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0);
// taskbar
panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT;
panel->g_taskbar.area._resize = resize_taskbar;
panel->g_taskbar.area.redraw = 1;
panel->g_taskbar.area.on_screen = 1;
if (panel_horizontal) {
panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy;
panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy);
}
else {
panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy;
panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx);
}
// task
panel->g_task.area.size_mode = SIZE_BY_LAYOUT;
panel->g_task.area._draw_foreground = draw_task;
panel->g_task.area.redraw = 1;
panel->g_task.area.on_screen = 1;
if ((panel->g_task.config_asb_mask & (1<<TASK_NORMAL)) == 0) {
panel->g_task.alpha[TASK_NORMAL] = 100;
panel->g_task.saturation[TASK_NORMAL] = 0;
panel->g_task.brightness[TASK_NORMAL] = 0;
}
if ((panel->g_task.config_asb_mask & (1<<TASK_ACTIVE)) == 0) {
panel->g_task.alpha[TASK_ACTIVE] = panel->g_task.alpha[TASK_NORMAL];
panel->g_task.saturation[TASK_ACTIVE] = panel->g_task.saturation[TASK_NORMAL];
panel->g_task.brightness[TASK_ACTIVE] = panel->g_task.brightness[TASK_NORMAL];
}
if ((panel->g_task.config_asb_mask & (1<<TASK_ICONIFIED)) == 0) {
panel->g_task.alpha[TASK_ICONIFIED] = panel->g_task.alpha[TASK_NORMAL];
panel->g_task.saturation[TASK_ICONIFIED] = panel->g_task.saturation[TASK_NORMAL];
panel->g_task.brightness[TASK_ICONIFIED] = panel->g_task.brightness[TASK_NORMAL];
}
if ((panel->g_task.config_asb_mask & (1<<TASK_URGENT)) == 0) {
panel->g_task.alpha[TASK_URGENT] = panel->g_task.alpha[TASK_ACTIVE];
panel->g_task.saturation[TASK_URGENT] = panel->g_task.saturation[TASK_ACTIVE];
panel->g_task.brightness[TASK_URGENT] = panel->g_task.brightness[TASK_ACTIVE];
}
if ((panel->g_task.config_font_mask & (1<<TASK_NORMAL)) == 0) panel->g_task.font[TASK_NORMAL] = (Color){{0, 0, 0}, 0};
if ((panel->g_task.config_font_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.font[TASK_ACTIVE] = panel->g_task.font[TASK_NORMAL];
if ((panel->g_task.config_font_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.font[TASK_ICONIFIED] = panel->g_task.font[TASK_NORMAL];
if ((panel->g_task.config_font_mask & (1<<TASK_URGENT)) == 0) panel->g_task.font[TASK_URGENT] = panel->g_task.font[TASK_ACTIVE];
if ((panel->g_task.config_font_mask & (1<<TASK_NORMAL)) == 0) panel->g_task.background[TASK_NORMAL] = &g_array_index(backgrounds, Background, 0);
if ((panel->g_task.config_background_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.background[TASK_ACTIVE] = panel->g_task.background[TASK_NORMAL];
if ((panel->g_task.config_background_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.background[TASK_ICONIFIED] = panel->g_task.background[TASK_NORMAL];
if ((panel->g_task.config_background_mask & (1<<TASK_URGENT)) == 0) panel->g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE];
if (panel_horizontal) {
panel->g_task.area.posy = panel->g_taskbar.area.posy + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
}
else {
panel->g_task.area.posx = panel->g_taskbar.area.posx + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx);
panel->g_task.area.height = panel->g_task.maximum_height;
}
int k;
for (k=0; k<TASK_STATE_COUNT; ++k) {
if (panel->g_task.background[k]->border.rounded > panel->g_task.area.height/2) {
printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n", k==0 ? "_" : k==1 ? "_active_" : k==2 ? "_iconified_" : "_urgent_");
g_array_append_val(backgrounds, *panel->g_task.background[k]);
panel->g_task.background[k] = &g_array_index(backgrounds, Background, backgrounds->len-1);
panel->g_task.background[k]->border.rounded = panel->g_task.area.height/2;
}
}
// compute vertical position : text and icon
int height_ink, height;
get_text_size(panel->g_task.font_desc, &height_ink, &height, panel->area.height, "TAjpg", 5);
if (!panel->g_task.maximum_width && panel_horizontal)
panel->g_task.maximum_width = server.monitor[panel->monitor].width;
panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
if (panel->g_task.icon) {
panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
panel->g_task.text_posx += panel->g_task.icon_size1;
panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2;
}
//printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width);
Taskbar *tskbar;
for (j=0 ; j < panel->nb_desktop ; j++) {
tskbar = &panel->taskbar[j];
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
tskbar->desktop = j;
if (j == server.desktop && panel->g_taskbar.use_active)
tskbar->area.bg = panel->g_taskbar.bg_active;
}
}
}
void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data)
{
remove_task(task_get_task(*(Window*)key));
}
void default_taskbar() void default_taskbar()
{ {
@ -204,6 +82,132 @@ void cleanup_taskbar()
} }
void init_taskbar()
{
if (win_to_task_table == 0)
win_to_task_table = g_hash_table_new_full(win_hash, win_compare, free, free_ptr_array);
task_active = 0;
task_drag = 0;
}
void init_taskbar_panel(void *p)
{
Panel *panel =(Panel*)p;
int j;
if (panel->g_taskbar.bg == 0) {
panel->g_taskbar.bg = &g_array_index(backgrounds, Background, 0);
panel->g_taskbar.area.bg = panel->g_taskbar.bg;
}
if (panel->g_taskbar.bg_active == 0)
panel->g_taskbar.bg_active = panel->g_taskbar.bg;
if (panel->g_task.area.bg == 0)
panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0);
// taskbar
panel->g_taskbar.area.size_mode = SIZE_BY_LAYOUT;
panel->g_taskbar.area._resize = resize_taskbar;
panel->g_taskbar.area.redraw = 1;
panel->g_taskbar.area.on_screen = 1;
if (panel_horizontal) {
panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy;
panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy);
}
else {
panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy;
panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx);
}
// task
panel->g_task.area.size_mode = SIZE_BY_LAYOUT;
panel->g_task.area._draw_foreground = draw_task;
panel->g_task.area.redraw = 1;
panel->g_task.area.on_screen = 1;
if ((panel->g_task.config_asb_mask & (1<<TASK_NORMAL)) == 0) {
panel->g_task.alpha[TASK_NORMAL] = 100;
panel->g_task.saturation[TASK_NORMAL] = 0;
panel->g_task.brightness[TASK_NORMAL] = 0;
}
if ((panel->g_task.config_asb_mask & (1<<TASK_ACTIVE)) == 0) {
panel->g_task.alpha[TASK_ACTIVE] = panel->g_task.alpha[TASK_NORMAL];
panel->g_task.saturation[TASK_ACTIVE] = panel->g_task.saturation[TASK_NORMAL];
panel->g_task.brightness[TASK_ACTIVE] = panel->g_task.brightness[TASK_NORMAL];
}
if ((panel->g_task.config_asb_mask & (1<<TASK_ICONIFIED)) == 0) {
panel->g_task.alpha[TASK_ICONIFIED] = panel->g_task.alpha[TASK_NORMAL];
panel->g_task.saturation[TASK_ICONIFIED] = panel->g_task.saturation[TASK_NORMAL];
panel->g_task.brightness[TASK_ICONIFIED] = panel->g_task.brightness[TASK_NORMAL];
}
if ((panel->g_task.config_asb_mask & (1<<TASK_URGENT)) == 0) {
panel->g_task.alpha[TASK_URGENT] = panel->g_task.alpha[TASK_ACTIVE];
panel->g_task.saturation[TASK_URGENT] = panel->g_task.saturation[TASK_ACTIVE];
panel->g_task.brightness[TASK_URGENT] = panel->g_task.brightness[TASK_ACTIVE];
}
if ((panel->g_task.config_font_mask & (1<<TASK_NORMAL)) == 0) panel->g_task.font[TASK_NORMAL] = (Color){{0, 0, 0}, 0};
if ((panel->g_task.config_font_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.font[TASK_ACTIVE] = panel->g_task.font[TASK_NORMAL];
if ((panel->g_task.config_font_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.font[TASK_ICONIFIED] = panel->g_task.font[TASK_NORMAL];
if ((panel->g_task.config_font_mask & (1<<TASK_URGENT)) == 0) panel->g_task.font[TASK_URGENT] = panel->g_task.font[TASK_ACTIVE];
if ((panel->g_task.config_font_mask & (1<<TASK_NORMAL)) == 0) panel->g_task.background[TASK_NORMAL] = &g_array_index(backgrounds, Background, 0);
if ((panel->g_task.config_background_mask & (1<<TASK_ACTIVE)) == 0) panel->g_task.background[TASK_ACTIVE] = panel->g_task.background[TASK_NORMAL];
if ((panel->g_task.config_background_mask & (1<<TASK_ICONIFIED)) == 0) panel->g_task.background[TASK_ICONIFIED] = panel->g_task.background[TASK_NORMAL];
if ((panel->g_task.config_background_mask & (1<<TASK_URGENT)) == 0) panel->g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE];
if (panel_horizontal) {
panel->g_task.area.posy = panel->g_taskbar.area.posy + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
}
else {
panel->g_task.area.posx = panel->g_taskbar.area.posx + panel->g_taskbar.bg->border.width + panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx);
panel->g_task.area.height = panel->g_task.maximum_height;
}
for (j=0; j<TASK_STATE_COUNT; ++j) {
if (panel->g_task.background[j]->border.rounded > panel->g_task.area.height/2) {
printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n", j==0 ? "_" : j==1 ? "_active_" : j==2 ? "_iconified_" : "_urgent_");
g_array_append_val(backgrounds, *panel->g_task.background[j]);
panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len-1);
panel->g_task.background[j]->border.rounded = panel->g_task.area.height/2;
}
}
// compute vertical position : text and icon
int height_ink, height;
get_text_size(panel->g_task.font_desc, &height_ink, &height, panel->area.height, "TAjpg", 5);
if (!panel->g_task.maximum_width && panel_horizontal)
panel->g_task.maximum_width = server.monitor[panel->monitor].width;
panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
if (panel->g_task.icon) {
panel->g_task.icon_size1 = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
panel->g_task.text_posx += panel->g_task.icon_size1;
panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2;
}
//printf("monitor %d, task_maximum_width %d\n", panel->monitor, panel->g_task.maximum_width);
Taskbar *tskbar;
panel->nb_desktop = server.nb_desktop;
panel->taskbar = calloc(server.nb_desktop, sizeof(Taskbar));
for (j=0 ; j < panel->nb_desktop ; j++) {
tskbar = &panel->taskbar[j];
memcpy(&tskbar->area, &panel->g_taskbar, sizeof(Area));
tskbar->desktop = j;
if (j == server.desktop && panel->g_taskbar.use_active)
tskbar->area.bg = panel->g_taskbar.bg_active;
}
}
void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data)
{
remove_task(task_get_task(*(Window*)key));
}
Task *task_get_task (Window win) Task *task_get_task (Window win)
{ {
GPtrArray* task_group = task_get_tasks(win); GPtrArray* task_group = task_get_tasks(win);

View file

@ -44,7 +44,9 @@ void default_taskbar();
void cleanup_taskbar(); void cleanup_taskbar();
void init_taskbar(); void init_taskbar();
void init_taskbar_panel(void *p);
void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data);
Task *task_get_task (Window win); Task *task_get_task (Window win);
GPtrArray* task_get_tasks(Window win); GPtrArray* task_get_tasks(Window win);
void task_refresh_tasklist (); void task_refresh_tasklist ();

View file

@ -490,10 +490,11 @@ void event_property_notify (XEvent *e)
server.nb_desktop = server_get_number_of_desktop (); server.nb_desktop = server_get_number_of_desktop ();
cleanup_taskbar(); cleanup_taskbar();
init_taskbar(); init_taskbar();
visible_object();
for (i=0 ; i < nb_panel ; i++) { for (i=0 ; i < nb_panel ; i++) {
set_panel_items(&panel1[i]);
panel1[i].area.resize = 1; panel1[i].area.resize = 1;
} }
visible_object();
task_refresh_tasklist(); task_refresh_tasklist();
active_task(); active_task();
panel_refresh = 1; panel_refresh = 1;
@ -883,7 +884,7 @@ start:
signal_pending = SIGUSR1; signal_pending = SIGUSR1;
break; break;
} }
if (e.xany.window == g_tooltip.window || !systray.area.on_screen) if (e.xany.window == g_tooltip.window || !systray_enabled)
break; break;
for (it = systray.list_icons; it; it = g_slist_next(it)) { for (it = systray.list_icons; it; it = g_slist_next(it)) {
if (((TrayWindow*)it->data)->tray_id == e.xany.window) { if (((TrayWindow*)it->data)->tray_id == e.xany.window) {
@ -903,7 +904,7 @@ start:
// Start real_transparency // Start real_transparency
signal_pending = SIGUSR1; signal_pending = SIGUSR1;
} }
if (systray.area.on_screen && e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) { if (systray_enabled && e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) {
net_message(&e.xclient); net_message(&e.xclient);
} }
else if (e.xclient.message_type == server.atom.XdndPosition) { else if (e.xclient.message_type == server.atom.XdndPosition) {

View file

@ -63,7 +63,8 @@ typedef struct {
// list of child : Area object // list of child : Area object
GSList *list; GSList *list;
// object visible on screen // object visible on screen.
// An object (like systray) could be enabled but hidden (because no tray icon).
int on_screen; int on_screen;
// way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT) // way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT)
int size_mode; int size_mode;