diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-10-16 06:19:03 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-10-16 06:27:10 +0300 |
commit | 137586a13c758d95472c3a3eabfc7dd4b22b7502 (patch) | |
tree | c886a31d3bde859a87c464bf24087b0f89aca751 /source | |
parent | 201b02f2a740290796eedfc8346fabe13e945ad2 (diff) |
Event System: Prevent mouse motion in click events
Don't convert mouse button events to click if they include dragging.
Double-click events already checked for this.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 7e7314cc0c8..a6777d40398 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -83,6 +83,9 @@ #include "RNA_enum_types.h" +/* Motion in pixels allowed before we don't consider single/double click. */ +#define WM_EVENT_CLICK_WIGGLE_ROOM 2 + static void wm_notifier_clear(wmNotifier *note); static void update_tablet_data(wmWindow *win, wmEvent *event); @@ -2204,7 +2207,9 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) if ((event->val == KM_RELEASE) && (win->eventstate->prevval == KM_PRESS) && - (win->eventstate->check_click == true)) + (win->eventstate->check_click == true) && + ((abs(event->x - win->eventstate->prevclickx)) <= WM_EVENT_CLICK_WIGGLE_ROOM && + (abs(event->y - win->eventstate->prevclicky)) <= WM_EVENT_CLICK_WIGGLE_ROOM)) { event->val = KM_CLICK; @@ -3163,8 +3168,9 @@ static bool wm_event_is_double_click(wmEvent *event, const wmEvent *event_state) (event_state->prevval == KM_RELEASE) && (event->val == KM_PRESS)) { - if ((ISMOUSE(event->type) == false) || ((ABS(event->x - event_state->prevclickx)) <= 2 && - (ABS(event->y - event_state->prevclicky)) <= 2)) + 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)) { if ((PIL_check_seconds_timer() - event_state->prevclicktime) * 1000 < U.dbl_click_time) { return true; |