Date: Fri, 13 Feb 2004 17:03:16 +0100
authorSam Lantinga <slouken@libsdl.org>
Fri, 13 Feb 2004 17:57:16 +0000
changeset 816428f688f2ad2
parent 815 6176f9a0d61a
child 817 700c9c5c923b
Date: Fri, 13 Feb 2004 17:03:16 +0100
From: Max Horn
Subject: Modifier key fix

The internal modifier state can get out of sync with reality. To
trigger this, do for example this:
1) Launch an SDL app
2) Alt-click on the desktop (this will hide the SDL app).
3) Bring the SDL app back to the front
4) SDL will still think alt is pressed (and as such will treat left
clicks like middle clicks). If you press and release alt, it'll be fine
again.

The attached patch cures this by rechecking the modifier state whenever
we process an event.
src/video/quartz/SDL_QuartzEvents.m
src/video/quartz/SDL_QuartzVideo.m
     1.1 --- a/src/video/quartz/SDL_QuartzEvents.m	Fri Feb 13 06:42:17 2004 +0000
     1.2 +++ b/src/video/quartz/SDL_QuartzEvents.m	Fri Feb 13 17:57:16 2004 +0000
     1.3 @@ -266,6 +266,9 @@
     1.4      int i;
     1.5      int bit;
     1.6      SDL_keysym key;
     1.7 +    
     1.8 +    if (current_mods == newMods)
     1.9 +    	return;
    1.10  
    1.11      key.scancode    = 0;
    1.12      key.sym         = SDLK_UNKNOWN;
    1.13 @@ -462,6 +465,8 @@
    1.14              type = [ event type ];
    1.15              isInGameWin = QZ_IsMouseInWindow (this);
    1.16  
    1.17 +            QZ_DoModifiers(this, [ event modifierFlags ] );
    1.18 +
    1.19              switch (type) {
    1.20                  case NSLeftMouseDown:
    1.21                      if ( getenv("SDL_HAS3BUTTONMOUSE") ) {
    1.22 @@ -613,7 +618,6 @@
    1.23                      QZ_DoKey (this, SDL_PRESSED, event);
    1.24                      break;
    1.25                  case NSFlagsChanged:
    1.26 -                    QZ_DoModifiers(this, [ event modifierFlags ] );
    1.27                      break;
    1.28                  case NSAppKitDefined:
    1.29                      switch ( [ event subtype ] ) {
     2.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Fri Feb 13 06:42:17 2004 +0000
     2.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Fri Feb 13 17:57:16 2004 +0000
     2.3 @@ -203,6 +203,7 @@
     2.4      current_grab_mode = SDL_GRAB_OFF;
     2.5      cursor_should_be_visible    = YES;
     2.6      cursor_visible              = YES;
     2.7 +    current_mods = -1;
     2.8      
     2.9      /* register for sleep notifications so wake from sleep generates SDL_VIDEOEXPOSE */
    2.10      QZ_RegisterForSleepNotifications (this);