[Bf-blender-cvs] [7a736854603] master: Fix WM_event_type_mask_test ignoring wheel and gesture events

Campbell Barton noreply at git.blender.org
Thu Jul 21 08:54:35 CEST 2022


Commit: 7a736854603b640ca2a384a6cf05d0afc7fbe6dd
Author: Campbell Barton
Date:   Thu Jul 21 15:59:54 2022 +1000
Branches: master
https://developer.blender.org/rB7a736854603b640ca2a384a6cf05d0afc7fbe6dd

Fix WM_event_type_mask_test ignoring wheel and gesture events

WM_event_type_mask_test checks assumed ISMOUSE macro worked for any
kind of mouse event when it only accepted buttons & motion.

Now ISMOUSE checks for any kind of mouse event,
use ISMOUSE_BUTTON/WHEEL/GESTURE for more specific checks.

===================================================================

M	source/blender/windowmanager/wm_event_types.h

===================================================================

diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 2911c74e5a4..c356b275a7e 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -44,7 +44,10 @@ enum {
   /* non-event, for example disabled timer */
   EVENT_NONE = 0x0000,
 
-  /* ********** Start of Input devices. ********** */
+/* ********** Start of Input devices. ********** */
+
+/* Minimum mouse value (inclusive). */
+#define _EVT_MOUSE_MIN 0x0001
 
   /* MOUSE: 0x000x, 0x001x */
   LEFTMOUSE = 0x0001,
@@ -74,6 +77,9 @@ enum {
    * paint and drawing tools however will want to handle these. */
   INBETWEEN_MOUSEMOVE = 0x0011,
 
+/* Maximum keyboard value (inclusive). */
+#define _EVT_MOUSE_MAX 0x0011 /* 17 */
+
   /* IME event, GHOST_kEventImeCompositionStart in ghost */
   WM_IME_COMPOSITE_START = 0x0014,
   /* IME event, GHOST_kEventImeComposition in ghost */
@@ -379,8 +385,14 @@ enum {
   (((event_type) >= EVT_LEFTCTRLKEY && (event_type) <= EVT_LEFTSHIFTKEY) || \
    (event_type) == EVT_OSKEY)
 
-/** Test whether the event is a mouse button. */
-#define ISMOUSE(event_type) ((event_type) >= LEFTMOUSE && (event_type) <= BUTTON7MOUSE)
+/**
+ * Test whether the event is any kind:
+ * #ISMOUSE_BUTTON, #ISMOUSE_WHEEL, #ISMOUSE_GESTURE & motion.
+ *
+ * \note It's best to use more specific check if possible as mixing motion/buttons/gestures
+ * is very broad and not necessarily obvious which kinds of events are important.
+ */
+#define ISMOUSE(event_type) ((event_type) >= _EVT_MOUSE_MIN && (event_type) <= _EVT_MOUSE_MAX)
 /** Test whether the event is a mouse wheel. */
 #define ISMOUSE_WHEEL(event_type) ((event_type) >= WHEELUPMOUSE && (event_type) <= WHEELOUTMOUSE)
 /** Test whether the event is a mouse (track-pad) gesture. */



More information about the Bf-blender-cvs mailing list