diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-01-10 04:25:20 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-01-10 04:41:45 +0300 |
commit | fdd3d969a621132ec0f3aeae8875b146f8e3a19d (patch) | |
tree | baf9a648846089bc6aadda12067487cf199a0884 /source/blender/windowmanager/intern | |
parent | 9aada45e52e88d272c38dc2e47cbc9a6d3d35698 (diff) |
Fix T53491: Absolute tablet motion detection fails
When using a tablet, detecting absolute motion only worked
when activating a tool with the tablet.
Pressing Enter to run a tool for e.g. would use relative motion.
Now store is_motion_absolute in the event,
set for new events based on the most recent motion events.
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 50 |
2 files changed, 30 insertions, 27 deletions
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index d4c3928bd6c..ad5e83ceda7 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -213,13 +213,10 @@ void WM_cursor_grab_enable(wmWindow *win, bool wrap, bool hide, int bounds[4]) } if ((G.debug & G_DEBUG) == 0) { if (win->ghostwin) { - const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); - /* Note: There is no tabletdata on Windows if no tablet device is connected. */ - if (!tabletdata) - GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); - else if (tabletdata->Active == GHOST_kTabletModeNone) + if (win->eventstate->is_motion_absolute == false) { GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); + } win->grabcursor = mode; } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 8f0b5de0cde..ed56586711d 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -94,7 +94,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA /* ************ event management ************** */ -void wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent *event_to_add_after) +wmEvent *wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent *event_to_add_after) { wmEvent *event = MEM_mallocN(sizeof(wmEvent), "wmEvent"); @@ -102,6 +102,13 @@ void wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent * update_tablet_data(win, event); + if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { + /* We could have a preference to support relative tablet motion (we can't detect that). */ + event->is_motion_absolute = ( + (event->tablet_data != NULL) && + (event->tablet_data->Active != GHOST_kTabletModeNone)); + } + if (event_to_add_after == NULL) { BLI_addtail(&win->queue, event); } @@ -109,11 +116,12 @@ void wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent * /* note, strictly speaking this breaks const-correctness, however we're only changing 'next' member */ BLI_insertlinkafter(&win->queue, (void *)event_to_add_after, event); } + return event; } -void wm_event_add(wmWindow *win, const wmEvent *event_to_add) +wmEvent *wm_event_add(wmWindow *win, const wmEvent *event_to_add) { - wm_event_add_ex(win, event_to_add, NULL); + return wm_event_add_ex(win, event_to_add, NULL); } void wm_event_free(wmEvent *event) @@ -624,11 +632,6 @@ void WM_report_banner_show(void) wm_reports->reporttimer->customdata = rti; } -bool WM_event_is_absolute(const wmEvent *event) -{ - return (event->tablet_data != NULL); -} - bool WM_event_is_last_mousemove(const wmEvent *event) { while ((event = event->next)) { @@ -3196,7 +3199,7 @@ static bool wm_event_is_double_click(wmEvent *event, const wmEvent *event_state) return false; } -static void wm_event_add_mousemove(wmWindow *win, const wmEvent *event) +static wmEvent *wm_event_add_mousemove(wmWindow *win, const wmEvent *event) { wmEvent *event_last = win->queue.last; @@ -3206,16 +3209,13 @@ static void wm_event_add_mousemove(wmWindow *win, const wmEvent *event) if (event_last && event_last->type == MOUSEMOVE) event_last->type = INBETWEEN_MOUSEMOVE; - wm_event_add(win, event); - - { - wmEvent *event_new = win->queue.last; - if (event_last == NULL) { - event_last = win->eventstate; - } - - copy_v2_v2_int(&event_new->prevx, &event_last->x); + wmEvent *event_new = wm_event_add(win, event); + if (event_last == NULL) { + event_last = win->eventstate; } + + copy_v2_v2_int(&event_new->prevx, &event_last->x); + return event_new; } /* windows store own event queues, no bContext here */ @@ -3245,8 +3245,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U wm_stereo3d_mouse_offset_apply(win, &event.x); event.type = MOUSEMOVE; - wm_event_add_mousemove(win, &event); - copy_v2_v2_int(&evt->x, &event.x); + { + wmEvent *event_new = wm_event_add_mousemove(win, &event); + copy_v2_v2_int(&evt->x, &event_new->x); + evt->is_motion_absolute = event_new->is_motion_absolute; + } /* also add to other window if event is there, this makes overdraws disappear nicely */ /* it remaps mousecoord to other window in event */ @@ -3258,8 +3261,11 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U copy_v2_v2_int(&oevent.x, &event.x); oevent.type = MOUSEMOVE; - wm_event_add_mousemove(owin, &oevent); - copy_v2_v2_int(&oevt->x, &oevent.x); + { + wmEvent *event_new = wm_event_add_mousemove(owin, &oevent); + copy_v2_v2_int(&oevt->x, &event_new->x); + oevt->is_motion_absolute = event_new->is_motion_absolute; + } } break; |