Add behavior to hide an empty taskbar in multi_desktop mode
This commit is contained in:
parent
008eebe4b1
commit
8976f35c5f
4 changed files with 41 additions and 28 deletions
|
@ -269,12 +269,11 @@ void init_panel()
|
|||
|
||||
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)
|
||||
|
|
|
@ -430,18 +430,46 @@ gboolean resize_taskbar(void *obj)
|
|||
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) {
|
||||
|
@ -459,22 +487,6 @@ void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
|
|||
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;
|
||||
}
|
||||
|
||||
#define NONTRIVIAL 2
|
||||
gint compare_tasks_trivial(Task *a, Task *b, Taskbar *taskbar)
|
||||
{
|
||||
|
|
|
@ -79,10 +79,11 @@ Task *get_task(Window win);
|
|||
// 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);
|
||||
|
|
|
@ -1010,7 +1010,7 @@ void event_property_notify(XEvent *e)
|
|||
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 @@ void event_property_notify(XEvent *e)
|
|||
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 @@ void event_property_notify(XEvent *e)
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue