From 606a8dc73d91a198d72d249934dc027a23f4c338 Mon Sep 17 00:00:00 2001 From: Ben Byer Date: Wed, 31 Oct 2007 03:39:47 -0700 Subject: [PATCH] Darwin: Trap Deactivate messages and release modifiers to avoid "stuck shift lock" (etc) bugs (cherry picked from commit 2b189a99330eb465fa0d17020fb1db1e38829151) --- hw/darwin/darwinEvents.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/darwin/darwinEvents.c b/hw/darwin/darwinEvents.c index bc3a041a5..06c4cc7dd 100644 --- a/hw/darwin/darwinEvents.c +++ b/hw/darwin/darwinEvents.c @@ -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 @@ -347,6 +357,9 @@ void ProcessInputEvents(void) { ErrorF("Unexpected XDarwinScrollWheel event in DarwinProcessInputEvents\n"); break; + case kXDarwinDeactivate: + DarwinReleaseModifiers(); + // fall through default: // Check for mode specific event DarwinModeProcessEvent(&xe);