diff options
-rw-r--r-- | intern/ghost/GHOST_Types.h | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWin32.cpp | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 909417e0f50..b3799c53a8d 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -321,6 +321,7 @@ typedef enum { GHOST_kKeyBackslash = 0x5C, GHOST_kKeyAccentGrave = '`', + /* Modifiers: See #GHOST_KEY_IS_MODIFIER. */ GHOST_kKeyLeftShift = 0x100, GHOST_kKeyRightShift, GHOST_kKeyLeftControl, @@ -329,6 +330,8 @@ typedef enum { GHOST_kKeyRightAlt, GHOST_kKeyLeftOS, /* Command key on Apple, Windows key(s) on Windows. */ GHOST_kKeyRightOS, + /* End modifiers. */ + GHOST_kKeyGrLess, /* German PC only! */ GHOST_kKeyApp, /* Also known as menu key. */ @@ -402,6 +405,8 @@ typedef enum { GHOST_kKeyMediaLast } GHOST_TKey; +#define GHOST_KEY_IS_MODIFIER(key) (key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightOS); + typedef enum { /** Grab not set. */ GHOST_kGrabDisable = 0, diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index ce622aa0751..5a40feb70ae 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1136,12 +1136,18 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA GHOST_TKey key = system->hardKey(raw, &key_down); GHOST_EventKey *event; + /* NOTE(@campbellbarton): key repeat in WIN32 also applies to modifier-keys. + * Check for this case and filter out modifier-repeat. + * Typically keyboard events are *not* filtered as part of GHOST's event handling. + * As other GHOST back-ends don't have the behavior, it's simplest not to send them through. + * Ideally it would be possible to check the key-map for keys that repeat but this doesn't look + * to be supported. */ bool is_repeat = false; bool is_repeated_modifier = false; if (key_down) { if (system->m_keycode_last_repeat_key == vk) { is_repeat = true; - is_repeated_modifier = (key >= GHOST_kKeyLeftShift && key <= GHOST_kKeyRightAlt); + is_repeated_modifier = GHOST_KEY_IS_MODIFIER(key); } system->m_keycode_last_repeat_key = vk; } |