all repos — tint2 @ 8976f35c5fba405658118c4b2470450b1a51ec28

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
Benoit Averty benoit.averty@gmail.com
commit

8976f35c5fba405658118c4b2470450b1a51ec28

parent

008eebe4b1238c827e76b8c77aee1231f61a748f

4 files changed, 41 insertions(+), 28 deletions(-)

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

@@ -269,12 +269,11 @@ }

if (panel_autohide) autohide_trigger_hide(p); - - update_taskbar_visibility(p); } taskbar_refresh_tasklist(); reset_active_task(); + update_all_taskbars_visibility(); } void init_panel_size_and_position(Panel *panel)
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -430,18 +430,46 @@ }

return FALSE; } +void update_one_taskbar_visibility(Taskbar *taskbar) +{ + //TODO handle hidden name + gboolean taskbar_non_empty = g_list_length(taskbar->area.children) > 1; + + 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) { + // MULTI_DESKTOP : show non-empty taskbars + taskbar->area.on_screen = TRUE; + } + else { + taskbar->area.on_screen = FALSE; + } + + panel_refresh = TRUE; +} + +void update_all_taskbars_visibility() +{ + for (int i = 0; i < num_panels; i++) { + Panel *panel = &panels[i]; + 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) { taskbar->area.bg = panels[0].g_taskbar.background[state]; if (taskbarname_enabled) { taskbar->bar_name.area.bg = panels[0].g_taskbar.background_name[state]; } - if (taskbar_mode != MULTI_DESKTOP) { - if (state == TASKBAR_NORMAL) - taskbar->area.on_screen = FALSE; - else - taskbar->area.on_screen = TRUE; - } + + update_one_taskbar_visibility(taskbar); + if (taskbar->area.on_screen) { schedule_redraw(&taskbar->area); if (taskbarname_enabled) {

@@ -454,22 +482,6 @@ if (taskbarname_enabled)

l = l->next; for (; l; l = l->next) schedule_redraw((Area *)l->data); - } - } - panel_refresh = TRUE; -} - -void update_taskbar_visibility(void *p) -{ - Panel *panel = (Panel *)p; - - for (int j = 0; j < panel->num_desktops; j++) { - Taskbar *taskbar = &panel->taskbar[j]; - if (taskbar_mode != MULTI_DESKTOP && taskbar->desktop != server.desktop) { - // SINGLE_DESKTOP and not current desktop - taskbar->area.on_screen = FALSE; - } else { - taskbar->area.on_screen = TRUE; } } panel_refresh = TRUE;
M src/taskbar/taskbar.hsrc/taskbar/taskbar.h

@@ -79,10 +79,11 @@ // Returns the task buttons for this window, usually having only one element.

// However for windows shown on all desktops, there are multiple buttons, one for each taskbar. GPtrArray *get_task_buttons(Window win); +// Change state of a taskbar (ACTIVE or NORMAL) void set_taskbar_state(Taskbar *taskbar, TaskbarState state); -// Updates the visibility of each taskbar when the current desktop changes. -void update_taskbar_visibility(void *p); +// Updates the visibility of all taskbars +void update_all_taskbars_visibility(); // Sorts the taskbar(s) on which the window is present. void sort_taskbar_for_win(Window win);
M src/tint.csrc/tint.c

@@ -1010,7 +1010,7 @@ int old_num_desktops = server.num_desktops;

int old_desktop = server.desktop; server_get_number_of_desktops(); server.desktop = get_current_desktop(); - if (old_num_desktops != server.num_desktops) { + if (old_num_desktops != server.num_desktops) { // If number of desktop changed if (server.num_desktops <= server.desktop) { server.desktop = server.num_desktops - 1; }

@@ -1019,11 +1019,11 @@ init_taskbar();

for (int i = 0; i < num_panels; i++) { init_taskbar_panel(&panels[i]); set_panel_items_order(&panels[i]); - update_taskbar_visibility(&panels[i]); panels[i].area.resize_needed = 1; } taskbar_refresh_tasklist(); reset_active_task(); + update_all_taskbars_visibility(); panel_refresh = TRUE; } else if (old_desktop != server.desktop) { for (int i = 0; i < num_panels; i++) {

@@ -1092,6 +1092,7 @@ else if (at == server.atom._NET_CLIENT_LIST) {

if (debug) fprintf(stderr, "%s %d: win = root, atom = _NET_CLIENT_LIST\n", __FUNCTION__, __LINE__); taskbar_refresh_tasklist(); + update_all_taskbars_visibility(); panel_refresh = TRUE; } // Change active