[Bf-blender-cvs] [bc994918d31] temp-outliner-library-override-hierarchy: Event System: ignore keys such as print-screen & num-lock
Campbell Barton
noreply at git.blender.org
Fri Mar 25 14:17:21 CET 2022
Commit: bc994918d316e02a5382e180cef87231eb4585f8
Author: Campbell Barton
Date: Wed Mar 23 21:05:56 2022 +1100
Branches: temp-outliner-library-override-hierarchy
https://developer.blender.org/rBbc994918d316e02a5382e180cef87231eb4585f8
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
===================================================================
M source/blender/windowmanager/intern/wm_event_system.c
===================================================================
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));
More information about the Bf-blender-cvs
mailing list