Darwin: Trap Deactivate messages and release modifiers to avoid "stuck shift lock" (etc) bugs

(cherry picked from commit 2b189a99330eb465fa0d17020fb1db1e38829151)
This commit is contained in:
Ben Byer 2007-10-31 03:39:47 -07:00 committed by Jeremy Huddleston
parent 4c18ef4331
commit 606a8dc73d

View File

@ -147,6 +147,16 @@ static void DarwinUpdateModifiers(
} }
} }
/*
* DarwinReleaseModifiers
* This hacky function releases all modifier keys. It should be called when X11.app
* is deactivated (kXDarwinDeactivate) to prevent modifiers from getting stuck if they
* are held down during a "context" switch -- otherwise, we would miss the KeyUp.
*/
static void DarwinReleaseModifiers(void) {
xEvent e;
DarwinUpdateModifiers(&e, KeyRelease, COMMAND_MASK(-1) | CONTROL_MASK(-1) | ALTERNATE_MASK(-1) | SHIFT_MASK(-1));
}
/* /*
* DarwinSimulateMouseClick * DarwinSimulateMouseClick
@ -347,6 +357,9 @@ void ProcessInputEvents(void) {
ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n"); ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n");
break; break;
case kXDarwinDeactivate:
DarwinReleaseModifiers();
// fall through
default: default:
// Check for mode specific event // Check for mode specific event
DarwinModeProcessEvent(&xe); DarwinModeProcessEvent(&xe);