src/video/cocoa/SDL_cocoawindow.m
changeset 4465 3e69e077cb95
parent 3688 6512cba48440
child 4484 9322f7db8603
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sun May 09 19:55:28 2010 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun May 09 20:47:22 2010 -0700
     1.3 @@ -126,28 +126,21 @@
     1.4  
     1.5  - (void)windowDidBecomeKey:(NSNotification *)aNotification
     1.6  {
     1.7 -    int index;
     1.8 -
     1.9      /* We're going to get keyboard events, since we're key. */
    1.10 -    index = _data->videodata->keyboard;
    1.11 -    SDL_SetKeyboardFocus(index, _data->window);
    1.12 +    SDL_SetKeyboardFocus(_data->window);
    1.13  }
    1.14  
    1.15  - (void)windowDidResignKey:(NSNotification *)aNotification
    1.16  {
    1.17 -    int index;
    1.18 -    SDL_Mouse *mouse;
    1.19 -
    1.20      /* Some other window will get mouse events, since we're not key. */
    1.21 -    index = _data->videodata->mouse;
    1.22 -    mouse = SDL_GetMouse(index);
    1.23 -    if (mouse->focus == _data->window) {
    1.24 -        SDL_SetMouseFocus(index, 0);
    1.25 +    if (SDL_GetMouseFocus() == _data->window) {
    1.26 +        SDL_SetMouseFocus(NULL);
    1.27      }
    1.28  
    1.29      /* Some other window will get keyboard events, since we're not key. */
    1.30 -    index = _data->videodata->keyboard;
    1.31 -    SDL_SetKeyboardFocus(index, 0);
    1.32 +    if (SDL_GetKeyboardFocus() == _data->window) {
    1.33 +        SDL_SetKeyboardFocus(NULL);
    1.34 +    }
    1.35  }
    1.36  
    1.37  - (void)windowDidHide:(NSNotification *)aNotification
    1.38 @@ -162,10 +155,8 @@
    1.39  
    1.40  - (void)mouseDown:(NSEvent *)theEvent
    1.41  {
    1.42 -    int index;
    1.43      int button;
    1.44  
    1.45 -    index = _data->videodata->mouse;
    1.46      switch ([theEvent buttonNumber]) {
    1.47      case 0:
    1.48          button = SDL_BUTTON_LEFT;
    1.49 @@ -180,7 +171,7 @@
    1.50          button = [theEvent buttonNumber];
    1.51          break;
    1.52      }
    1.53 -    SDL_SendMouseButton(index, SDL_PRESSED, button);
    1.54 +    SDL_SendMouseButton(SDL_PRESSED, button);
    1.55  }
    1.56  
    1.57  - (void)rightMouseDown:(NSEvent *)theEvent
    1.58 @@ -195,10 +186,8 @@
    1.59  
    1.60  - (void)mouseUp:(NSEvent *)theEvent
    1.61  {
    1.62 -    int index;
    1.63      int button;
    1.64  
    1.65 -    index = _data->videodata->mouse;
    1.66      switch ([theEvent buttonNumber]) {
    1.67      case 0:
    1.68          button = SDL_BUTTON_LEFT;
    1.69 @@ -213,7 +202,7 @@
    1.70          button = [theEvent buttonNumber];
    1.71          break;
    1.72      }
    1.73 -    SDL_SendMouseButton(index, SDL_RELEASED, button);
    1.74 +    SDL_SendMouseButton(SDL_RELEASED, button);
    1.75  }
    1.76  
    1.77  - (void)rightMouseUp:(NSEvent *)theEvent
    1.78 @@ -229,24 +218,18 @@
    1.79  - (void)mouseMoved:(NSEvent *)theEvent
    1.80  {
    1.81      SDL_Window *window = _data->window;
    1.82 -    int index;
    1.83 -    SDL_Mouse *mouse;
    1.84      NSPoint point;
    1.85  
    1.86 -    index = _data->videodata->mouse;
    1.87 -    mouse = SDL_GetMouse(index);
    1.88      point = [theEvent locationInWindow];
    1.89      point.y = window->h - point.y;
    1.90      if ( point.x < 0 || point.x >= window->w ||
    1.91           point.y < 0 || point.y >= window->h ) {
    1.92 -        if (mouse->focus != 0) {
    1.93 -            SDL_SetMouseFocus(index, 0);
    1.94 +        if (SDL_GetMouseFocus() == window) {
    1.95 +            SDL_SetMouseFocus(NULL);
    1.96          }
    1.97      } else {
    1.98 -        if (mouse->focus != _data->window) {
    1.99 -            SDL_SetMouseFocus(index, _data->window);
   1.100 -        }
   1.101 -        SDL_SendMouseMotion(index, 0, (int)point.x, (int)point.y, 0);
   1.102 +        SDL_SetMouseFocus(_data->window);
   1.103 +        SDL_SendMouseMotion(0, (int)point.x, (int)point.y);
   1.104      }
   1.105  }
   1.106  
   1.107 @@ -267,10 +250,7 @@
   1.108  
   1.109  - (void)scrollWheel:(NSEvent *)theEvent
   1.110  {
   1.111 -    int index;
   1.112 -
   1.113 -    index = _data->videodata->mouse;
   1.114 -    SDL_SendMouseWheel(index, (int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f));
   1.115 +    SDL_SendMouseWheel((int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f));
   1.116  }
   1.117  
   1.118  @end
   1.119 @@ -361,9 +341,8 @@
   1.120          window->flags &= ~SDL_WINDOW_MINIMIZED;
   1.121      }
   1.122      if ([nswindow isKeyWindow]) {
   1.123 -        int index = data->videodata->keyboard;
   1.124          window->flags |= SDL_WINDOW_INPUT_FOCUS;
   1.125 -        SDL_SetKeyboardFocus(index, data->window);
   1.126 +        SDL_SetKeyboardFocus(data->window);
   1.127  
   1.128          if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
   1.129              /* FIXME */
   1.130 @@ -385,8 +364,6 @@
   1.131      NSRect rect;
   1.132      SDL_Rect bounds;
   1.133      unsigned int style;
   1.134 -    NSString *title;
   1.135 -    int status;
   1.136  
   1.137      Cocoa_GetDisplayBounds(_this, display, &bounds);
   1.138      if ((window->flags & SDL_WINDOW_FULLSCREEN)
   1.139 @@ -452,7 +429,6 @@
   1.140      NSAutoreleasePool *pool;
   1.141      NSWindow *nswindow = (NSWindow *) data;
   1.142      NSString *title;
   1.143 -    int status;
   1.144  
   1.145      pool = [[NSAutoreleasePool alloc] init];
   1.146  
   1.147 @@ -625,7 +601,7 @@
   1.148  SDL_bool
   1.149  Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
   1.150  {
   1.151 -    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   1.152 +    //NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   1.153  
   1.154      if (info->version.major <= SDL_MAJOR_VERSION) {
   1.155          //info->window = nswindow;