[Bf-blender-cvs] [e815784aa68] blender2.8: Keymaps: make click event detection use a larger distance threshold.

Brecht Van Lommel noreply at git.blender.org
Thu Nov 22 14:40:51 CET 2018


Commit: e815784aa684ccd66a491bbf27370b91ce14f397
Author: Brecht Van Lommel
Date:   Thu Nov 22 14:28:59 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBe815784aa684ccd66a491bbf27370b91ce14f397

Keymaps: make click event detection use a larger distance threshold.

Previously this was hardcoded to 2 pixels, which is too low for tablets and
not taking into account DPI. Now we set it equal to the tweak threshold, so
you either always do click or drag.

The default distance of 10 pixels may be quite far for something to be
considered a click, and we'll need to see how well it works. But I find this
to help a lot when selecting vertices in quick succession.

Thanks to Julien for spotting this.

===================================================================

M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 2a97ce8c904..a9a248f027b 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -91,8 +91,9 @@
 
 #include "DEG_depsgraph.h"
 
-/* Motion in pixels allowed before we don't consider single/double click. */
-#define WM_EVENT_CLICK_WIGGLE_ROOM 2
+/* Motion in pixels allowed before we don't consider single/double click,
+ * or detect the start of a tweak event. */
+#define WM_EVENT_CLICK_TWEAK_THRESHOLD (U.tweak_threshold * U.dpi_fac)
 
 static void wm_notifier_clear(wmNotifier *note);
 static void update_tablet_data(wmWindow *win, wmEvent *event);
@@ -2612,9 +2613,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
 		if (wm_action_not_handled(action)) {
 			if (event->check_drag) {
 				wmWindow *win = CTX_wm_window(C);
-				float tweak_threshold = U.tweak_threshold * U.dpi_fac;
-				if ((abs(event->x - win->eventstate->prevclickx)) >= tweak_threshold ||
-				    (abs(event->y - win->eventstate->prevclicky)) >= tweak_threshold)
+				if ((abs(event->x - win->eventstate->prevclickx)) >= WM_EVENT_CLICK_TWEAK_THRESHOLD ||
+				    (abs(event->y - win->eventstate->prevclicky)) >= WM_EVENT_CLICK_TWEAK_THRESHOLD)
 				{
 					int x = event->x;
 					int y = event->y;
@@ -2673,8 +2673,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
 				    (win->eventstate->prevval == KM_PRESS) &&
 				    (win->eventstate->check_click == true))
 				{
-					if ((abs(event->x - win->eventstate->prevclickx)) <= WM_EVENT_CLICK_WIGGLE_ROOM &&
-					    (abs(event->y - win->eventstate->prevclicky)) <= WM_EVENT_CLICK_WIGGLE_ROOM)
+					if ((abs(event->x - win->eventstate->prevclickx)) < WM_EVENT_CLICK_TWEAK_THRESHOLD &&
+					    (abs(event->y - win->eventstate->prevclicky)) < WM_EVENT_CLICK_TWEAK_THRESHOLD)
 					{
 						/* Position is where the actual click happens, for more
 						 * accurate selecting in case the mouse drifts a little. */
@@ -3784,8 +3784,8 @@ static bool wm_event_is_double_click(wmEvent *event, const wmEvent *event_state)
 	    (event->val == KM_PRESS))
 	{
 		if ((ISMOUSE(event->type) == false) ||
-		    ((abs(event->x - event_state->prevclickx)) <= WM_EVENT_CLICK_WIGGLE_ROOM &&
-		     (abs(event->y - event_state->prevclicky)) <= WM_EVENT_CLICK_WIGGLE_ROOM))
+		    ((abs(event->x - event_state->prevclickx)) < WM_EVENT_CLICK_TWEAK_THRESHOLD &&
+		     (abs(event->y - event_state->prevclicky)) < WM_EVENT_CLICK_TWEAK_THRESHOLD))
 		{
 			if ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time) {
 				return true;



More information about the Bf-blender-cvs mailing list