On Compiz (etc?), _NET_WM_ACTION_FULLSCREEN needs the window to be resizable.

Thanks to Edward Rudd for the patch!

--HG--
extra : rebase_source : 2039db129b3a6801e0001c6b8f508f5b0d27269e
This commit is contained in:
Ryan C. Gordon 2012-09-27 00:53:37 -04:00
parent 9119439672
commit 170089c6aa
3 changed files with 52 additions and 0 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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; i<len; ++i)
{
if (list[i] == action) {
ret = True;
break;
}
}
XFree(list);
}
return ret;
}
void
X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen)
{
@ -896,6 +921,29 @@ X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display,
if (X11_IsWindowMapped(_this, window)) {
XEvent e;
if (isActionAllowed(data, data->videodata->_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;