diff options
author | Campbell Barton <campbell@blender.org> | 2022-03-23 13:05:56 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-03-23 13:17:59 +0300 |
commit | 8f63dccaa96588bfb35a62ffa7b956fe6a291e9c (patch) | |
tree | 597259c76a8cc698356b4fba632df532190a93d2 /source/blender/windowmanager | |
parent | ad370868a294675277334388f90461e852b4b334 (diff) |
Event System: ignore keys such as print-screen & num-lock
Avoid adding events with their type set to EVENT_NONE as these
can't be categorized usefully (keyboard/mouse/NDOF ... etc),
and add an extra case that needs to be accounted for.
Adding these events seems to be an unintentional change from [0],
these keys used to be ignored in 2.4x.
[0]: a1c8543f2acd7086d412cb794b32f96794b00659
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 4fd9922aabd..e565b32662a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -4428,6 +4428,9 @@ void WM_event_add_mousemove(wmWindow *win) /** \name Ghost Event Conversion * \{ */ +/** + * \return The WM enum for key or #EVENT_NONE (which should be ignored). + */ static int convert_key(GHOST_TKey key) { if (key >= GHOST_kKeyA && key <= GHOST_kKeyZ) { @@ -4451,7 +4454,7 @@ static int convert_key(GHOST_TKey key) case GHOST_kKeyLinefeed: return EVT_LINEFEEDKEY; case GHOST_kKeyClear: - return 0; + return EVENT_NONE; case GHOST_kKeyEnter: return EVT_RETKEY; @@ -4506,9 +4509,9 @@ static int convert_key(GHOST_TKey key) case GHOST_kKeyCapsLock: return EVT_CAPSLOCKKEY; case GHOST_kKeyNumLock: - return 0; + return EVENT_NONE; case GHOST_kKeyScrollLock: - return 0; + return EVENT_NONE; case GHOST_kKeyLeftArrow: return EVT_LEFTARROWKEY; @@ -4520,7 +4523,7 @@ static int convert_key(GHOST_TKey key) return EVT_DOWNARROWKEY; case GHOST_kKeyPrintScreen: - return 0; + return EVENT_NONE; case GHOST_kKeyPause: return EVT_PAUSEKEY; @@ -4563,7 +4566,7 @@ static int convert_key(GHOST_TKey key) return EVT_MEDIALAST; default: - return EVT_UNKNOWNKEY; /* #GHOST_kKeyUnknown (this could be asserted). */ + return EVT_UNKNOWNKEY; } } @@ -4865,7 +4868,7 @@ static void wm_event_state_update_and_click_set(const GHOST_TEventType type, wmEvent *event, wmEvent *event_state) { - BLI_assert(ISKEYBOARD_OR_BUTTON(event->type) || (event->type == EVENT_NONE)); + BLI_assert(ISKEYBOARD_OR_BUTTON(event->type)); BLI_assert(ELEM(event->val, KM_PRESS, KM_RELEASE)); /* Only copy these flags into the `event_state`. */ @@ -5087,6 +5090,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void case GHOST_kEventKeyUp: { GHOST_TEventKeyData *kd = customdata; event.type = convert_key(kd->key); + if (UNLIKELY(event.type == EVENT_NONE)) { + break; + } + event.ascii = kd->ascii; /* Might be not NULL terminated. */ memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); |