src/video/x11/SDL_x11window.c
changeset 5302 b1b9ec9874ba
parent 5288 d4381f3b0d1e
child 5305 75f5ff92ad08
     1.1 --- a/src/video/x11/SDL_x11window.c	Tue Feb 15 16:41:04 2011 -0800
     1.2 +++ b/src/video/x11/SDL_x11window.c	Tue Feb 15 17:23:02 2011 -0800
     1.3 @@ -772,7 +772,7 @@
     1.4  }
     1.5  
     1.6  static void
     1.7 -X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized)
     1.8 +SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized)
     1.9  {
    1.10      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.11      SDL_DisplayData *displaydata =
    1.12 @@ -823,7 +823,7 @@
    1.13  void
    1.14  X11_MaximizeWindow(_THIS, SDL_Window * window)
    1.15  {
    1.16 -    X11_SetWindowMaximized(_this, window, SDL_TRUE);
    1.17 +    SetWindowMaximized(_this, window, SDL_TRUE);
    1.18  }
    1.19  
    1.20  void
    1.21 @@ -841,10 +841,68 @@
    1.22  void
    1.23  X11_RestoreWindow(_THIS, SDL_Window * window)
    1.24  {
    1.25 -    X11_SetWindowMaximized(_this, window, SDL_FALSE);
    1.26 +    SetWindowMaximized(_this, window, SDL_FALSE);
    1.27      X11_ShowWindow(_this, window);
    1.28  }
    1.29  
    1.30 +static void
    1.31 +SetWindowFullscreen(_THIS, SDL_Window * window, SDL_bool fullscreen)
    1.32 +{
    1.33 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.34 +    SDL_DisplayData *displaydata =
    1.35 +        (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
    1.36 +    Display *display = data->videodata->display;
    1.37 +    Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
    1.38 +    Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
    1.39 +    Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
    1.40 +    Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN;
    1.41 +
    1.42 +    if (X11_IsWindowMapped(_this, window)) {
    1.43 +        XEvent e;
    1.44 +
    1.45 +        SDL_zero(e);
    1.46 +        e.xany.type = ClientMessage;
    1.47 +        e.xclient.message_type = _NET_WM_STATE;
    1.48 +        e.xclient.format = 32;
    1.49 +        e.xclient.window = data->xwindow;
    1.50 +        e.xclient.data.l[0] =
    1.51 +            fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
    1.52 +        e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
    1.53 +        e.xclient.data.l[3] = 0l;
    1.54 +
    1.55 +        XSendEvent(display, RootWindow(display, displaydata->screen), 0,
    1.56 +                   SubstructureNotifyMask | SubstructureRedirectMask, &e);
    1.57 +    } else {
    1.58 +        int count = 0;
    1.59 +        Atom atoms[3];
    1.60 +
    1.61 +        if (fullscreen) {
    1.62 +            atoms[count++] = _NET_WM_STATE_FULLSCREEN;
    1.63 +        }
    1.64 +        if (window->flags & SDL_WINDOW_MAXIMIZED) {
    1.65 +            atoms[count++] = _NET_WM_STATE_MAXIMIZED_VERT;
    1.66 +            atoms[count++] = _NET_WM_STATE_MAXIMIZED_HORZ;
    1.67 +        }
    1.68 +        if (count > 0) {
    1.69 +            XChangeProperty(display, data->xwindow, _NET_WM_STATE, XA_ATOM, 32,
    1.70 +                            PropModeReplace, (unsigned char *)atoms, count);
    1.71 +        } else {
    1.72 +            XDeleteProperty(display, data->xwindow, _NET_WM_STATE);
    1.73 +        }
    1.74 +    }
    1.75 +    XFlush(display);
    1.76 +}
    1.77 +
    1.78 +void
    1.79 +X11_SetWindowFullscreen(_THIS, SDL_Window * window)
    1.80 +{
    1.81 +    if (FULLSCREEN_VISIBLE(window)) {
    1.82 +        SetWindowFullscreen(_this, window, SDL_TRUE);
    1.83 +    } else {
    1.84 +        SetWindowFullscreen(_this, window, SDL_FALSE);
    1.85 +    }
    1.86 +}
    1.87 +
    1.88  void
    1.89  X11_SetWindowGrab(_THIS, SDL_Window * window)
    1.90  {