Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1372 - OSX Window Maximize/Resize Doesn't Update Window Pos…
Browse files Browse the repository at this point in the history
…ition

Alex Nankervis 2012-01-15 14:20:01 PST

SDL_cocoawindow.m, windowDidResize needs to also send a window move event.
Depending on the corner you resize a window from, or when maximizing a window,
the window position will change. Discovered this when creating a maximized
window and found that the window position was stuck at the un-maximized
window's value.

Diff with fix attached.
  • Loading branch information
slouken committed Jan 19, 2012
1 parent c5fd9de commit 972b4ce
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -153,8 +153,11 @@ - (void)windowDidMove:(NSNotification *)aNotification
- (void)windowDidResize:(NSNotification *)aNotification
{
SDL_VideoDevice *device = SDL_GetVideoDevice();
int w, h;
int x, y, w, h;
NSRect rect = [_data->nswindow contentRectForFrameRect:[_data->nswindow frame]];
ConvertNSRect(&rect);
x = (int)rect.origin.x;
y = (int)rect.origin.y;
w = (int)rect.size.width;
h = (int)rect.size.height;
if (SDL_IsShapedWindow(_data->window))
Expand All @@ -164,6 +167,9 @@ - (void)windowDidResize:(NSNotification *)aNotification
[((NSOpenGLContext *) device->current_glctx) update];
}

/* The window can move during a resize event, such as when maximizing
or resizing from a corner */
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MOVED, x, y);
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
}

Expand Down

0 comments on commit 972b4ce

Please sign in to comment.