Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-11-22 16:28:59 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-11-22 16:33:07 +0300
commite815784aa684ccd66a491bbf27370b91ce14f397 (patch)
tree63769697253cd44a713951ce66635129f7f7da7e
parent783b0809b60abecb97d084495a6a910ae7bb9b09 (diff)
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.
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c18
1 files changed, 9 insertions, 9 deletions
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;