diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-09-22 17:23:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-09-22 17:23:12 +0400 |
commit | 1541ee20c87fe5b981b81ab3add6fa0df29e91d1 (patch) | |
tree | b41500bcd4aab6afc2c82c2156bcb4db8152ad66 /source | |
parent | 9bb90f4d8510a64ab0435f86659eb169db423613 (diff) |
Improvement to own commit r50810.
Add an optional ghost argument to set the new mouse location when un-grabbing. - without this the mouse would flicker at the old location before moving to the new location - when using the color picker for eg.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 4 |
4 files changed, 22 insertions, 12 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 0da029f1363..a1f6b4bbd38 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5372,14 +5372,21 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s else if (data->state == BUTTON_STATE_NUM_EDITING) { ui_numedit_end(but, data); if (ui_is_a_warp_but(but)) { - WM_cursor_grab_disable(CTX_wm_window(C)); - /* XXX, you can see that the cursor is revealed, then moved - should do at once */ #ifdef USE_CONT_MOUSE_CORRECT if (data->ungrab_mval[0] != FLT_MAX) { + int mouse_ungrab_xy[2]; ui_block_to_window_fl(data->region, but->block, &data->ungrab_mval[0], &data->ungrab_mval[1]); - WM_cursor_warp(CTX_wm_window(C), data->ungrab_mval[0], data->ungrab_mval[1]); + mouse_ungrab_xy[0] = data->ungrab_mval[0]; + mouse_ungrab_xy[1] = data->ungrab_mval[1]; + + WM_cursor_grab_disable(data->window, mouse_ungrab_xy); + } + else { + WM_cursor_grab_disable(data->window, NULL); } +#else + WM_cursor_grab_disable(data->window, ); #endif } } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 0ef94f3db61..9570638fb25 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -114,8 +114,8 @@ void WM_cursor_set (struct wmWindow *win, int curs); void WM_cursor_modal (struct wmWindow *win, int curs); void WM_cursor_restore (struct wmWindow *win); void WM_cursor_wait (int val); -void WM_cursor_grab_enable(struct wmWindow *win, int wrap, int hide, int *bounds); -void WM_cursor_grab_disable(struct wmWindow *win); +void WM_cursor_grab_enable(struct wmWindow *win, int wrap, int hide, int bounds[4]); +void WM_cursor_grab_disable(struct wmWindow *win, int mouse_ungrab_xy[2]); void WM_cursor_time (struct wmWindow *win, int nr); void *WM_paint_cursor_activate(struct wmWindowManager *wm, diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 6fc6a57ade1..7853b40c98a 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -179,7 +179,10 @@ void WM_cursor_wait(int val) } } -void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int *bounds) +/** + * \param bounds can be NULL + */ +void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int bounds[4]) { /* Only grab cursor when not running debug. * It helps not to get a stuck WM when hitting a breakpoint @@ -193,20 +196,20 @@ void WM_cursor_grab_enable(wmWindow *win, int wrap, int hide, int *bounds) 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); + GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); else if (tabletdata->Active == GHOST_kTabletModeNone) - GHOST_SetCursorGrab(win->ghostwin, mode, bounds); + GHOST_SetCursorGrab(win->ghostwin, mode, bounds, NULL); win->grabcursor = mode; } } } -void WM_cursor_grab_disable(wmWindow *win) +void WM_cursor_grab_disable(wmWindow *win, int mouse_ungrab_xy[2]) { if ((G.debug & G_DEBUG) == 0) { if (win && win->ghostwin) { - GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL); + GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL, mouse_ungrab_xy); win->grabcursor = GHOST_kGrabDisable; } } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 17f17baba0e..c05d9532f74 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1202,7 +1202,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) CTX_wm_region_set(C, region); } - WM_cursor_grab_disable(CTX_wm_window(C)); + WM_cursor_grab_disable(CTX_wm_window(C), NULL); WM_operator_free(handler->op); } else if (handler->ui_remove) { @@ -1432,7 +1432,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand /* remove modal handler, operator itself should have been canceled and freed */ if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) { - WM_cursor_grab_disable(CTX_wm_window(C)); + WM_cursor_grab_disable(CTX_wm_window(C), NULL); BLI_remlink(handlers, handler); wm_event_free_handler(handler); |