From b5ca42e880753304f2a84ff9b23e03ef88442574 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 22 Oct 2009 04:46:11 +0000 Subject: [PATCH] Adam Strzelecki to SDL Sending a patch for fullscreen Mac OS X SDL 1.3 (SVN) Cocoa mouse position handling. In fullscreen mouse coordinates should be relative to SCREEN not to the window, which doesn't really occupy fullscreen. Without this patch mouse position (especially Y) was totally incorrect (shifted) in fullscreen. --- src/video/cocoa/SDL_cocoawindow.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 8e18a0a6f..a53f6dd82 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -239,6 +239,15 @@ static __inline__ void ConvertNSRect(NSRect *r) mouse = SDL_GetMouse(index); point = [NSEvent mouseLocation]; + if ( (window->flags & SDL_WINDOW_FULLSCREEN) ) { + rect.size.width = CGDisplayPixelsWide(kCGDirectMainDisplay); + rect.size.height = CGDisplayPixelsHigh(kCGDirectMainDisplay); + point.y = rect.size.height - point.y; + } else { + rect = [_data->window contentRectForFrameRect:[_data->window frame]]; + point.x = point.x - rect.origin.x; + point.y = rect.size.height - (point.y - rect.origin.y); + } point.x = point.x - rect.origin.x; point.y = rect.size.height - (point.y - rect.origin.y); if ( point.x < 0 || point.x >= rect.size.width ||