Fix click-drag events for dragging markers
Clicking and dragging markers accumulates flags from multiple operators in a way that can't be interpreted when combine. Follow tweak behavior for cancelling click-drag events.
This commit is contained in:
parent
cf428b2ebd
commit
aa71414dfc
Notes:
blender-bot
2023-02-14 11:20:29 +01:00
Referenced by commit4d0f846b93
, Event System: use more thoroughly tested logic for click-drag events Referenced by commit47396ea81e
, Fix T96123: Crash when click-dragging across the visibility icons Referenced by commit1747269ea5
, Cleanup: misleading code fromaa71414dfc
Referenced by issue #96255, Node socket click detection is broken in some cases Referenced by issue #96140, Dragging & Drop color (fields) let's blender crash. Referenced by issue #96123, Crash when click-dragging across the visibility icons
|
@ -3157,44 +3157,40 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
|||
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
|
||||
/* Test for #WM_CLICK_DRAG events. */
|
||||
|
||||
/* NOTE(@campbellbarton): Needed so drag can be used for editors that support both click
|
||||
/* NOTE(@campbellbarton): Ignore `action` so drag can be used for editors that use 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;
|
||||
* In the case of marker select-drag the combinations of (pass-through / finished / modal)
|
||||
* can accumulate to have flags set that they can't be properly interpreted here.
|
||||
* Instead `win->event_queue_check_drag` is cleared in `wm_event_do_handlers`. */
|
||||
if (win->event_queue_check_drag) {
|
||||
if (WM_event_drag_test(event, event->prev_click_xy)) {
|
||||
win->event_queue_check_drag_handled = true;
|
||||
|
||||
const int prev_xy[2] = {UNPACK2(event->xy)};
|
||||
const short prev_val = event->val;
|
||||
const short prev_type = event->type;
|
||||
const uint8_t prev_modifier = event->modifier;
|
||||
const short prev_keymodifier = event->keymodifier;
|
||||
const int prev_xy[2] = {UNPACK2(event->xy)};
|
||||
const short prev_val = event->val;
|
||||
const short prev_type = event->type;
|
||||
const uint8_t prev_modifier = event->modifier;
|
||||
const short prev_keymodifier = event->keymodifier;
|
||||
|
||||
copy_v2_v2_int(event->xy, event->prev_click_xy);
|
||||
event->val = KM_CLICK_DRAG;
|
||||
event->type = event->prev_type;
|
||||
event->modifier = event->prev_click_modifier;
|
||||
event->keymodifier = event->prev_click_keymodifier;
|
||||
copy_v2_v2_int(event->xy, event->prev_click_xy);
|
||||
event->val = KM_CLICK_DRAG;
|
||||
event->type = event->prev_type;
|
||||
event->modifier = event->prev_click_modifier;
|
||||
event->keymodifier = event->prev_click_keymodifier;
|
||||
|
||||
CLOG_INFO(WM_LOG_HANDLERS, 1, "handling PRESS_DRAG");
|
||||
CLOG_INFO(WM_LOG_HANDLERS, 1, "handling PRESS_DRAG");
|
||||
|
||||
action |= wm_handlers_do_intern(C, win, event, handlers);
|
||||
WM_event_print(event);
|
||||
|
||||
event->keymodifier = prev_keymodifier;
|
||||
event->modifier = prev_modifier;
|
||||
event->val = prev_val;
|
||||
event->type = prev_type;
|
||||
copy_v2_v2_int(event->xy, prev_xy);
|
||||
action |= wm_handlers_do_intern(C, win, event, handlers);
|
||||
|
||||
win->event_queue_check_click = false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
event->keymodifier = prev_keymodifier;
|
||||
event->modifier = prev_modifier;
|
||||
event->val = prev_val;
|
||||
event->type = prev_type;
|
||||
copy_v2_v2_int(event->xy, prev_xy);
|
||||
|
||||
win->event_queue_check_click = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -3270,7 +3266,6 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
|
|||
}
|
||||
else {
|
||||
win->event_queue_check_click = false;
|
||||
win->event_queue_check_drag = false;
|
||||
}
|
||||
}
|
||||
else if (ISMOUSE_WHEEL(event->type) || ISMOUSE_GESTURE(event->type)) {
|
||||
|
@ -3720,6 +3715,10 @@ void wm_event_do_handlers(bContext *C)
|
|||
/* Builtin tweak, if action is break it removes tweak. */
|
||||
wm_tweakevent_test(C, event, action);
|
||||
|
||||
if (action & WM_HANDLER_BREAK) {
|
||||
win->event_queue_check_drag = false;
|
||||
}
|
||||
|
||||
if ((action & WM_HANDLER_BREAK) == 0) {
|
||||
/* NOTE: setting subwin active should be done here, after modal handlers have been done. */
|
||||
if (event->type == MOUSEMOVE) {
|
||||
|
|
Loading…
Reference in New Issue