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

This commit is contained in:
Benoit Averty
2016-09-04 15:33:33 +02:00
parent 8976f35c5f
commit d765190e3d
2 changed files with 27 additions and 16 deletions

View File

@@ -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)) +