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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-09-21 10:18:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-09-21 10:26:21 +0300
commit52bfa750e74952ddd4e8223d92d21140831902a7 (patch)
tree452ae89384d36eea827edb83b2e4e0f846491666 /source/blender/windowmanager
parent5eb505e3682260d47b319b56d8d56310de766cab (diff)
WM: only return PASS_THROUGH on PRESS for selection operators
Some selection operators return (PASS_THROUGH & FINISHED) so the tweak event isn't suppressed from the PRESS event having been handled. This is now restricted to events with a PRESS action. Without this, using CLICK for selection was passing the event through which could run other actions unintentionally.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/intern/wm_operator_utils.c18
2 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 189a231616e..28d3cb326ae 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -707,6 +707,8 @@ void WM_event_fileselect_event(struct wmWindowManager *wm, void *ophandle, int e
void WM_operator_region_active_win_set(struct bContext *C);
+int WM_operator_flag_only_pass_through_on_press(int retval, const struct wmEvent *event);
+
/* drag and drop */
struct wmDrag *WM_event_start_drag(
struct bContext *C, int icon, int type, void *poin, double value, unsigned int flags);
diff --git a/source/blender/windowmanager/intern/wm_operator_utils.c b/source/blender/windowmanager/intern/wm_operator_utils.c
index 81b597f7484..85a0a28de79 100644
--- a/source/blender/windowmanager/intern/wm_operator_utils.c
+++ b/source/blender/windowmanager/intern/wm_operator_utils.c
@@ -41,6 +41,24 @@
#include "ED_screen.h"
/* -------------------------------------------------------------------- */
+/** \name Generic Utilities
+ * \{ */
+
+/**
+ * Only finish + pass through for press events (allowing press-tweak).
+ */
+int WM_operator_flag_only_pass_through_on_press(int retval, const struct wmEvent *event)
+{
+ if ((event->val != KM_PRESS) &&
+ ((retval & OPERATOR_PASS_THROUGH) && (retval & OPERATOR_FINISHED))) {
+ retval &= ~OPERATOR_PASS_THROUGH;
+ }
+ return retval;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Value Interaction Helper
*
* Possible additions (add as needed).