From d398795202dd9764cf6e5ac844e90f3a648023ba Mon Sep 17 00:00:00 2001 From: o9000 Date: Thu, 24 Mar 2016 19:36:55 +0100 Subject: [PATCH] panel: Watch the panel`s WM_DESKTOP property and reset it if it changes --- src/panel.c | 2 +- src/tint.c | 10 ++++++++-- src/util/window.c | 11 +++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/panel.c b/src/panel.c index d914827..73a09ed 100644 --- a/src/panel.c +++ b/src/panel.c @@ -241,7 +241,7 @@ void init_panel() mask, &att); - long event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask; + long event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PropertyChangeMask; if (p->mouse_effects || p->g_task.tooltip_enabled || p->clock.area._get_tooltip_text || (launcher_enabled && launcher_tooltip_enabled)) event_mask |= PointerMotionMask | LeaveWindowMask; diff --git a/src/tint.c b/src/tint.c index a372482..312144f 100644 --- a/src/tint.c +++ b/src/tint.c @@ -919,6 +919,14 @@ void event_property_notify(XEvent *e) if (xsettings_client) xsettings_client_process_event(xsettings_client, e); + for (int i = 0; i < num_panels; i++) { + Panel *p = &panels[i]; + if (win == p->main_win) { + if (at == server.atom._NET_WM_DESKTOP && get_window_desktop(p->main_win) != ALL_DESKTOPS) + place_panel_all_desktops(p); + return; + } + } if (win == server.root_win) { if (!server.got_root_win) { XSelectInput(server.display, server.root_win, PropertyChangeMask | StructureNotifyMask); @@ -953,7 +961,6 @@ void event_property_notify(XEvent *e) init_taskbar(); for (int i = 0; i < num_panels; i++) { init_taskbar_panel(&panels[i]); - place_panel_all_desktops(&panels[i]); set_panel_items_order(&panels[i]); update_taskbar_visibility(&panels[i]); panels[i].area.resize_needed = 1; @@ -964,7 +971,6 @@ void event_property_notify(XEvent *e) } else if (old_desktop != server.desktop) { for (int i = 0; i < num_panels; i++) { Panel *panel = &panels[i]; - place_panel_all_desktops(panel); set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL); set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE); // check ALL_DESKTOPS task => resize taskbar diff --git a/src/util/window.c b/src/util/window.c index 97452fd..507a025 100644 --- a/src/util/window.c +++ b/src/util/window.c @@ -108,17 +108,16 @@ gboolean window_is_hidden(Window win) int get_window_desktop(Window win) { - if (!server.viewports) { - int desktop = get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL); - if (desktop != ALL_DESKTOPS) - desktop = MAX(0, MIN(server.num_desktops - 1, desktop)); + int desktop = get_property32(win, server.atom._NET_WM_DESKTOP, XA_CARDINAL); + if (desktop == ALL_DESKTOPS) return desktop; - } + if (!server.viewports) + return CLAMP(desktop, 0, server.num_desktops - 1); int x, y, w, h; get_window_coordinates(win, &x, &y, &w, &h); - int desktop = get_current_desktop(); + desktop = get_current_desktop(); // Window coordinates are relative to the current viewport, make them absolute x += server.viewports[desktop].x; y += server.viewports[desktop].y;