diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-10-17 23:32:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-10-17 23:32:28 +0400 |
commit | 69c6a33ba1a064aa13da3ef6a74b310620cfafd5 (patch) | |
tree | 69eb569feb0f03d912391651b7fde6c66c43be98 /source/blender/windowmanager | |
parent | 484bf962c66a5ffb7592cf8e4b462dbfb8d21214 (diff) |
wrap the mouse within the region while grabbing so on release the current view never changes and less likelyhood of loosing the cursor when running blender on 2+ screens. (assuming the 3d view isnt stretched over both)
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_cursors.c | 7 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 16 |
3 files changed, 19 insertions, 6 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index d90d812d0bb..59f3bcd4edc 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -76,7 +76,7 @@ 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(struct wmWindow *win, int wrap, int hide); +void WM_cursor_grab(struct wmWindow *win, int wrap, int hide, int *bounds); void WM_cursor_ungrab(struct wmWindow *win); void WM_timecursor (struct wmWindow *win, int nr); diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 1d5b10f2583..5fe62157979 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -163,26 +163,27 @@ void WM_cursor_wait(int val) } } -void WM_cursor_grab(wmWindow *win, int wrap, int hide) +void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds) { /* Only grab cursor when not running debug. * It helps not to get a stuck WM when hitting a breakpoint * */ GHOST_TGrabCursorMode mode = GHOST_kGrabNormal; + int bounds_arr[4] = {-1, -1, -1, -1}; /* l/t/r/b */ if(hide) mode = GHOST_kGrabHide; else if(wrap) mode = GHOST_kGrabWrap; if ((G.f & G_DEBUG) == 0) if(win) - GHOST_SetCursorGrab(win->ghostwin, mode); + GHOST_SetCursorGrab(win->ghostwin, mode, bounds); } void WM_cursor_ungrab(wmWindow *win) { if ((G.f & G_DEBUG) == 0) if(win) - GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable); + GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL); } /* afer this you can call restore too */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 9e5f982880e..8eca0a1b416 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -463,8 +463,20 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P else if(retval & OPERATOR_RUNNING_MODAL) { /* grab cursor during blocking modal ops (X11) */ if(ot->flag & OPTYPE_BLOCKING) { - int warp = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->flag & OP_GRAB_POINTER) || (ot->flag & OPTYPE_GRAB_POINTER)); - WM_cursor_grab(CTX_wm_window(C), warp, FALSE); + int bounds[4] = {-1,-1,-1,-1}; + int wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->flag & OP_GRAB_POINTER) || (ot->flag & OPTYPE_GRAB_POINTER)); + + if(wrap) { + ARegion *ar= CTX_wm_region(C); + if(ar) { + bounds[0]= ar->winrct.xmin; + bounds[1]= ar->winrct.ymax; + bounds[2]= ar->winrct.xmax; + bounds[3]= ar->winrct.ymin; + } + } + + WM_cursor_grab(CTX_wm_window(C), wrap, FALSE, bounds); } } else |