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

Commit

Permalink
Fixed bug 1105 (SDL_GetMouseState returns wrong location upon window …
Browse files Browse the repository at this point in the history
…re-activation)
  • Loading branch information
slouken committed Feb 21, 2011
1 parent 5e5bac6 commit 9ca9183
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -135,8 +135,20 @@ - (void)windowDidDeminiaturize:(NSNotification *)aNotification

- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;

/* We're going to get keyboard events, since we're key. */
SDL_SetKeyboardFocus(_data->window);
SDL_SetKeyboardFocus(window);

/* If we just gained focus we need the updated mouse position */
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
NSPoint point;
point = [NSEvent mouseLocation];
point = [_data->nswindow convertScreenToBase:point];
point = [[_data->nswindow contentView] convertPoint:point fromView:nil];
point.y = window->h - point.y;
SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y);
}

/* Check to see if someone updated the clipboard */
Cocoa_CheckClipboardUpdate(_data->videodata);
Expand Down

0 comments on commit 9ca9183

Please sign in to comment.