From 487c8fb763865c30afa2227b2cf18e979f2ba393 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 11 Feb 2011 20:49:13 -0800 Subject: [PATCH] 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 | 24 ---------------------- src/video/SDL_sysvideo.h | 14 ------------- src/video/SDL_video.c | 4 ---- src/video/cocoa/SDL_cocoawindow.m | 34 ++++++++++++------------------- 4 files changed, 13 insertions(+), 63 deletions(-) diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index 22ec79454..fe818f0fe 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -86,43 +86,19 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, 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) { diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 95e39b0c0..daae1411a 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -72,20 +72,6 @@ struct SDL_Window 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; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 7cef5128f..94c15c011 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1082,10 +1082,6 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt) _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 * diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 3f63ee5e2..3678279a3 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -333,8 +333,8 @@ - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event 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 @@ - (void)rightMouseDown:(NSEvent *)theEvent [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 @@ - (void)rightMouseDown:(NSEvent *)theEvent 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 @@ - (void)rightMouseDown:(NSEvent *)theEvent 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! */