svn merge ^/trunk/blender -r48004:48011
[blender.git] / source / blender / windowmanager / intern / wm_event_system.c
index 42fb03d5d6480aec0fe9629074f58952737af4df..3d483c06419d9d07c503466fead32f9257979c4f 100644 (file)
@@ -194,7 +194,7 @@ void wm_event_do_notifiers(bContext *C)
        
        /* cache & catch WM level notifiers, such as frame change, scene/screen set */
        for (win = wm->windows.first; win; win = win->next) {
-               int do_anim = 0;
+               int do_anim = FALSE;
                
                CTX_wm_window_set(C, win);
                
@@ -229,7 +229,7 @@ void wm_event_do_notifiers(bContext *C)
                        {
                                if (note->category == NC_SCENE) {
                                        if (note->data == ND_FRAME)
-                                               do_anim = 1;
+                                               do_anim = TRUE;
                                }
                        }
                        if (ELEM5(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_SCENE, NC_WM)) {
@@ -240,12 +240,12 @@ void wm_event_do_notifiers(bContext *C)
                if (do_anim) {
 
                        /* XXX, quick frame changes can cause a crash if framechange and rendering
-                        * collide (happens on slow scenes), scene_update_for_newframe can be called
+                        * collide (happens on slow scenes), BKE_scene_update_for_newframe can be called
                         * twice which can depgraph update the same object at once */
                        if (!G.rendering) {
 
                                /* depsgraph gets called, might send more notifiers */
-                               ED_update_for_newframe(CTX_data_main(C), win->screen->scene, win->screen, 1);
+                               ED_update_for_newframe(CTX_data_main(C), win->screen->scene, 1);
                        }
                }
        }
@@ -311,7 +311,7 @@ void wm_event_do_notifiers(bContext *C)
                        /* XXX, hack so operators can enforce datamasks [#26482], gl render */
                        win->screen->scene->customdata_mask |= win->screen->scene->customdata_mask_modal;
 
-                       scene_update_tagged(bmain, win->screen->scene);
+                       BKE_scene_update_tagged(bmain, win->screen->scene);
                }
        }
 
@@ -331,17 +331,17 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve
        ScrArea *area = CTX_wm_area(C);
        ARegion *region = CTX_wm_region(C);
        ARegion *menu = CTX_wm_menu(C);
-       static int do_wheel_ui = 1;
+       static int do_wheel_ui = TRUE;
        int is_wheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE);
        int retval;
        
        /* UI is quite aggressive with swallowing events, like scrollwheel */
        /* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */
-       if (do_wheel_ui == 0) {
+       if (do_wheel_ui == FALSE) {
                if (is_wheel)
                        return WM_HANDLER_CONTINUE;
                else if (wm_event_always_pass(event) == 0)
-                       do_wheel_ui = 1;
+                       do_wheel_ui = TRUE;
        }
        
        /* we set context to where ui handler came from */
@@ -369,7 +369,7 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve
        
        /* event not handled in UI, if wheel then we temporarily disable it */
        if (is_wheel)
-               do_wheel_ui = 0;
+               do_wheel_ui = FALSE;
        
        return WM_HANDLER_CONTINUE;
 }
@@ -691,7 +691,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P
                if (properties) {
                        otmacro = ot->macro.first;
 
-                       RNA_STRUCT_BEGIN(properties, prop)
+                       RNA_STRUCT_BEGIN (properties, prop)
                        {
 
                                if (otmacro == NULL)
@@ -747,6 +747,7 @@ static void wm_region_mouse_co(bContext *C, wmEvent *event)
        }
 }
 
