From 8db67d8892106c042fb9b04cd49229dd34f76f0a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 27 Sep 2012 00:53:37 -0400 Subject: [PATCH] On Compiz (etc?), _NET_WM_ACTION_FULLSCREEN needs the window to be resizable. Thanks to Edward Rudd for the patch! --- src/video/x11/SDL_x11video.c | 2 ++ src/video/x11/SDL_x11video.h | 2 ++ src/video/x11/SDL_x11window.c | 48 +++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 1b8ff4237..c7197bef5 100755 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -339,6 +339,8 @@ X11_VideoInit(_THIS) GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); GET_ATOM(_NET_WM_STATE_FULLSCREEN); + GET_ATOM(_NET_WM_ALLOWED_ACTIONS); + GET_ATOM(_NET_WM_ACTION_FULLSCREEN); GET_ATOM(_NET_WM_NAME); GET_ATOM(_NET_WM_ICON_NAME); GET_ATOM(_NET_WM_ICON); diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index 59234296f..232e37878 100755 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -86,6 +86,8 @@ typedef struct SDL_VideoData Atom _NET_WM_STATE_MAXIMIZED_VERT; Atom _NET_WM_STATE_MAXIMIZED_HORZ; Atom _NET_WM_STATE_FULLSCREEN; + Atom _NET_WM_ALLOWED_ACTIONS; + Atom _NET_WM_ACTION_FULLSCREEN; Atom _NET_WM_NAME; Atom _NET_WM_ICON_NAME; Atom _NET_WM_ICON; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 68fe640f0..4ee61e1ef 100755 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -882,6 +882,31 @@ X11_RestoreWindow(_THIS, SDL_Window * window) X11_ShowWindow(_this, window); } +static Bool +isActionAllowed(SDL_WindowData *data, Atom action) +{ + Atom _NET_WM_ALLOWED_ACTIONS = data->videodata->_NET_WM_ALLOWED_ACTIONS; + Atom type; + Display *display = data->videodata->display; + int form; + unsigned long remain; + unsigned long len, i; + Atom *list; + Bool ret = False; + if (XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success) + { + for (i=0; ivideodata->_NET_WM_ACTION_FULLSCREEN) == False) + { + /* We aren't allowed to go into fullscreen mode... */ + if ((window->flags & SDL_WINDOW_RESIZABLE) == 0) { + /* ...and we aren't resizable. Compiz refuses fullscreen toggle in this case. */ + XSizeHints *sizehints = XAllocSizeHints(); + long flags = 0; + XGetWMNormalHints(display, data->xwindow, sizehints, &flags); + /* set the resize flags on */ + sizehints->flags |= PMinSize | PMaxSize; + if (fullscreen) { + /* we are going fullscreen so turn the flags off */ + sizehints->flags ^= (PMinSize | PMaxSize); + } else { + /* Reset the min/max width height to make the window non-resizable again */ + sizehints->min_width = sizehints->max_width = window->w; + sizehints->min_height = sizehints->max_height = window->h; + } + XSetWMNormalHints(display, data->xwindow, sizehints); + XFree(sizehints); + } + } + SDL_zero(e); e.xany.type = ClientMessage; e.xclient.message_type = _NET_WM_STATE;