Some fixes for SDL_MaximizeWindow().
authorRyan C. Gordon <icculus@icculus.org>
Sat, 03 Aug 2013 02:20:00 -0400
changeset 7566b14d00c30095
parent 7565 3d97fc52d294
child 7567 52da75545aaa
Some fixes for SDL_MaximizeWindow().

Fixes Bugzilla #1441.
src/video/SDL_video.c
src/video/cocoa/SDL_cocoawindow.m
src/video/x11/SDL_x11window.c
     1.1 --- a/src/video/SDL_video.c	Fri Aug 02 18:25:20 2013 -0400
     1.2 +++ b/src/video/SDL_video.c	Sat Aug 03 02:20:00 2013 -0400
     1.3 @@ -1756,6 +1756,8 @@
     1.4          return;
     1.5      }
     1.6  
     1.7 +    // !!! FIXME: should this check if the window is resizable?
     1.8 +
     1.9      if (_this->MaximizeWindow) {
    1.10          _this->MaximizeWindow(_this, window);
    1.11      }
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Fri Aug 02 18:25:20 2013 -0400
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sat Aug 03 02:20:00 2013 -0400
     2.3 @@ -239,6 +239,13 @@
     2.4         or resizing from a corner */
     2.5      SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MOVED, x, y);
     2.6      SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
     2.7 +
     2.8 +    const BOOL zoomed = [_data->nswindow isZoomed];
     2.9 +    if (!zoomed) {
    2.10 +        SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESTORED, 0, 0);
    2.11 +    } else if (zoomed) {
    2.12 +        SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
    2.13 +    }
    2.14  }
    2.15  
    2.16  - (void)windowDidMiniaturize:(NSNotification *)aNotification
     3.1 --- a/src/video/x11/SDL_x11window.c	Fri Aug 02 18:25:20 2013 -0400
     3.2 +++ b/src/video/x11/SDL_x11window.c	Sat Aug 03 02:20:00 2013 -0400
     3.3 @@ -878,6 +878,12 @@
     3.4      Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
     3.5      Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
     3.6  
     3.7 +    if (maximized) {
     3.8 +        window->flags |= SDL_WINDOW_MAXIMIZED;
     3.9 +    } else {
    3.10 +        window->flags &= ~SDL_WINDOW_MAXIMIZED;
    3.11 +    }
    3.12 +
    3.13      if (X11_IsWindowMapped(_this, window)) {
    3.14          XEvent e;
    3.15  
    3.16 @@ -895,15 +901,7 @@
    3.17          XSendEvent(display, RootWindow(display, displaydata->screen), 0,
    3.18                     SubstructureNotifyMask | SubstructureRedirectMask, &e);
    3.19      } else {
    3.20 -        Uint32 flags;
    3.21 -
    3.22 -        flags = window->flags;
    3.23 -        if (maximized) {
    3.24 -            flags |= SDL_WINDOW_MAXIMIZED;
    3.25 -        } else {
    3.26 -            flags &= ~SDL_WINDOW_MAXIMIZED;
    3.27 -        }
    3.28 -        X11_SetNetWMState(_this, data->xwindow, flags);
    3.29 +        X11_SetNetWMState(_this, data->xwindow, window->flags);
    3.30      }
    3.31      XFlush(display);
    3.32  }