Make it so SDL_RestoreWindow() implements the _NET_ACTIVE_WINDOW protocol which some window managers require to restore full screen windows. CR: saml
authorSam Lantinga <slouken@libsdl.org>
Wed, 06 Mar 2013 09:37:03 -0800
changeset 6970 e0db39f7afb0
parent 6969 74cf567e8618
child 6971 5ded971ee761
Make it so SDL_RestoreWindow() implements the _NET_ACTIVE_WINDOW protocol which some window managers require to restore full screen windows. CR: saml
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
src/video/x11/SDL_x11window.c
--- a/src/video/x11/SDL_x11video.c	Wed Mar 06 10:37:27 2013 -0500
+++ b/src/video/x11/SDL_x11video.c	Wed Mar 06 09:37:03 2013 -0800
@@ -522,6 +522,7 @@
     GET_ATOM(_NET_WM_ICON_NAME);
     GET_ATOM(_NET_WM_ICON);
     GET_ATOM(_NET_WM_PING);
+    GET_ATOM(_NET_ACTIVE_WINDOW);
     GET_ATOM(UTF8_STRING);
 
     /* Detect the window manager */
--- a/src/video/x11/SDL_x11video.h	Wed Mar 06 10:37:27 2013 -0500
+++ b/src/video/x11/SDL_x11video.h	Wed Mar 06 09:37:03 2013 -0800
@@ -99,6 +99,7 @@
     Atom _NET_WM_ICON_NAME;
     Atom _NET_WM_ICON;
     Atom _NET_WM_PING;
+    Atom _NET_ACTIVE_WINDOW;
     Atom UTF8_STRING;
 
     SDL_Scancode key_layout[256];
--- a/src/video/x11/SDL_x11window.c	Wed Mar 06 10:37:27 2013 -0500
+++ b/src/video/x11/SDL_x11window.c	Wed Mar 06 09:37:03 2013 -0800
@@ -927,10 +927,39 @@
     XFlush(display);
 }
 
+static void
+SetWindowActive(_THIS, SDL_Window * window)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    SDL_DisplayData *displaydata =
+        (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
+    Display *display = data->videodata->display;
+	Atom _NET_ACTIVE_WINDOW = data->videodata->_NET_ACTIVE_WINDOW;
+
+    if (X11_IsWindowMapped(_this, window)) {
+        XEvent e;
+
+        SDL_zero(e);
+        e.xany.type = ClientMessage;
+        e.xclient.message_type = _NET_ACTIVE_WINDOW;
+        e.xclient.format = 32;
+        e.xclient.window = data->xwindow;
+        e.xclient.data.l[0] = 1;  /* source indication. 1 = application */
+		e.xclient.data.l[1] = CurrentTime;
+		e.xclient.data.l[2] = 0;
+
+        XSendEvent(display, RootWindow(display, displaydata->screen), 0,
+                   SubstructureNotifyMask | SubstructureRedirectMask, &e);
+
+    	XFlush(display);
+    }
+}
+
 void
 X11_RestoreWindow(_THIS, SDL_Window * window)
 {
     SetWindowMaximized(_this, window, SDL_FALSE);
+	SetWindowActive(_this, window);
     X11_ShowWindow(_this, window);
 }