Mercurial > sdl-ios-xcode
diff src/video/cocoa/SDL_cocoawindow.m @ 4465:3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Plus, this lets me start implementing cursor support.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 09 May 2010 20:47:22 -0700 |
parents | 6512cba48440 |
children | 9322f7db8603 |
line wrap: on
line diff
--- a/src/video/cocoa/SDL_cocoawindow.m Sun May 09 19:55:28 2010 -0700 +++ b/src/video/cocoa/SDL_cocoawindow.m Sun May 09 20:47:22 2010 -0700 @@ -126,28 +126,21 @@ - (void)windowDidBecomeKey:(NSNotification *)aNotification { - int index; - /* We're going to get keyboard events, since we're key. */ - index = _data->videodata->keyboard; - SDL_SetKeyboardFocus(index, _data->window); + SDL_SetKeyboardFocus(_data->window); } - (void)windowDidResignKey:(NSNotification *)aNotification { - int index; - SDL_Mouse *mouse; - /* Some other window will get mouse events, since we're not key. */ - index = _data->videodata->mouse; - mouse = SDL_GetMouse(index); - if (mouse->focus == _data->window) { - SDL_SetMouseFocus(index, 0); + if (SDL_GetMouseFocus() == _data->window) { + SDL_SetMouseFocus(NULL); } /* Some other window will get keyboard events, since we're not key. */ - index = _data->videodata->keyboard; - SDL_SetKeyboardFocus(index, 0); + if (SDL_GetKeyboardFocus() == _data->window) { + SDL_SetKeyboardFocus(NULL); + } } - (void)windowDidHide:(NSNotification *)aNotification @@ -162,10 +155,8 @@ - (void)mouseDown:(NSEvent *)theEvent { - int index; int button; - index = _data->videodata->mouse; switch ([theEvent buttonNumber]) { case 0: button = SDL_BUTTON_LEFT; @@ -180,7 +171,7 @@ button = [theEvent buttonNumber]; break; } - SDL_SendMouseButton(index, SDL_PRESSED, button); + SDL_SendMouseButton(SDL_PRESSED, button); } - (void)rightMouseDown:(NSEvent *)theEvent @@ -195,10 +186,8 @@ - (void)mouseUp:(NSEvent *)theEvent { - int index; int button; - index = _data->videodata->mouse; switch ([theEvent buttonNumber]) { case 0: button = SDL_BUTTON_LEFT; @@ -213,7 +202,7 @@ button = [theEvent buttonNumber]; break; } - SDL_SendMouseButton(index, SDL_RELEASED, button); + SDL_SendMouseButton(SDL_RELEASED, button); } - (void)rightMouseUp:(NSEvent *)theEvent @@ -229,24 +218,18 @@ - (void)mouseMoved:(NSEvent *)theEvent { SDL_Window *window = _data->window; - int index; - SDL_Mouse *mouse; NSPoint point; - index = _data->videodata->mouse; - mouse = SDL_GetMouse(index); point = [theEvent locationInWindow]; point.y = window->h - point.y; if ( point.x < 0 || point.x >= window->w || point.y < 0 || point.y >= window->h ) { - if (mouse->focus != 0) { - SDL_SetMouseFocus(index, 0); + if (SDL_GetMouseFocus() == window) { + SDL_SetMouseFocus(NULL); } } else { - if (mouse->focus != _data->window) { - SDL_SetMouseFocus(index, _data->window); - } - SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y, 0); + SDL_SetMouseFocus(_data->window); + SDL_SendMouseMotion(0, (int)point.x, (int)point.y); } } @@ -267,10 +250,7 @@ - (void)scrollWheel:(NSEvent *)theEvent { - int index; - - index = _data->videodata->mouse; - SDL_SendMouseWheel(index, (int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f)); + SDL_SendMouseWheel((int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f)); } @end @@ -361,9 +341,8 @@ window->flags &= ~SDL_WINDOW_MINIMIZED; } if ([nswindow isKeyWindow]) { - int index = data->videodata->keyboard; window->flags |= SDL_WINDOW_INPUT_FOCUS; - SDL_SetKeyboardFocus(index, data->window); + SDL_SetKeyboardFocus(data->window); if (window->flags & SDL_WINDOW_INPUT_GRABBED) { /* FIXME */ @@ -385,8 +364,6 @@ NSRect rect; SDL_Rect bounds; unsigned int style; - NSString *title; - int status; Cocoa_GetDisplayBounds(_this, display, &bounds); if ((window->flags & SDL_WINDOW_FULLSCREEN) @@ -452,7 +429,6 @@ NSAutoreleasePool *pool; NSWindow *nswindow = (NSWindow *) data; NSString *title; - int status; pool = [[NSAutoreleasePool alloc] init]; @@ -625,7 +601,7 @@ SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) { - NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; + //NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; if (info->version.major <= SDL_MAJOR_VERSION) { //info->window = nswindow;