wrap the mouse within the region while grabbing so on release the current view never...
[blender-staging.git] / source / blender / windowmanager / intern / wm_event_system.c
index 9e5f982880e011f490fa2575e7f42ff07187d799..8eca0a1b416ba5ac93c586d0a9e7ad726e3fbcc0 100644 (file)
@@ -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