Fix snap gizmo flickering while dragging

Ignore click-drag for non-mouse button drag events

Alternative to fix issue detailed in D10886.
This commit is contained in:
Campbell Barton 2021-04-13 21:33:52 +10:00
parent 2f367db2cc
commit 1534da457e
Notes: blender-bot 2023-02-14 07:31:34 +01:00
Referenced by issue #87511, Snap gizmo flickering when activated by pressing and holding the Ctrl button
4 changed files with 8 additions and 2 deletions

View File

@ -861,6 +861,7 @@ int WM_event_modifier_flag(const struct wmEvent *event);
bool WM_event_is_modal_tweak_exit(const struct wmEvent *event, int tweak_event);
bool WM_event_is_last_mousemove(const struct wmEvent *event);
bool WM_event_is_mouse_drag(const struct wmEvent *event);
int WM_event_drag_threshold(const struct wmEvent *event);
bool WM_event_drag_test(const struct wmEvent *event, const int prev_xy[2]);

View File

@ -592,7 +592,7 @@ static int gizmo_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const int highlight_part_init = gz->highlight_part;
if (gz->drag_part != -1) {
if (ISTWEAK(event->type) || (event->val == KM_CLICK_DRAG)) {
if (WM_event_is_mouse_drag(event)) {
gz->highlight_part = gz->drag_part;
}
}

View File

@ -735,7 +735,7 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
/* Ensure for drag events we use the location where the user clicked.
* Without this click-dragging on a gizmo can accidentally act on the wrong gizmo. */
if (ISTWEAK(event->type) || (event->val == KM_CLICK_DRAG)) {
if (WM_event_is_mouse_drag(event)) {
mval[0] += event->x - event->prevclickx;
mval[1] += event->y - event->prevclicky;
}

View File

@ -265,6 +265,11 @@ bool WM_event_is_last_mousemove(const wmEvent *event)
return true;
}
bool WM_event_is_mouse_drag(const wmEvent *event)
{
return ISTWEAK(event->type) || (ISMOUSE_BUTTON(event->type) && (event->val == KM_CLICK_DRAG));
}
/** \} */
/* -------------------------------------------------------------------- */