+#if 1 /* disabling for 2.63 release, since we keep getting reports some menu items are leaving props undefined */
 int WM_operator_last_properties_init(wmOperator *op)
 {
        int change = FALSE;
@@ -760,7 +761,8 @@ int WM_operator_last_properties_init(wmOperator *op)
 
                iterprop = RNA_struct_iterator_property(op->type->srna);
 
-               RNA_PROP_BEGIN(op->ptr, itemptr, iterprop) {
+               RNA_PROP_BEGIN (op->ptr, itemptr, iterprop)
+               {
                        PropertyRNA *prop = itemptr.data;
                        if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
                                if (!RNA_property_is_set(op->ptr, prop)) { /* don't override a setting already set */
@@ -805,6 +807,20 @@ int WM_operator_last_properties_store(wmOperator *op)
        }
 }
 
+#else
+
+int WM_operator_last_properties_init(wmOperator *UNUSED(op))
+{
+       return FALSE;
+}
+
+int WM_operator_last_properties_store(wmOperator *UNUSED(op))
+{
+       return FALSE;
+}
+
+#endif
+
 static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties, ReportList *reports, short poll_only)
 {
        wmWindowManager *wm = CTX_wm_manager(C);
@@ -815,7 +831,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
                return WM_operator_poll(C, ot);
 
        if (WM_operator_poll(C, ot)) {
-               wmOperator *op = wm_operator_create(wm, ot, properties, reports); /* if reports==NULL, theyll be initialized */
+               wmOperator *op = wm_operator_create(wm, ot, properties, reports); /* if reports == NULL, they'll be initialized */
                const short is_nested_call = (wm->op_undo_depth != 0);
                
                /* initialize setting from previous run */
@@ -851,7 +867,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
                }
                else {
                        /* debug, important to leave a while, should never happen */
-                       printf("invalid operator call '%s'\n", ot->idname);
+                       printf("%s: invalid operator call '%s'\n", __func__, ot->idname);
                }
                
                /* Note, if the report is given as an argument then assume the caller will deal with displaying them
@@ -1420,8 +1436,9 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
                        }
                        
                }
-               else
-                       printf("wm_handler_operator_call error\n");
+               else {
+                       printf("%s: error - missing modal\n", __func__);
+               }
        }
        else {
                wmOperatorType *ot = WM_operatortype_find(event->keymap_idname, 0);
@@ -1523,7 +1540,8 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
                                /* a bit weak, might become arg for WM_event_fileselect? */
                                /* XXX also extension code in image-save doesnt work for this yet */
                                if (RNA_struct_find_property(handler->op->ptr, "check_existing") &&
-                                   RNA_boolean_get(handler->op->ptr, "check_existing")) {
+                                   RNA_boolean_get(handler->op->ptr, "check_existing"))
+                               {
                                        char *path = RNA_string_get_alloc(handler->op->ptr, "filepath", NULL, 0);
                                        /* this gives ownership to pupmenu */
                                        uiPupMenuSaveOver(C, handler->op, (path) ? path : "");
@@ -1847,7 +1865,7 @@ static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *ar)
                for (; pc; pc = pc->next) {
                        if (pc->poll == NULL || pc->poll(C)) {
                                wmWindow *win = CTX_wm_window(C);
-                               win->screen->do_draw_paintcursor = 1;
+                               win->screen->do_draw_paintcursor = TRUE;
                                wm_tag_redraw_overlay(win, ar);
                        }
                }
@@ -1886,10 +1904,10 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even
        if (wm->drags.first == NULL) return;
        
        if (event->type == MOUSEMOVE)
-               win->screen->do_draw_drag = 1;
+               win->screen->do_draw_drag = TRUE;
        else if (event->type == ESCKEY) {
                BLI_freelistN(&wm->drags);
-               win->screen->do_draw_drag = 1;
+               win->screen->do_draw_drag = TRUE;
        }
        else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                event->type = EVT_DROP;
@@ -1905,7 +1923,7 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even
                event->customdatafree = 1;
                
                /* clear drop icon */
-               win->screen->do_draw_drag = 1;
+               win->screen->do_draw_drag = TRUE;
                
                /* restore cursor (disabled, see wm_dragdrop.c) */
                // WM_cursor_restore(win);
@@ -1914,7 +1932,7 @@ static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *even
        /* overlap fails otherwise */
        if (win->screen->do_draw_drag)
                if (win->drawmethod == USER_DRAW_OVERLAP)
-                       win->screen->do_draw = 1;
+                       win->screen->do_draw = TRUE;
        
 }
 
@@ -1944,7 +1962,7 @@ void wm_event_do_handlers(bContext *C)
                                        CTX_wm_screen_set(C, win->screen);
                                        CTX_data_scene_set(C, scene);
                                        
-                                       if (((playing == 1) && (!win->screen->animtimer)) || ((playing == 0) && (win->screen->animtimer))) {
+                                       if (((playing == 1) && (!ED_screen_animation_playing(wm))) || ((playing == 0) && (ED_screen_animation_playing(wm)))) {
                                                ED_screen_animation_play(C, -1, 1);
                                        }
                                        
@@ -1954,7 +1972,7 @@ void wm_event_do_handlers(bContext *C)
                                                        int ncfra = sound_sync_scene(scene) * (float)FPS + 0.5f;
                                                        if (ncfra != scene->r.cfra) {
                                                                scene->r.cfra = ncfra;
-                                                               ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
+                                                               ED_update_for_newframe(CTX_data_main(C), scene, 1);
                                                                WM_event_add_notifier(C, NC_WINDOW, NULL);
                                                        }
                                                }
@@ -2008,7 +2026,7 @@ void wm_event_do_handlers(bContext *C)
                                /* Note: setting subwin active should be done here, after modal handlers have been done */
                                if (event->type == MOUSEMOVE) {
                                        /* state variables in screen, cursors. Also used in wm_draw.c, fails for modal handlers though */
-                                       ED_screen_set_subwinactive(C, event);   
+                                       ED_screen_set_subwinactive(C, event);
                                        /* for regions having custom cursors */
                                        wm_paintcursor_test(C, event);
                                }
@@ -2243,7 +2261,7 @@ wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap
        wmEventHandler *handler;
 
        if (!keymap) {
-               printf("WM_event_add_keymap_handler called with NULL keymap\n");
+               printf("%s: called with NULL keymap\n", __func__);
                return NULL;
        }
 
@@ -2596,7 +2614,8 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
                        
                        if (owin != win) {
                                if (mx - owin->posx >= 0 && my - owin->posy >= 0 &&
-                                   mx - owin->posx <= owin->sizex && my - owin->posy <= owin->sizey) {
+                                   mx - owin->posx <= owin->sizex && my - owin->posy <= owin->sizey)
+                               {
                                        evt->x = mx - (int)owin->posx;
                                        evt->y = my - (int)owin->posy;
                                        
@@ -2685,7 +2704,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                                event.y = evt->y = (win->sizey - 1) - cy;
                        }
 
-                       // Use prevx/prevy so we can calculate the delta later
+                       /* Use prevx/prevy so we can calculate the delta later */
                        event.prevx = event.x - pd->deltaX;
                        event.prevy = event.y - (-pd->deltaY);
                        
@@ -2698,7 +2717,6 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
                case GHOST_kEventButtonUp: {
                        GHOST_TEventButtonData *bd = customdata;
 
-                       /* Note!, this starts as 0/1 but later is converted to KM_PRESS/KM_RELEASE by tweak */
                        event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE;
                        
                        if (bd->button == GHOST_kButtonMaskLeft)