comparison src/video/cocoa/SDL_cocoawindow.m @ 3508:a12068b6f44f

Fixed mouse coordinates for fullscreen mode
author Sam Lantinga <slouken@libsdl.org>
date Wed, 02 Dec 2009 06:10:18 +0000
parents 3712547eac4f
children 8fde6aeb58df
comparison
equal deleted inserted replaced
3507:3712547eac4f 3508:a12068b6f44f
230 { 230 {
231 SDL_Window *window = SDL_GetWindowFromID(_data->windowID); 231 SDL_Window *window = SDL_GetWindowFromID(_data->windowID);
232 int index; 232 int index;
233 SDL_Mouse *mouse; 233 SDL_Mouse *mouse;
234 NSPoint point; 234 NSPoint point;
235 NSRect rect;
236 235
237 index = _data->videodata->mouse; 236 index = _data->videodata->mouse;
238 mouse = SDL_GetMouse(index); 237 mouse = SDL_GetMouse(index);
239 238
240 point = [NSEvent mouseLocation]; 239 point = [NSEvent mouseLocation];
241 if ( (window->flags & SDL_WINDOW_FULLSCREEN) ) { 240 if ( (window->flags & SDL_WINDOW_FULLSCREEN) ) {
242 rect.size.width = CGDisplayPixelsWide(kCGDirectMainDisplay); 241 NSRect rect = CGDisplayBounds(_data->display);
243 rect.size.height = CGDisplayPixelsHigh(kCGDirectMainDisplay); 242
244 point.x = point.x - rect.origin.x; 243 point.x = point.x - rect.origin.x;
245 point.y = rect.size.height - point.y; 244 point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - rect.origin.y;
246 } else { 245 } else {
247 point.x -= window->x; 246 point.x -= window->x;
248 point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - window->y; 247 point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - window->y;
249 } 248 }
250 if ( point.x < 0 || point.x >= window->w || 249 if ( point.x < 0 || point.x >= window->w ||