Add operator and operator type flag for GRAB_POINTER, don't coopt the OPTYPE_BLOCKING...
authorMartin Poirier <theeth@yahoo.com>
Sat, 10 Oct 2009 17:19:49 +0000 (17:19 +0000)
committerMartin Poirier <theeth@yahoo.com>
Sat, 10 Oct 2009 17:19:49 +0000 (17:19 +0000)
It will check if either the operator or operator type flags are set on top of the user preference before grabbing the pointer.

I've set that flag for 3d view navigation operators, others should be set too (no transform, I'll deal with that one).

source/blender/editors/space_view3d/view3d_edit.c
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_event_system.c

index 4c96e1fee3904408d387fd35a946f9746f77191c..3cd810d5c167e0508a7abe4f6e01eb7e2f3f2608 100644 (file)
@@ -621,7 +621,7 @@ void VIEW3D_OT_rotate(wmOperatorType *ot)
        ot->poll= ED_operator_view3d_active;
 
        /* flags */
-       ot->flag= OPTYPE_BLOCKING;
+       ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
 }
 
 /* ************************ viewmove ******************************** */
@@ -743,7 +743,7 @@ void VIEW3D_OT_move(wmOperatorType *ot)
        ot->poll= ED_operator_view3d_active;
 
        /* flags */
-       ot->flag= OPTYPE_BLOCKING;
+       ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
 }
 
 /* ************************ viewzoom ******************************** */
@@ -976,7 +976,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
        ot->poll= ED_operator_view3d_active;
 
        /* flags */
-       ot->flag= OPTYPE_BLOCKING;
+       ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
 
        RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
 }
index 2b986d6d80273f52aba5da092733a681555646d8..0292f01fd6d290acbabbced75ba6a9636b305428 100644 (file)
@@ -330,7 +330,7 @@ typedef struct wmOperator {
 #define OPERATOR_PASS_THROUGH  8
 
 /* wmOperator flag */
-
+#define OP_GRAB_POINTER                        1
 
 /* ************** wmEvent ************************ */
 /* for read-only rna access, dont save this */
index d746df014210051f0a017084da4939dab820ffe2..31cb5ee083297486f3aaff838cf7083f6d00df91 100644 (file)
@@ -44,6 +44,7 @@ struct wmWindowManager;
 #define OPTYPE_UNDO                    2       /* do undo push after after */
 #define OPTYPE_BLOCKING                4       /* let blender grab all input from the WM (X11) */
 #define OPTYPE_MACRO           8
+#define OPTYPE_GRAB_POINTER    16      /* */
 
 /* context to call operator in for WM_operator_name_call */
 /* rna_ui.c contains EnumPropertyItem's of these, keep in sync */
index ea73ed38123e590837038dd43a26e63d74e37dbb..f1104feaf5b067c22d7f8a455bff4daa69397b12 100644 (file)
@@ -462,8 +462,10 @@ 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)
-                               WM_cursor_grab(CTX_wm_window(C), (U.uiflag & USER_CONTINUOUS_MOUSE));
+                       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);
+                       }
                }
                else
                        WM_operator_free(op);