Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Make it so SDL_RestoreWindow() implements the _NET_ACTIVE_WINDOW prot…
Browse files Browse the repository at this point in the history
…ocol which some window managers require to restore full screen windows. CR: saml
  • Loading branch information
slouken committed Mar 6, 2013
1 parent 33be7a1 commit 956d061
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions src/video/x11/SDL_x11video.h
Expand Up @@ -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];
Expand Down
29 changes: 29 additions & 0 deletions src/video/x11/SDL_x11window.c
Expand Up @@ -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);
}

Expand Down

0 comments on commit 956d061

Please sign in to comment.