diff options
Diffstat (limited to 'app/x11_util.cc')
-rw-r--r-- | app/x11_util.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/app/x11_util.cc b/app/x11_util.cc index 934e824..101815a 100644 --- a/app/x11_util.cc +++ b/app/x11_util.cc @@ -159,6 +159,10 @@ XID GetX11RootWindow() { return GDK_WINDOW_XID(gdk_get_default_root_window()); } +bool GetCurrentDesktop(int* desktop) { + return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); +} + XID GetX11WindowFromGtkWidget(GtkWidget* widget) { return GDK_WINDOW_XID(widget->window); } @@ -192,7 +196,15 @@ int BitsPerPixelForPixmapDepth(Display* dpy, int depth) { bool IsWindowVisible(XID window) { XWindowAttributes win_attributes; XGetWindowAttributes(GetXDisplay(), window, &win_attributes); - return (win_attributes.map_state == IsViewable); + if (win_attributes.map_state != IsViewable) + return false; + // Some compositing window managers (notably kwin) do not actually unmap + // windows on desktop switch, so we also must check the current desktop. + int window_desktop, current_desktop; + return (!GetWindowDesktop(window, &window_desktop) || + !GetCurrentDesktop(¤t_desktop) || + window_desktop == kAllDesktops || + window_desktop == current_desktop); } bool GetWindowRect(XID window, gfx::Rect* rect) { @@ -342,6 +354,10 @@ XID GetHighestAncestorWindow(XID window, XID root) { } } +bool GetWindowDesktop(XID window, int* desktop) { + return GetIntProperty(window, "_NET_WM_DESKTOP", desktop); +} + // Returns true if |window| is a named window. bool IsWindowNamed(XID window) { XTextProperty prop; @@ -787,7 +803,12 @@ void GrabWindowSnapshot(GtkWindow* gtk_window, bool ChangeWindowDesktop(XID window, XID destination) { int desktop; - if (!GetIntProperty(destination, "_NET_WM_DESKTOP", &desktop)) + if (!GetWindowDesktop(destination, &desktop)) + return false; + + // If |window| is sticky, use the current desktop. + if (desktop == kAllDesktops && + !GetCurrentDesktop(&desktop)) return false; XEvent event; |