src/video/quartz/SDL_QuartzEvents.m
changeset 1212 7663bb0f52c7
parent 1050 8e1815fd9777
child 1213 8eb191652834
equal deleted inserted replaced
1211:304d8dd6a989 1212:7663bb0f52c7
   885                     }
   885                     }
   886                     else
   886                     else
   887                     if ( !isInGameWin && (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
   887                     if ( !isInGameWin && (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
   888                     
   888                     
   889                         SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
   889                         SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
       
   890                         if (grab_state == QZ_INVISIBLE_GRAB)
       
   891                             /*The cursor has left the window even though it is
       
   892                               disassociated from the mouse (and therefore
       
   893                               shouldn't move): this can happen with Wacom
       
   894                               tablets, and it effectively breaks the grab, since
       
   895                               mouse down events now go to background
       
   896                               applications. The only possibility to avoid this
       
   897                               seems to be talking to the tablet driver
       
   898                               (AppleEvents) to constrain its mapped area to the
       
   899                               window, which may not be worth the effort. For
       
   900                               now, handle the condition more gracefully than
       
   901                               before by reassociating cursor and mouse until the
       
   902                               cursor enters the window again, making it obvious
       
   903                               to the user that the grab is broken.*/
       
   904                             CGAssociateMouseAndMouseCursorPosition (1);
   890                         if (!cursor_should_be_visible)
   905                         if (!cursor_should_be_visible)
   891                             QZ_ShowMouse (this);
   906                             QZ_ShowMouse (this);
   892                     }
   907                     }
   893                     else
   908                     else
   894                     if ( isInGameWin && !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
   909                     if ( isInGameWin && !(SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
   895                     
   910                     
   896                         SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
   911                         SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
   897                         if (!cursor_should_be_visible)
   912                         if (!cursor_should_be_visible)
   898                             QZ_HideMouse (this);
   913                             QZ_HideMouse (this);
       
   914                         if (grab_state == QZ_INVISIBLE_GRAB) { /*see comment above*/
       
   915                             QZ_PrivateWarpCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);
       
   916                             CGAssociateMouseAndMouseCursorPosition (0);
       
   917                         }
   899                     }
   918                     }
   900                     break;
   919                     break;
   901                 case NSScrollWheel:
   920                 case NSScrollWheel:
   902                     if ( isInGameWin ) {
   921                     if ( isInGameWin ) {
   903                         float dy, dx;
   922                         float dy, dx;
   945     if (dx != 0 || dy != 0)
   964     if (dx != 0 || dy != 0)
   946         SDL_PrivateMouseMotion (0, 1, dx, dy);
   965         SDL_PrivateMouseMotion (0, 1, dx, dy);
   947     
   966     
   948     [ pool release ];
   967     [ pool release ];
   949 }
   968 }
       
   969 
       
   970 void QZ_UpdateMouse (_THIS)
       
   971 {
       
   972     NSPoint p;
       
   973     QZ_GetMouseLocation (this, &p);
       
   974     SDL_PrivateAppActive (QZ_IsMouseInWindow (this), SDL_APPMOUSEFOCUS);
       
   975     SDL_PrivateMouseMotion (0, 0, p.x, p.y);
       
   976 }