diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-01-10 05:57:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-01-10 06:01:09 +0300 |
commit | 5ff33ecdf0ed319db2e589926a614f67738531a6 (patch) | |
tree | 75646e8ba2b3520716adb44e9fda7db84be84aa8 /source/blender/windowmanager | |
parent | 5c3dc01f54703e844893e55230ebafb9e4bdcd18 (diff) | |
parent | cacba951eaa266c7fc53cd25be6afc0fb7951425 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/windowmanager')
5 files changed, 36 insertions, 33 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1db84b7d2ee..e3f53e4b5cb 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -214,7 +214,6 @@ struct wmEventHandler *WM_event_add_dropbox_handler(ListBase *handlers, ListBase /* mouse */ void WM_event_add_mousemove(struct bContext *C); bool WM_event_is_modal_tweak_exit(const struct wmEvent *event, int tweak_event); -bool WM_event_is_absolute(const struct wmEvent *event); bool WM_event_is_last_mousemove(const struct wmEvent *event); #ifdef WITH_INPUT_NDOF @@ -232,11 +231,11 @@ void WM_report_banner_show(void); void WM_report(ReportType type, const char *message); void WM_reportf(ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(2, 3); -void wm_event_add_ex( +struct wmEvent *wm_event_add_ex( struct wmWindow *win, const struct wmEvent *event_to_add, const struct wmEvent *event_to_add_after) ATTR_NONNULL(1, 2); -void wm_event_add( +struct wmEvent *wm_event_add( struct wmWindow *win, const struct wmEvent *event_to_add) ATTR_NONNULL(1, 2); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 9edae85cc3c..883a680acd7 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -473,8 +473,9 @@ typedef struct wmEvent { short keymodifier; /* rawkey modifier */ /* set in case a KM_PRESS went by unhandled */ - short check_click; - + char check_click; + char is_motion_absolute; + /* keymap item, set by handler (weak?) */ const char *keymap_idname; 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 3d5016af94b..154e120cde8 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -97,7 +97,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"); @@ -105,6 +105,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); } @@ -112,11 +119,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) @@ -689,11 +697,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)) { @@ -3523,7 +3526,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; @@ -3533,16 +3536,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 */ @@ -3572,8 +3572,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 */ @@ -3585,8 +3588,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; diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c index bf9b5b72c67..d051c93d892 100644 --- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c +++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c @@ -906,7 +906,7 @@ void wm_manipulatormap_modal_set( mmap->mmap_context.modal = mpr; if ((mpr->flag & WM_MANIPULATOR_GRAB_CURSOR) && - (WM_event_is_absolute(event) == false)) + (event->is_motion_absolute == false)) { WM_cursor_grab_enable(win, true, true, NULL); copy_v2_v2_int(mmap->mmap_context.event_xy, &event->x); |