From 0d07cfd9405464e45186c3c075f255ff519f1d24 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Apr 2021 23:09:26 +1000 Subject: Fix/Workaround T87511: snap gizmo flickers on Ctrl-Drag Hack to bypass drag events, eventually the gizmo API should support this use case without hacks. --- .../editors/gizmo_library/gizmo_types/snap3d_gizmo.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c index cd7d0f5fb4c..3cff07dde3f 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c @@ -609,12 +609,23 @@ static int snap_gizmo_test_select(bContext *C, wmGizmo *gz, const int mval[2]) { SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz; wmWindowManager *wm = CTX_wm_manager(C); + ARegion *region = CTX_wm_region(C); + + /* FIXME: this hack is to ignore drag events, otherwise drag events + * cause momentary snap gizmo re-positioning at the drag-start location, see: T87511. */ + if (wm && wm->winactive) { + const wmEvent *event = wm->winactive->eventstate; + int mval_compare[2] = {event->x - region->winrct.xmin, event->y - region->winrct.ymin}; + if (!equals_v2v2_int(mval_compare, mval)) { + return snap_gizmo->snap_elem ? 0 : -1; + } + } + if (!eventstate_has_changed(snap_gizmo, wm)) { /* Performance, do not update. */ return snap_gizmo->snap_elem ? 0 : -1; } - ARegion *region = CTX_wm_region(C); View3D *v3d = CTX_wm_view3d(C); const float mval_fl[2] = {UNPACK2(mval)}; short snap_elem = ED_gizmotypes_snap_3d_update( -- cgit v1.2.3