Some fixes for SDL_MaximizeWindow().
authorRyan C. Gordon <icculus@icculus.org>
Sat, 03 Aug 2013 02:20:00 -0400
changeset 7566 b14d00c30095
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
--- a/src/video/SDL_video.c	Fri Aug 02 18:25:20 2013 -0400
+++ b/src/video/SDL_video.c	Sat Aug 03 02:20:00 2013 -0400
@@ -1756,6 +1756,8 @@
         return;
     }
 
+    // !!! FIXME: should this check if the window is resizable?
+
     if (_this->MaximizeWindow) {
         _this->MaximizeWindow(_this, window);
     }
--- a/src/video/cocoa/SDL_cocoawindow.m	Fri Aug 02 18:25:20 2013 -0400
+++ b/src/video/cocoa/SDL_cocoawindow.m	Sat Aug 03 02:20:00 2013 -0400
@@ -239,6 +239,13 @@
        or resizing from a corner */
     SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MOVED, x, y);
     SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
+
+    const BOOL zoomed = [_data->nswindow isZoomed];
+    if (!zoomed) {
+        SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESTORED, 0, 0);
+    } else if (zoomed) {
+        SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
+    }
 }
 
 - (void)windowDidMiniaturize:(NSNotification *)aNotification
--- a/src/video/x11/SDL_x11window.c	Fri Aug 02 18:25:20 2013 -0400
+++ b/src/video/x11/SDL_x11window.c	Sat Aug 03 02:20:00 2013 -0400
@@ -878,6 +878,12 @@
     Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
     Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
 
+    if (maximized) {
+        window->flags |= SDL_WINDOW_MAXIMIZED;
+    } else {
+        window->flags &= ~SDL_WINDOW_MAXIMIZED;
+    }
+
     if (X11_IsWindowMapped(_this, window)) {
         XEvent e;
 
@@ -895,15 +901,7 @@
         XSendEvent(display, RootWindow(display, displaydata->screen), 0,
                    SubstructureNotifyMask | SubstructureRedirectMask, &e);
     } else {
-        Uint32 flags;
-
-        flags = window->flags;
-        if (maximized) {
-            flags |= SDL_WINDOW_MAXIMIZED;
-        } else {
-            flags &= ~SDL_WINDOW_MAXIMIZED;
-        }
-        X11_SetNetWMState(_this, data->xwindow, flags);
+        X11_SetNetWMState(_this, data->xwindow, window->flags);
     }
     XFlush(display);
 }