Make it so SDL_RestoreWindow() implements the _NET_ACTIVE_WINDOW protocol which some window managers require to restore full screen windows. CR: saml

This commit is contained in:
Sam Lantinga
2013-03-06 09:37:03 -08:00
parent 7c3cb6e7f4
commit 14bbe49aae
3 changed files with 31 additions and 0 deletions

View File

@@ -522,6 +522,7 @@ X11_VideoInit(_THIS)
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 */

View File

@@ -99,6 +99,7 @@ typedef struct SDL_VideoData
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];

View File

@@ -927,10 +927,39 @@ 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);
}