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.
authorSam Lantinga <slouken@libsdl.org>
Fri, 11 Feb 2011 20:49:13 -0800
changeset 5261595814f561f7
parent 5260 62d2bc792002
child 5262 b530ef003506
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.
src/events/SDL_windowevents.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/events/SDL_windowevents.c	Fri Feb 11 19:11:27 2011 -0800
     1.2 +++ b/src/events/SDL_windowevents.c	Fri Feb 11 20:49:13 2011 -0800
     1.3 @@ -86,43 +86,19 @@
     1.4              SDL_WINDOWPOS_ISUNDEFINED(data2)) {
     1.5              return 0;
     1.6          }
     1.7 -        if (window->flags & SDL_WINDOW_FULLSCREEN) {
     1.8 -            window->fullscreen.x = data1;
     1.9 -            window->fullscreen.y = data1;
    1.10 -        } else {
    1.11 -            window->windowed.x = data1;
    1.12 -            window->windowed.y = data1;
    1.13 -        }
    1.14          if (data1 == window->x && data2 == window->y) {
    1.15              return 0;
    1.16          }
    1.17          window->x = data1;
    1.18          window->y = data2;
    1.19 -
    1.20 -        if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.21 -            /* Do we really want to do this? */
    1.22 -            return 0;
    1.23 -        }
    1.24          break;
    1.25      case SDL_WINDOWEVENT_RESIZED:
    1.26 -        if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.27 -            window->fullscreen.w = data1;
    1.28 -            window->fullscreen.h = data1;
    1.29 -        } else {
    1.30 -            window->windowed.w = data1;
    1.31 -            window->windowed.h = data1;
    1.32 -        }
    1.33          if (data1 == window->w && data2 == window->h) {
    1.34              return 0;
    1.35          }
    1.36          window->w = data1;
    1.37          window->h = data2;
    1.38          SDL_OnWindowResized(window);
    1.39 -
    1.40 -        if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.41 -            /* Do we really want to do this? */
    1.42 -            return 0;
    1.43 -        }
    1.44          break;
    1.45      case SDL_WINDOWEVENT_MINIMIZED:
    1.46          if (window->flags & SDL_WINDOW_MINIMIZED) {
     2.1 --- a/src/video/SDL_sysvideo.h	Fri Feb 11 19:11:27 2011 -0800
     2.2 +++ b/src/video/SDL_sysvideo.h	Fri Feb 11 20:49:13 2011 -0800
     2.3 @@ -72,20 +72,6 @@
     2.4      const void *magic;
     2.5      Uint32 id;
     2.6      char *title;
     2.7 -
     2.8 -    /* The fullscreen values */
     2.9 -    struct {
    2.10 -        int x, y;
    2.11 -        int w, h;
    2.12 -    } fullscreen;
    2.13 -
    2.14 -    /* The windowed values */
    2.15 -    struct {
    2.16 -        int x, y;
    2.17 -        int w, h;
    2.18 -    } windowed;
    2.19 -
    2.20 -    /* The public values */
    2.21      int x, y;
    2.22      int w, h;
    2.23      Uint32 flags;
     3.1 --- a/src/video/SDL_video.c	Fri Feb 11 19:11:27 2011 -0800
     3.2 +++ b/src/video/SDL_video.c	Fri Feb 11 20:49:13 2011 -0800
     3.3 @@ -1082,10 +1082,6 @@
     3.4          _this->SetWindowFullscreen(_this, window);
     3.5      }
     3.6      display->fullscreen_window = NULL;
     3.7 -
     3.8 -    /* Generate a mode change events here */
     3.9 -    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED,
    3.10 -                        window->windowed.w, window->windowed.h);
    3.11  }
    3.12  
    3.13  SDL_Window *
     4.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Fri Feb 11 19:11:27 2011 -0800
     4.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Feb 11 20:49:13 2011 -0800
     4.3 @@ -333,8 +333,8 @@
     4.4          SDL_FingerID fingerId = (SDL_FingerID)[touch identity];
     4.5          float x = [touch normalizedPosition].x;
     4.6          float y = [touch normalizedPosition].y;
     4.7 -	/* Make the origin the upper left instead of the lower left */
     4.8 -	y = 1.0f - y;
     4.9 +        /* Make the origin the upper left instead of the lower left */
    4.10 +        y = 1.0f - y;
    4.11  
    4.12          switch (type) {
    4.13          case COCOA_TOUCH_DOWN:
    4.14 @@ -450,10 +450,10 @@
    4.15          [contentView release];
    4.16  
    4.17          ConvertNSRect(&rect);
    4.18 -        window->fullscreen.x = window->windowed.x = window->x = (int)rect.origin.x;
    4.19 -        window->fullscreen.y = window->windowed.y = window->y = (int)rect.origin.y;
    4.20 -        window->fullscreen.w = window->windowed.w = window->w = (int)rect.size.width;
    4.21 -        window->fullscreen.h = window->windowed.h = window->h = (int)rect.size.height;
    4.22 +        window->x = (int)rect.origin.x;
    4.23 +        window->y = (int)rect.origin.y;
    4.24 +        window->w = (int)rect.size.width;
    4.25 +        window->h = (int)rect.size.height;
    4.26      }
    4.27      if ([nswindow isVisible]) {
    4.28          window->flags |= SDL_WINDOW_SHOWN;
    4.29 @@ -709,11 +709,10 @@
    4.30      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    4.31      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    4.32      NSWindow *nswindow = data->nswindow;
    4.33 -    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    4.34      NSRect rect;
    4.35 -    unsigned int style;
    4.36  
    4.37      if (FULLSCREEN_VISIBLE(window)) {
    4.38 +        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    4.39          SDL_Rect bounds;
    4.40  
    4.41          Cocoa_GetDisplayBounds(_this, display, &bounds);
    4.42 @@ -723,23 +722,16 @@
    4.43          rect.size.height = bounds.h;
    4.44          ConvertNSRect(&rect);
    4.45  
    4.46 -        style = NSBorderlessWindowMask;
    4.47 +        [nswindow setStyleMask:NSBorderlessWindowMask];
    4.48 +        [nswindow setContentSize:rect.size];
    4.49 +        [nswindow setFrameOrigin:rect.origin];
    4.50      } else {
    4.51 -        rect.origin.x = window->windowed.x;
    4.52 -        rect.origin.y = window->windowed.y;
    4.53 -        rect.size.width = window->windowed.w;
    4.54 -        rect.size.height = window->windowed.h;
    4.55 -        /* FIXME: This calculation is wrong, we're changing the origin */
    4.56 -        ConvertNSRect(&rect);
    4.57 +        [nswindow setStyleMask:GetStyleMask(window)];
    4.58  
    4.59 -        style = GetStyleMask(window);
    4.60 +        // This doesn't seem to do anything...
    4.61 +        //[nswindow setFrameOrigin:origin];
    4.62      }
    4.63  
    4.64 -    [nswindow setStyleMask:style];
    4.65 -    [nswindow setContentSize:rect.size];
    4.66 -    rect = [nswindow frameRectForContentRect:rect];
    4.67 -    [nswindow setFrameOrigin:rect.origin];
    4.68 -
    4.69  #ifdef FULLSCREEN_TOGGLEABLE
    4.70      if (FULLSCREEN_VISIBLE(window)) {
    4.71          /* OpenGL is rendering to the window, so make it visible! */