From 9cf83386e828e38fca2a164dee322e9208ec8fd6 Mon Sep 17 00:00:00 2001 From: Ben Byer Date: Wed, 31 Oct 2007 03:39:47 -0700 Subject: [PATCH] Trap Deactivate messages and release modifiers to avoid "stuck shift lock" (etc) bugs --- hw/darwin/darwinEvents.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c index fc79da8cd..6293d6b55 100644 --- a/hw/darwin/darwinEvents.c +++ b/hw/darwin/darwinEvents.c @@ -143,6 +143,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 @@ -467,6 +477,9 @@ void ProcessInputEvents(void) break; } + case kXDarwinDeactivate: + DarwinReleaseModifiers(); + // fall through default: // Check for mode specific event DarwinModeProcessEvent(&xe);