all repos — tint2 @ d765190e3d3bd6b13b313c4a2425bd8d4241e8aa

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Add behavior to hide an empty taskbar in multi_desktop mode: fix TODO and fix panel resize
Benoit Averty benoit.averty@gmail.com
commit

d765190e3d3bd6b13b313c4a2425bd8d4241e8aa

parent

8976f35c5fba405658118c4b2470450b1a51ec28

2 files changed, 27 insertions(+), 16 deletions(-)

jump to
M src/panel.csrc/panel.c

@@ -394,7 +394,11 @@ // Compute the total available size, and the total size requested by the taskbars

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 @@ // number of tasks in each taskbar)

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)) +
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -169,7 +169,7 @@ panel->g_taskbar.area.on_screen = TRUE;

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 @@ }

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; + show(&taskbar->area); + } else { + hide(&taskbar->area); } - else { - taskbar->area.on_screen = FALSE; - } - - panel_refresh = TRUE; } void update_all_taskbars_visibility()

@@ -458,7 +464,6 @@ for (int j = 0; j < panel->num_desktops; j++) {

update_one_taskbar_visibility(&panel->taskbar[j]); } } - panel_refresh = TRUE; } void set_taskbar_state(Taskbar *taskbar, TaskbarState state)