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.
This commit is contained in:
Brecht Van Lommel
2018-11-22 14:28:59 +01:00
parent 783b0809b6
commit e815784aa6

View File

@@ -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;