Fix X11_RestoreWindow() and X11_RaiseWindow() to properly do window activation. X11_RestoreWindow() had a call ordering problem that prevented activation, and X11_RaiseWindow() wasn't attempting activation. Windows and OS X both activate in these cases. CR: saml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 2dde727..0a8e3df 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -935,6 +935,34 @@ X11_HideWindow(_THIS, SDL_Window * window)
}
}
+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_RaiseWindow(_THIS, SDL_Window * window)
{
@@ -942,6 +970,7 @@ X11_RaiseWindow(_THIS, SDL_Window * window)
Display *display = data->videodata->display;
XRaiseWindow(display, data->xwindow);
+ SetWindowActive(_this, window);
XFlush(display);
}
@@ -1002,40 +1031,12 @@ X11_MinimizeWindow(_THIS, SDL_Window * window)
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);
+ SetWindowActive(_this, window);
}
/* This asks the Window Manager to handle fullscreen for us. Most don't do it right, though. */