[Bf-blender-cvs] [52bfa750e74] master: WM: only return PASS_THROUGH on PRESS for selection operators
Campbell Barton
noreply at git.blender.org
Tue Sep 21 09:29:07 CEST 2021
Commit: 52bfa750e74952ddd4e8223d92d21140831902a7
Author: Campbell Barton
Date: Tue Sep 21 17:18:26 2021 +1000
Branches: master
https://developer.blender.org/rB52bfa750e74952ddd4e8223d92d21140831902a7
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.
===================================================================
M source/blender/editors/space_view3d/view3d_select.c
M source/blender/editors/uvedit/uvedit_select.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_operator_utils.c
===================================================================
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 3f572bf9d5a..39aed131ea1 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2813,7 +2813,9 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *even
{
RNA_int_set_array(op->ptr, "location", event->mval);
- return view3d_select_exec(C, op);
+ const int retval = view3d_select_exec(C, op);
+
+ return WM_operator_flag_only_pass_through_on_press(retval, event);
}
void VIEW3D_OT_select(wmOperatorType *ot)
diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c
index c0ccf1b7095..86390882bed 100644
--- a/source/blender/editors/uvedit/uvedit_select.c
+++ b/source/blender/editors/uvedit/uvedit_select.c
@@ -2122,7 +2122,9 @@ static int uv_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
RNA_float_set_array(op->ptr, "location", co);
- return uv_select_exec(C, op);
+ const int retval = uv_select_exec(C, op);
+
+ return WM_operator_flag_only_pass_through_on_press(retval, event);
}
void UV_OT_select(wmOperatorType *ot)
@@ -2281,7 +2283,9 @@ static int uv_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *eve
UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
RNA_float_set_array(op->ptr, "location", co);
- return uv_select_loop_exec(C, op);
+ const int retval = uv_select_loop_exec(C, op);
+
+ return WM_operator_flag_only_pass_through_on_press(retval, event);
}
void UV_OT_select_loop(wmOperatorType *ot)
@@ -2341,7 +2345,9 @@ static int uv_select_edge_ring_invoke(bContext *C, wmOperator *op, const wmEvent
UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
RNA_float_set_array(op->ptr, "location", co);
- return uv_select_edge_ring_exec(C, op);
+ const int retval = uv_select_edge_ring_exec(C, op);
+
+ return WM_operator_flag_only_pass_through_on_press(retval, event);
}
void UV_OT_select_edge_ring(wmOperatorType *ot)
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
@@ -40,6 +40,24 @@
#include "ED_object.h"
#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
*
More information about the Bf-blender-cvs
mailing list