panel: Watch the panel`s WM_DESKTOP property and reset it if it changes

This commit is contained in:
o9000 2016-03-24 19:36:55 +01:00
parent 5f82ef4d3b
commit d398795202
3 changed files with 14 additions and 9 deletions

View file

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

View file

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

View file

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