diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-11-18 14:14:55 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-11-18 14:21:55 +0300 |
commit | bbd4613ed94931cd5443309d98ab8e112b64b93a (patch) | |
tree | 08eef1a803eb3992a62b6372ddea398cd23a09c7 /source | |
parent | c1e1ea5b8fc00aa4852f6be0231fa3041845c136 (diff) |
Keymaps: make click event use position on button press rather than release.
This may improve reliability with left click select and pen input, assuming
that the place where the pen first touched the surface is closer to the
intended location than where it was released from the surface.
I'm not sure if this will make a significant difference in practice, but it
seems worth a try.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_region_menu_pie.c | 12 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 16 |
2 files changed, 19 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c index 6887235f5db..b7fc1055154 100644 --- a/source/blender/editors/interface/interface_region_menu_pie.c +++ b/source/blender/editors/interface/interface_region_menu_pie.c @@ -152,15 +152,9 @@ uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, co pie->layout = UI_block_layout(pie->block_radial, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style); - /* Open from where we started dragging. */ - if (event->val == KM_CLICK_DRAG) { - pie->mx = event->prevclickx; - pie->my = event->prevclicky; - } - else { - pie->mx = event->x; - pie->my = event->y; - } + /* Note event->x/y is where we started dragging in case of KM_CLICK_DRAG. */ + pie->mx = event->x; + pie->my = event->y; /* create title button */ if (title[0]) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 63c45407135..f82df000288 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2615,8 +2615,13 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) if ((abs(event->x - win->eventstate->prevclickx)) >= U.tweak_threshold || (abs(event->y - win->eventstate->prevclicky)) >= U.tweak_threshold) { + int x = event->x; + int y = event->y; short val = event->val; short type = event->type; + + event->x = win->eventstate->prevclickx; + event->y = win->eventstate->prevclicky; event->val = KM_CLICK_DRAG; event->type = win->eventstate->type; @@ -2626,6 +2631,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) event->val = val; event->type = type; + event->x = x; + event->y = y; win->eventstate->check_click = 0; win->eventstate->check_drag = 0; @@ -2668,6 +2675,13 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) if ((abs(event->x - win->eventstate->prevclickx)) <= WM_EVENT_CLICK_WIGGLE_ROOM && (abs(event->y - win->eventstate->prevclicky)) <= WM_EVENT_CLICK_WIGGLE_ROOM) { + /* Position is where the actual click happens, for more + * accurate selecting in case the mouse drifts a little. */ + int x = event->x; + int y = event->y; + + event->x = win->eventstate->prevclickx; + event->y = win->eventstate->prevclicky; event->val = KM_CLICK; CLOG_INFO(WM_LOG_HANDLERS, 1, "handling CLICK"); @@ -2675,6 +2689,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) action |= wm_handlers_do_intern(C, event, handlers); event->val = KM_RELEASE; + event->x = x; + event->y = y; } else { win->eventstate->check_click = 0; |