changeset 5266:595814f561f7

There is only one width and height for the window. If those are changed during the course of a fullscreen mode change, then they'll stay that size when returning to windowed mode.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 11 Feb 2011 20:49:13 -0800
parents 62d2bc792002
children b530ef003506
files src/events/SDL_windowevents.c src/video/SDL_sysvideo.h src/video/SDL_video.c src/video/cocoa/SDL_cocoawindow.m
diffstat 4 files changed, 13 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/src/events/SDL_windowevents.c	Fri Feb 11 19:11:27 2011 -0800
+++ b/src/events/SDL_windowevents.c	Fri Feb 11 20:49:13 2011 -0800
@@ -86,43 +86,19 @@
             SDL_WINDOWPOS_ISUNDEFINED(data2)) {
             return 0;
         }
-        if (window->flags & SDL_WINDOW_FULLSCREEN) {
-            window->fullscreen.x = data1;
-            window->fullscreen.y = data1;
-        } else {
-            window->windowed.x = data1;
-            window->windowed.y = data1;
-        }
         if (data1 == window->x && data2 == window->y) {
             return 0;
         }
         window->x = data1;
         window->y = data2;
-
-        if (window->flags & SDL_WINDOW_FULLSCREEN) {
-            /* Do we really want to do this? */
-            return 0;
-        }
         break;
     case SDL_WINDOWEVENT_RESIZED:
-        if (window->flags & SDL_WINDOW_FULLSCREEN) {
-            window->fullscreen.w = data1;
-            window->fullscreen.h = data1;
-        } else {
-            window->windowed.w = data1;
-            window->windowed.h = data1;
-        }
         if (data1 == window->w && data2 == window->h) {
             return 0;
         }
         window->w = data1;
         window->h = data2;
         SDL_OnWindowResized(window);
-
-        if (window->flags & SDL_WINDOW_FULLSCREEN) {
-            /* Do we really want to do this? */
-            return 0;
-        }
         break;
     case SDL_WINDOWEVENT_MINIMIZED:
         if (window->flags & SDL_WINDOW_MINIMIZED) {
--- a/src/video/SDL_sysvideo.h	Fri Feb 11 19:11:27 2011 -0800
+++ b/src/video/SDL_sysvideo.h	Fri Feb 11 20:49:13 2011 -0800
@@ -72,20 +72,6 @@
     const void *magic;
     Uint32 id;
     char *title;
-
-    /* The fullscreen values */
-    struct {
-        int x, y;
-        int w, h;
-    } fullscreen;
-
-    /* The windowed values */
-    struct {
-        int x, y;
-        int w, h;
-    } windowed;
-
-    /* The public values */
     int x, y;
     int w, h;
     Uint32 flags;
--- a/src/video/SDL_video.c	Fri Feb 11 19:11:27 2011 -0800
+++ b/src/video/SDL_video.c	Fri Feb 11 20:49:13 2011 -0800
@@ -1082,10 +1082,6 @@
         _this->SetWindowFullscreen(_this, window);
     }
     display->fullscreen_window = NULL;
-
-    /* Generate a mode change events here */
-    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED,
-                        window->windowed.w, window->windowed.h);
 }
 
 SDL_Window *
--- a/src/video/cocoa/SDL_cocoawindow.m	Fri Feb 11 19:11:27 2011 -0800
+++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Feb 11 20:49:13 2011 -0800
@@ -333,8 +333,8 @@
         SDL_FingerID fingerId = (SDL_FingerID)[touch identity];
         float x = [touch normalizedPosition].x;
         float y = [touch normalizedPosition].y;
-	/* Make the origin the upper left instead of the lower left */
-	y = 1.0f - y;
+        /* Make the origin the upper left instead of the lower left */
+        y = 1.0f - y;
 
         switch (type) {
         case COCOA_TOUCH_DOWN:
@@ -450,10 +450,10 @@
         [contentView release];
 
         ConvertNSRect(&rect);
-        window->fullscreen.x = window->windowed.x = window->x = (int)rect.origin.x;
-        window->fullscreen.y = window->windowed.y = window->y = (int)rect.origin.y;
-        window->fullscreen.w = window->windowed.w = window->w = (int)rect.size.width;
-        window->fullscreen.h = window->windowed.h = window->h = (int)rect.size.height;
+        window->x = (int)rect.origin.x;
+        window->y = (int)rect.origin.y;
+        window->w = (int)rect.size.width;
+        window->h = (int)rect.size.height;
     }
     if ([nswindow isVisible]) {
         window->flags |= SDL_WINDOW_SHOWN;
@@ -709,11 +709,10 @@
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     NSWindow *nswindow = data->nswindow;
-    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
     NSRect rect;
-    unsigned int style;
 
     if (FULLSCREEN_VISIBLE(window)) {
+        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
         SDL_Rect bounds;
 
         Cocoa_GetDisplayBounds(_this, display, &bounds);
@@ -723,23 +722,16 @@
         rect.size.height = bounds.h;
         ConvertNSRect(&rect);
 
-        style = NSBorderlessWindowMask;
+        [nswindow setStyleMask:NSBorderlessWindowMask];
+        [nswindow setContentSize:rect.size];
+        [nswindow setFrameOrigin:rect.origin];
     } else {
-        rect.origin.x = window->windowed.x;
-        rect.origin.y = window->windowed.y;
-        rect.size.width = window->windowed.w;
-        rect.size.height = window->windowed.h;
-        /* FIXME: This calculation is wrong, we're changing the origin */
-        ConvertNSRect(&rect);
+        [nswindow setStyleMask:GetStyleMask(window)];
 
-        style = GetStyleMask(window);
+        // This doesn't seem to do anything...
+        //[nswindow setFrameOrigin:origin];
     }
 
-    [nswindow setStyleMask:style];
-    [nswindow setContentSize:rect.size];
-    rect = [nswindow frameRectForContentRect:rect];
-    [nswindow setFrameOrigin:rect.origin];
-
 #ifdef FULLSCREEN_TOGGLEABLE
     if (FULLSCREEN_VISIBLE(window)) {
         /* OpenGL is rendering to the window, so make it visible! */