Commit 187e7f29 by o9000

Add behavior to hide an empty taskbar in multi_desktop mode: fix TODO and fix panel resize

parent 8976f35c
......@@ -394,7 +394,11 @@ gboolean resize_panel(void *obj)
int total_size = 0;
int total_name_size = 0;
int total_items = 0;
int visible_taskbars = 0;
for (int i = 0; i < panel->num_desktops; i++) {
if (!panel->taskbar[i].area.on_screen)
continue;
visible_taskbars++;
if (panel_horizontal) {
total_size += panel->taskbar[i].area.width;
} else {
......@@ -426,14 +430,16 @@ gboolean resize_panel(void *obj)
if (total_items) {
int actual_name_size;
if (total_name_size <= total_size) {
actual_name_size = total_name_size / panel->num_desktops;
actual_name_size = total_name_size / visible_taskbars;
} else {
actual_name_size = total_size / panel->num_desktops;
actual_name_size = total_size / visible_taskbars;
}
total_size -= total_name_size;
for (int i = 0; i < panel->num_desktops; i++) {
Taskbar *taskbar = &panel->taskbar[i];
if (!taskbar->area.on_screen)
continue;
int requested_size = (panel_horizontal ? left_right_border_width(&taskbar->area)
: top_bottom_border_width(&taskbar->area)) +
......
......@@ -169,7 +169,7 @@ void init_taskbar_panel(void *p)
if (panel_horizontal) {
panel->g_taskbar.area.posy = top_border_width(&panel->area) + panel->area.paddingy;
panel->g_taskbar.area.height =
panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy;
panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy;
panel->g_taskbar.area_name.posy = panel->g_taskbar.area.posy;
panel->g_taskbar.area_name.height = panel->g_taskbar.area.height;
} else {
......@@ -430,24 +430,30 @@ gboolean resize_taskbar(void *obj)
return FALSE;
}
void update_one_taskbar_visibility(Taskbar *taskbar)
gboolean taskbar_is_empty(Taskbar *taskbar)
{
//TODO handle hidden name
gboolean taskbar_non_empty = g_list_length(taskbar->area.children) > 1;
GList *l = taskbar->area.children;
if (taskbarname_enabled)
l = l->next;
for (; l != NULL; l = l->next) {
if (((Task *)l->data)->area.on_screen) {
return TRUE;
}
}
return FALSE;
}
void update_one_taskbar_visibility(Taskbar *taskbar)
{
if (taskbar->desktop == server.desktop) {
// Taskbar for current desktop is always shown
taskbar->area.on_screen = TRUE;
}
else if (taskbar_mode == MULTI_DESKTOP && taskbar_non_empty) {
show(&taskbar->area);
} else if (taskbar_mode == MULTI_DESKTOP && taskbar_is_empty(taskbar)) {
// MULTI_DESKTOP : show non-empty taskbars
taskbar->area.on_screen = TRUE;
}
else {
taskbar->area.on_screen = FALSE;
show(&taskbar->area);
} else {
hide(&taskbar->area);
}
panel_refresh = TRUE;
}
void update_all_taskbars_visibility()
......@@ -458,7 +464,6 @@ void update_all_taskbars_visibility()
update_one_taskbar_visibility(&panel->taskbar[j]);
}
}
panel_refresh = TRUE;
}
void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment