From 7123bcfc3ee424d115f11f50fd8b129b0749ba8f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 17 Jun 2014 11:29:34 +0200 Subject: [PATCH] Fixed modifier key events being lost. --- README.md | 2 ++ src/cocoa_window.m | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c912c625..e891dd5a 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,8 @@ The following dependencies are needed by the examples and test programs: - [Cocoa] Bugfix: One copy of each display name string was leaked - [Cocoa] Bugfix: Monitor enumeration caused a segfault if no `NSScreen` was found for a given `CGDisplay` + - [Cocoa] Bugfix: Modifier key events were lost if the corresponding modifier + bit field was unchanged - [Win32] Enabled generation of pkg-config file for MinGW - [Win32] Bugfix: Failure to load winmm or its functions was not reported to the error callback diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 20af25c1..723d3ff9 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -617,18 +617,25 @@ static int translateKey(unsigned int key) - (void)flagsChanged:(NSEvent *)event { int action; - unsigned int newModifierFlags = + const unsigned int modifierFlags = [event modifierFlags] & NSDeviceIndependentModifierFlagsMask; + const int key = translateKey([event keyCode]); + const int mods = translateFlags(modifierFlags); - if (newModifierFlags > window->ns.modifierFlags) + if (modifierFlags == window->ns.modifierFlags) + { + if (window->key[key] == GLFW_PRESS) + action = GLFW_RELEASE; + else + action = GLFW_PRESS; + } + else if (modifierFlags > window->ns.modifierFlags) action = GLFW_PRESS; else action = GLFW_RELEASE; - window->ns.modifierFlags = newModifierFlags; + window->ns.modifierFlags = modifierFlags; - const int key = translateKey([event keyCode]); - const int mods = translateFlags([event modifierFlags]); _glfwInputKey(window, key, [event keyCode], action, mods); }