Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-18 04:02:34 +0300
committerCampbell Barton <campbell@blender.org>2022-09-18 04:16:24 +0300
commit8c878ddd347c33eee663e7eb48474e59e0997f10 (patch)
treea5caa205a9eba88981c391cb12ca260ae89219da /intern
parent0950e6fae6800cd847d1c74e35489e46b0c48229 (diff)
Fix OS-key events repeating on GHOST/Win32
Holding the OS (Windows) key on Win32 used key-repeat behavior. While as far as I know it didn't cause user visible errors - sending repeated modifier events isn't expected behavior and doesn't happen on other platforms (or for other modifier keys).
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/GHOST_Types.h5
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp8
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;
}