From 82e8e5c871f86e65f332cdde3bd484a55e7e8572 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 30 May 2019 14:17:39 +1000 Subject: Cleanup: move click/drag events to functions Simplifies future changes to dragging checks and avoids each check for drag using slightly different logic. --- source/blender/editors/space_node/node_select.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/space_node/node_select.c') diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 11462358d88..78f36719880 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -611,13 +611,14 @@ static int node_select_modal(bContext *C, wmOperator *op, const wmEvent *event) return ret_value | OPERATOR_PASS_THROUGH; } else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { - const int dx = mval[0] - event->mval[0]; - const int dy = mval[1] - event->mval[1]; - const int drag_threshold = WM_EVENT_CURSOR_CLICK_DRAG_THRESHOLD; + const int drag_delta[2] = { + mval[0] - event->mval[0], + mval[1] - event->mval[1], + }; /* If user moves mouse more than defined threshold, we consider select operator as * finished. Otherwise, it is still running until we get an 'release' event. In any * case, we pass through event, but select op is not finished yet. */ - if (abs(dx) >= drag_threshold || abs(dy) >= drag_threshold) { + if (WM_event_drag_test_with_delta(event, drag_delta)) { return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } else { -- cgit v1.2.3