From cf428b2ebddabd5786f65ae8901f25a4cbf456da Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 2 Mar 2022 12:15:01 +1100 Subject: [PATCH] Fix ignored click-drag events when operators pass-through & finished Replacing tweak key-map items with click-drag caused selection in the graph/sequencer/node editors to ignore drag events (all uses of WM_generic_select_modal). Operators that return OPERATOR_PASS_THROUGH | OPERATOR_FINISHED result in the event loop considering the event as being handled. This stopped WM_CLICK_DRAG events from being generated which is not the case for tweak events. As click-drag is intended to be compatible with tweak events, accept drag events when WM_HANDLER_BREAK isn't set or when wm_action_not_handled returns true. --- .../blender/windowmanager/intern/wm_event_system.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index fb5af920ff8..20940c59679 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -3155,8 +3155,14 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) } if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { - /* Test for CLICK_DRAG events. */ - if (wm_action_not_handled(action)) { + /* Test for #WM_CLICK_DRAG events. */ + + /* NOTE(@campbellbarton): Needed so drag can be used for editors that support both click + * selection and passing through the drag action to box select. See #WM_generic_select_modal. + * Unlike click, accept `action` when break isn't set. + * Operators can return `OPERATOR_FINISHED | OPERATOR_PASS_THROUGH` which results + * in `action` setting #WM_HANDLER_HANDLED, but not #WM_HANDLER_BREAK. */ + if ((action & WM_HANDLER_BREAK) == 0 || wm_action_not_handled(action)) { if (win->event_queue_check_drag) { if (WM_event_drag_test(event, event->prev_click_xy)) { win->event_queue_check_drag_handled = true; @@ -3184,7 +3190,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) copy_v2_v2_int(event->xy, prev_xy); win->event_queue_check_click = false; - if (!wm_action_not_handled(action)) { + if (!((action & WM_HANDLER_BREAK) == 0 || wm_action_not_handled(action))) { /* Only disable when handled as other handlers may use this drag event. */ win->event_queue_check_drag = false; }