diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_time/time_header.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_header.c | 10 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_operator.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 98 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 7 |
7 files changed, 82 insertions, 59 deletions
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index fe7e236a841..dca77b94a14 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1685,7 +1685,7 @@ static void operator_cb(bContext *C, void *arg, int retval) const char *opname= arg; if(opname && retval > 0) - WM_operator_name_call(C, opname, WM_OP_DEFAULT, NULL); + WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, NULL); } static void vconfirm(bContext *C, char *opname, char *title, char *itemfmt, va_list ap) diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c index 406ccf0b54c..04f01803c1c 100644 --- a/source/blender/editors/space_time/time_header.c +++ b/source/blender/editors/space_time/time_header.c @@ -302,18 +302,18 @@ static uiBlock *time_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg block= uiBeginBlock(C, handle->region, "time_framemenu", UI_EMBOSSP, UI_HELV); uiBlockSetButmFunc(block, do_time_framemenu, NULL); - uiDefIconTextButO(C, block, BUTM, "ED_MARKER_OT_add", WM_OP_REGION_WIN, ICON_BLANK1, "Add Marker", + uiDefIconTextButO(C, block, BUTM, "ED_MARKER_OT_add", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Add Marker", 0, yco-=2, menuwidth, 19, ""); - uiDefIconTextButO(C, block, BUTM, "ED_MARKER_OT_duplicate", WM_OP_REGION_WIN, ICON_BLANK1, "Duplicate Marker", + uiDefIconTextButO(C, block, BUTM, "ED_MARKER_OT_duplicate", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Duplicate Marker", 0, yco-=20, menuwidth, 19, ""); - uiDefIconTextButO(C, block, BUTM, "ED_MARKER_OT_delete", WM_OP_REGION_WIN, ICON_BLANK1, "Delete Marker", + uiDefIconTextButO(C, block, BUTM, "ED_MARKER_OT_delete", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Delete Marker", 0, yco-=20, menuwidth, 19, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Name Marker|Ctrl M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextButO(C, block, BUTM, "ED_MARKER_OT_move", WM_OP_REGION_WIN, ICON_BLANK1, "Grab/Move Marker", + uiDefIconTextButO(C, block, BUTM, "ED_MARKER_OT_move", WM_OP_INVOKE_REGION_WIN, ICON_BLANK1, "Grab/Move Marker", 0, yco-=20, menuwidth, 19, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 3cd2e464321..35c686bc54e 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -461,7 +461,7 @@ static void do_view3d_view_alignviewmenu(bContext *C, void *arg, int event) // XXX mainqenter(PADASTERKEY, 1); break; case 6: /* Center View and Cursor to Origin */ - WM_operator_name_call(C, "VIEW3D_OT_viewcenter", WM_OP_REGION_WIN, NULL); + WM_operator_name_call(C, "VIEW3D_OT_viewcenter", WM_OP_EXEC_REGION_WIN, NULL); curs= give_cursor(scene, v3d); curs[0]=curs[1]=curs[2]= 0.0; break; @@ -545,10 +545,10 @@ static void do_view3d_viewmenu(bContext *C, void *arg, int event) endlocalview(scene, sa); break; case 9: /* View All (Home) */ - WM_operator_name_call(C, "VIEW3D_OT_viewhome", WM_OP_REGION_WIN, NULL); + WM_operator_name_call(C, "VIEW3D_OT_viewhome", WM_OP_EXEC_REGION_WIN, NULL); break; case 11: /* View Selected */ - WM_operator_name_call(C, "VIEW3D_OT_viewcenter", WM_OP_REGION_WIN, NULL); + WM_operator_name_call(C, "VIEW3D_OT_viewcenter", WM_OP_EXEC_REGION_WIN, NULL); break; case 13: /* Play Back Animation */ play_anim(0); @@ -560,7 +560,7 @@ static void do_view3d_viewmenu(bContext *C, void *arg, int event) add_blockhandler(sa, VIEW3D_HANDLER_PROPERTIES, UI_PNL_UNSTOW); break; case 17: /* Set Clipping Border */ - WM_operator_name_call(C, "VIEW3D_OT_clipping", WM_OP_REGION_WIN, NULL); + WM_operator_name_call(C, "VIEW3D_OT_clipping", WM_OP_INVOKE_REGION_WIN, NULL); break; case 18: /* render preview */ toggle_blockhandler(sa, VIEW3D_HANDLER_PREVIEW, 0); @@ -5325,7 +5325,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) switch(event) { case B_HOME: - WM_operator_name_call(C, "VIEW3D_OT_viewhome", WM_OP_REGION_WIN, NULL); + WM_operator_name_call(C, "VIEW3D_OT_viewhome", WM_OP_EXEC_REGION_WIN, NULL); break; case B_SCENELOCK: if(v3d->scenelock) { diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index b2cda269751..966253f82a8 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -167,7 +167,7 @@ static PyObject * pyop_func_call(BPy_OperatorFunc * self, PyObject *args, PyObje } if (error_val==0) { - WM_operator_name_call(self->C, self->name, WM_OP_DEFAULT, properties); + WM_operator_name_call(self->C, self->name, WM_OP_EXEC_DEFAULT, properties); } if (properties) { diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 21d245b08c9..687a8a6628c 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -41,12 +41,16 @@ struct wmEvent; /* flag */ #define OPTYPE_REGISTER 1 -/* context to call operator in for WM_operator_call */ +/* context to call operator in for WM_operator_name_call */ enum { - WM_OP_DEFAULT, - WM_OP_REGION_WIN, - WM_OP_AREA, - WM_OP_SCREEN + WM_OP_INVOKE_DEFAULT, + WM_OP_INVOKE_REGION_WIN, + WM_OP_INVOKE_AREA, + WM_OP_INVOKE_SCREEN, + WM_OP_EXEC_DEFAULT, + WM_OP_EXEC_REGION_WIN, + WM_OP_EXEC_AREA, + WM_OP_EXEC_SCREEN }; /* ************** wmEvent ************************ */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index b9bc38c5927..c10b2b2e28c 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -319,10 +319,12 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, I op->ptr= MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA"); RNA_pointer_create(&RNA_WindowManager, &wm->id, ot->srna, &op->properties, op->ptr); - if(op->type->invoke) + if(op->type->invoke && event) retval= (*op->type->invoke)(C, op, event); else if(op->type->exec) retval= op->type->exec(C, op); + else + printf("invalid operator call %s\n", ot->idname); /* debug, important to leave a while, should never happen */ /* only for testing, can remove any time */ WM_operator_print(op); @@ -343,56 +345,72 @@ int WM_operator_name_call(bContext *C, const char *opstring, int context, IDProp { wmOperatorType *ot= WM_operatortype_find(opstring); wmWindow *window= CTX_wm_window(C); + wmEvent *event= window->eventstate; + int retval; /* dummie test */ if(ot && C && window) { - if(context == WM_OP_REGION_WIN) { - /* forces event to go to the region window, for header menus */ - ARegion *ar= CTX_wm_region(C); - ScrArea *area= CTX_wm_area(C); + switch(context) { - if(area) { - ARegion *ar1= area->regionbase.first; - for(; ar1; ar1= ar1->next) - if(ar1->regiontype==RGN_TYPE_WINDOW) - break; - if(ar1) - CTX_wm_region_set(C, ar1); + case WM_OP_EXEC_REGION_WIN: + event= NULL; /* pass on without break */ + case WM_OP_INVOKE_REGION_WIN: + { + /* forces operator to go to the region window, for header menus */ + ARegion *ar= CTX_wm_region(C); + ScrArea *area= CTX_wm_area(C); + + if(area) { + ARegion *ar1= area->regionbase.first; + for(; ar1; ar1= ar1->next) + if(ar1->regiontype==RGN_TYPE_WINDOW) + break; + if(ar1) + CTX_wm_region_set(C, ar1); + } + + retval= wm_operator_invoke(C, ot, event, properties); + + /* set region back */ + CTX_wm_region_set(C, ar); + + return retval; } - - retval= wm_operator_invoke(C, ot, window->eventstate, properties); - - /* set region back */ - CTX_wm_region_set(C, ar); - - return retval; - } - else if(context == WM_OP_AREA) { - /* remove region from context */ - ARegion *ar= CTX_wm_region(C); + case WM_OP_EXEC_AREA: + event= NULL; /* pass on without break */ + case WM_OP_INVOKE_AREA: + { + /* remove region from context */ + ARegion *ar= CTX_wm_region(C); - CTX_wm_region_set(C, NULL); - retval= wm_operator_invoke(C, ot, window->eventstate, properties); - CTX_wm_region_set(C, ar); + CTX_wm_region_set(C, NULL); + retval= wm_operator_invoke(C, ot, event, properties); + CTX_wm_region_set(C, ar); - return retval; - } - else if(context == WM_OP_SCREEN) { - /* remove region + area from context */ - ARegion *ar= CTX_wm_region(C); - ScrArea *area= CTX_wm_area(C); + return retval; + } + case WM_OP_EXEC_SCREEN: + event= NULL; /* pass on without break */ + case WM_OP_INVOKE_SCREEN: + { + /* remove region + area from context */ + ARegion *ar= CTX_wm_region(C); + ScrArea *area= CTX_wm_area(C); - CTX_wm_region_set(C, NULL); - CTX_wm_area_set(C, NULL); - retval= wm_operator_invoke(C, ot, window->eventstate, properties); - CTX_wm_region_set(C, ar); - CTX_wm_area_set(C, area); + CTX_wm_region_set(C, NULL); + CTX_wm_area_set(C, NULL); + retval= wm_operator_invoke(C, ot, window->eventstate, properties); + CTX_wm_region_set(C, ar); + CTX_wm_area_set(C, area); - return retval; + return retval; + } + case WM_OP_EXEC_DEFAULT: + event= NULL; /* pass on without break */ + case WM_OP_INVOKE_DEFAULT: + return wm_operator_invoke(C, ot, event, properties); } - else - return wm_operator_invoke(C, ot, window->eventstate, properties); } return 0; diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 22616a49af1..eac51559269 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -39,6 +39,7 @@ #include "BKE_context.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_utildefines.h" #include "RNA_access.h" #include "RNA_types.h" @@ -519,7 +520,7 @@ char *WM_key_event_operator_string(bContext *C, char *opname, int opcontext, cha ListBase *handlers= NULL; /* find right handler list based on specified context */ - if(opcontext == WM_OP_REGION_WIN) { + if(ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) { if(CTX_wm_area(C)) { ARegion *ar= CTX_wm_area(C)->regionbase.first; for(; ar; ar= ar->next) @@ -530,11 +531,11 @@ char *WM_key_event_operator_string(bContext *C, char *opname, int opcontext, cha handlers= &ar->handlers; } } - else if(opcontext == WM_OP_AREA) { + else if(ELEM(opcontext, WM_OP_EXEC_AREA, WM_OP_INVOKE_AREA)) { if(CTX_wm_area(C)) handlers= &CTX_wm_area(C)->handlers; } - else if(opcontext == WM_OP_SCREEN) { + else if(ELEM(opcontext, WM_OP_EXEC_SCREEN, WM_OP_INVOKE_SCREEN)) { if(CTX_wm_window(C)) handlers= &CTX_wm_window(C)->handlers; } |