2.5: Handlers are now evaluated in a different order, fixing some
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 18 Sep 2009 12:43:36 +0000 (12:43 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 18 Sep 2009 12:43:36 +0000 (12:43 +0000)
issues like Shift+R (repeat last) not giving capital R in the text
editor. There is also new modal handler list at the window level,
and the API call will always add it to that one now, since modal
handlers were not used in other levels.

The order used to be:
* window modal + keymap
* area modal + keymap
* region modal + keymap

Now it is:
* window modal
* region keymap
* area keymap
* window keymap

28 files changed:
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/animation/anim_ops.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/armature/poselib.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/mesh/loopcut.c
source/blender/editors/physics/editparticle.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/transform/transform_ops.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c

index 0cbbc1051e73a0e80ce5b1b1669bf487e344e609..c5dcf1ce5202192b4239884a56d89523a0b733a0 100644 (file)
@@ -4371,6 +4371,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
                win->timers.first= win->timers.last= NULL;
                win->queue.first= win->queue.last= NULL;
                win->handlers.first= win->handlers.last= NULL;
+               win->modalhandlers.first= win->modalhandlers.last= NULL;
                win->subwindows.first= win->subwindows.last= NULL;
                win->gesture.first= win->gesture.last= NULL;
 
index 06fa3b715e0c9293464ea9b8d3773da943be89b6..bed534ae070ecfcc8589bac37d688e17cfb3cc36 100644 (file)
@@ -458,7 +458,7 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, wmEvent *evt)
                mm->event_type= evt->type;
                
                /* add temp handler */
-               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               WM_event_add_modal_handler(C, op);
                
                /* reset frs delta */
                RNA_int_set(op->ptr, "frames", 0);
index 186bdc3b7624b7687c53f9f5922a78cea00427e4..80077a6d4b3c5ddd11f525a4384d91dbe24f81a7 100644 (file)
@@ -162,7 +162,7 @@ static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event)
        change_frame_apply(C, op);
        
        /* add temp handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
index 79d3d7b1366d7662259ff304aa2775bc981a1d41..1e416d9c31d4e74cc64290f1355b39f6e428362f 100644 (file)
@@ -2618,7 +2618,7 @@ static int sketch_draw_stroke(bContext *C, wmOperator *op, wmEvent *event)
 
        sk_draw_stroke(C, sketch, sketch->active_stroke, dd, snap);
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
@@ -2644,7 +2644,7 @@ static int sketch_draw_gesture(bContext *C, wmOperator *op, wmEvent *event)
        sk_start_draw_gesture(sketch);
        sk_draw_stroke(C, sketch, sketch->gesture, dd, snap);
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
index c332a297e57617b5d6593b82bae576f23584cb71..f072f2e980e40e1cccda72ecbdecb52565c4ed10 100644 (file)
@@ -1411,7 +1411,7 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, wmEvent *event)
        poselib_preview_apply(C, op);
        
        /* add temp handler if we're running as a modal operator */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
index 99b85d62026776cb7328640089a27f361e1a8e45..92ae2400666a61f505303f7cc21dee871428f240 100644 (file)
@@ -1341,7 +1341,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event)
        }
        
        /* add a modal handler for this operator, so that we can then draw continuous strokes */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        return OPERATOR_RUNNING_MODAL;
 }
 
index 246058ceacc957a167537f7b024c8a8b409eb9ef..e8d813d8ff9a296bf59f99ab27607317abe27f7d 100644 (file)
@@ -3660,11 +3660,11 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
        if(!(but->block->handle && but->block->handle->popup)) {
                if(button_modal_state(state)) {
                        if(!button_modal_state(data->state))
-                               WM_event_add_ui_handler(C, &data->window->handlers, ui_handler_region_menu, NULL, data);
+                               WM_event_add_ui_handler(C, &data->window->modalhandlers, ui_handler_region_menu, NULL, data);
                }
                else {
                        if(button_modal_state(data->state))
-                               WM_event_remove_ui_handler(&data->window->handlers, ui_handler_region_menu, NULL, data);
+                               WM_event_remove_ui_handler(&data->window->modalhandlers, ui_handler_region_menu, NULL, data);
                }
        }
 
@@ -4600,7 +4600,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
                uiPopupBlockHandle temp= *menu;
                
                ui_popup_block_free(C, menu);
-               WM_event_remove_ui_handler(&CTX_wm_window(C)->handlers, ui_handler_popup, ui_handler_remove_popup, menu);
+               WM_event_remove_ui_handler(&CTX_wm_window(C)->modalhandlers, ui_handler_popup, ui_handler_remove_popup, menu);
 
                if(temp.menuretval == UI_RETURN_OK) {
                        if(temp.popup_func)
index 776122380bf1ff382632b457597b0a845c9499e9..cf29a1ddb584f125ebe5291a20841ff6056c1db4 100644 (file)
@@ -1400,14 +1400,14 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
                MEM_freeN(data);
                pa->activedata= NULL;
 
-               WM_event_remove_ui_handler(&win->handlers, ui_handler_panel, ui_handler_remove_panel, pa);
+               WM_event_remove_ui_handler(&win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa);
        }
        else {
                if(!data) {
                        data= MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData");
                        pa->activedata= data;
 
-                       WM_event_add_ui_handler(C, &win->handlers, ui_handler_panel, ui_handler_remove_panel, pa);
+                       WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa);
                }
 
                if(ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG))
index 95305819e2bea917fd142269555c2cc5dd6ac7ad..065d391e6d6d67f126da0c611b48ea3c516af3e2 100644 (file)
@@ -2275,7 +2275,7 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
        if(!but) {
                handle->popup= 1;
 
-               UI_add_popup_handlers(C, &window->handlers, handle);
+               UI_add_popup_handlers(C, &window->modalhandlers, handle);
                WM_event_add_mousemove(C);
        }
        
@@ -2332,7 +2332,7 @@ void uiPupMenuEnd(bContext *C, uiPopupMenu *pup)
        menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPUP, pup);
        menu->popup= 1;
        
-       UI_add_popup_handlers(C, &window->handlers, menu);
+       UI_add_popup_handlers(C, &window->modalhandlers, menu);
        WM_event_add_mousemove(C);
        
        MEM_freeN(pup);
@@ -2493,7 +2493,7 @@ void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, char *opname, i
        handle->optype= (opname)? WM_operatortype_find(opname, 0): NULL;
        handle->opcontext= opcontext;
        
-       UI_add_popup_handlers(C, &window->handlers, handle);
+       UI_add_popup_handlers(C, &window->modalhandlers, handle);
        WM_event_add_mousemove(C);
 }
 
@@ -2516,7 +2516,7 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int
        handle->cancel_func= confirm_cancel_operator;
        handle->opcontext= opcontext;
        
-       UI_add_popup_handlers(C, &window->handlers, handle);
+       UI_add_popup_handlers(C, &window->modalhandlers, handle);
        WM_event_add_mousemove(C);
 }
 
index 33838418842afbf103780f1566bab7e64fee4e77..ae4fe4eed1ba351d2b2e9915e20dd2045a093805 100644 (file)
@@ -210,7 +210,7 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
                WM_cursor_modal(window, BC_NSEW_SCROLLCURSOR);
        
        /* add temp handler */
-       WM_event_add_modal_handler(C, &window->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
@@ -764,7 +764,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
                WM_cursor_modal(window, BC_NSEW_SCROLLCURSOR);
        
        /* add temp handler */
-       WM_event_add_modal_handler(C, &window->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
@@ -1292,7 +1292,7 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE;
                
                /* still ok, so can add */
-               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               WM_event_add_modal_handler(C, op);
                return OPERATOR_RUNNING_MODAL;
        }
        else {
index f83ab04d78501b5a4835ea9afe317f172d3c3b1f..c322a169679d5c2ae23415ca8cbe021a3a344f59 100644 (file)
@@ -328,7 +328,7 @@ static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt)
                return OPERATOR_CANCELLED;
        
        /* add a modal handler for this operator - handles loop selection */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        lcd = op->customdata;
        lcd->vc.mval[0] = evt->mval[0];
@@ -356,7 +356,7 @@ static int ringcut_invoke (bContext *C, wmOperator *op, wmEvent *evt)
                return OPERATOR_CANCELLED;
        
        /* add a modal handler for this operator - handles loop selection */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        lcd = op->customdata;
        lcd->vc.mval[0] = evt->mval[0];
index cbfcf1508c780ea6c1659a7074dd16edf411c161..a5e169eba06db2fae1c597ab2db46576ef9c46a0 100644 (file)
@@ -3352,7 +3352,7 @@ static int brush_edit_invoke(bContext *C, wmOperator *op, wmEvent *event)
        
        brush_edit_apply_event(C, op, event);
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
index 605bd8682f574eec3489d72ea2e41278300492f2..6107d4123234840bbebe9d820f736d38d18ea214 100644 (file)
@@ -456,7 +456,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event)
        }
        else {
                /* add modal handler */
-               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               WM_event_add_modal_handler(C, op);
                
                return OPERATOR_RUNNING_MODAL;
        }
@@ -588,7 +588,7 @@ static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        /* add modal handler */
        WM_cursor_modal(CTX_wm_window(C), BC_SWAPAREA_CURSOR);
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        
        return OPERATOR_RUNNING_MODAL;
 
@@ -870,7 +870,7 @@ static int area_move_invoke(bContext *C, wmOperator *op, wmEvent *event)
                return OPERATOR_PASS_THROUGH;
        
        /* add temp handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        
        return OPERATOR_RUNNING_MODAL;
 }
@@ -1160,7 +1160,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        area_move_set_limits(CTX_wm_screen(C), dir, &sd->bigger, &sd->smaller);
                        
                        /* add temp handler for edge move or cancel */
-                       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+                       WM_event_add_modal_handler(C, op);
                        
                        return OPERATOR_RUNNING_MODAL;
                }
@@ -1296,7 +1296,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        rmd->origval= rmd->ar->type->minsizey;
                
                /* add temp handler */
-               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               WM_event_add_modal_handler(C, op);
                
                return OPERATOR_RUNNING_MODAL;
        }
@@ -1749,7 +1749,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        return OPERATOR_PASS_THROUGH;
        
                /* add temp handler */
-               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               WM_event_add_modal_handler(C, op);
        
                return OPERATOR_RUNNING_MODAL;
        }
@@ -2944,7 +2944,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
        WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
 
        /* add modal handler for ESC */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        
        return OPERATOR_RUNNING_MODAL;
 }
index 0d83cef3e953976a5a1208fc50d234e4fdfa56a0..d3cd49a26581f8b43320eb274487970539cae381 100644 (file)
@@ -4764,7 +4764,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event)
        paint_apply_event(C, op, event);
 
        pop= op->customdata;
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        if(pop->s.brush->flag & BRUSH_AIRBRUSH)
                pop->timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER, 0.01f);
@@ -4966,7 +4966,7 @@ static int grab_clone_invoke(bContext *C, wmOperator *op, wmEvent *event)
        cmv->starty= event->y;
        op->customdata= cmv;
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
index c43d903d4a6f60e4ac2fe4afc5817aa10bfe3bbd..17fd1d4fa4a2255a18a4e89df4d7105983f2ae29 100644 (file)
@@ -1502,7 +1502,7 @@ static int wpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
                                          wpaint_stroke_done);
        
        /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        op->type->modal(C, op, event);
        
@@ -1775,7 +1775,7 @@ static int vpaint_invoke(bContext *C, wmOperator *op, wmEvent *event)
                                          vpaint_stroke_done);
        
        /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        op->type->modal(C, op, event);
        
index 822e79bea1e8caa1d15706aef318ba3741a870d6..a466c87746beba14b5602411edbf2153217b0aec 100644 (file)
@@ -1440,7 +1440,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even
                                          sculpt_stroke_done);
 
        /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        op->type->modal(C, op, event);
        
index d54dd56d1e8462de3cb1b8058b79ce28d5afb564..3491ccd9d200a801edd700bc3f7b3d33674a1746 100644 (file)
@@ -161,7 +161,7 @@ static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event)
        vpd->xof= sima->xof;
        vpd->yof= sima->yof;
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 }
 
 static void view_pan_exit(bContext *C, wmOperator *op, int cancel)
@@ -280,7 +280,7 @@ static void view_zoom_init(bContext *C, wmOperator *op, wmEvent *event)
        vpd->y= event->y;
        vpd->zoom= sima->zoom;
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 }
 
 static void view_zoom_exit(bContext *C, wmOperator *op, int cancel)
@@ -1453,7 +1453,7 @@ static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        sample_apply(C, op, event);
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
@@ -1621,7 +1621,7 @@ static int record_composite_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        rcd= op->customdata;
        rcd->timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER, 0.0f);
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        if(!record_composite_apply(C, op))
                return OPERATOR_FINISHED;
index 4fd6995b8fda4a6077a085c06f3ae2bb3b85b0cf..5fc09408229a50472de29e5aa3c238680ecdffc3 100644 (file)
@@ -1216,7 +1216,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event)
                                nsw->oldwidth= node->width;
                        
                        /* add modal handler */
-                       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+                       WM_event_add_modal_handler(C, op);
 
                        return OPERATOR_RUNNING_MODAL;
                }
@@ -2033,7 +2033,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        nldrag->link= nodeAddLink(snode->edittree, NULL, NULL, nldrag->node, nldrag->sock);
                
                /* add modal handler */
-               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               WM_event_add_modal_handler(C, op);
                
                return OPERATOR_RUNNING_MODAL;
        }
index 3568f50dfe10d34ccd8679e42b7d13255bf2200b..8e81336912be375a706eeed7760e3c978c4f3984 100644 (file)
@@ -1731,7 +1731,7 @@ static int scroll_invoke(bContext *C, wmOperator *op, wmEvent *event)
        
        st->flags|= ST_SCROLL_SELECT;
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
@@ -1860,7 +1860,7 @@ static int scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event)
        
        st->flags|= ST_SCROLL_SELECT;
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
@@ -2115,7 +2115,7 @@ static int set_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
        scu->sell= txt_get_span(st->text->lines.first, st->text->sell);
        scu->selc= st->text->selc;
 
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        set_cursor_apply(C, op, event);
 
index bbcee0415f8338a950d6f5efde6335e870ca6d70..d28789491dd13801b9c0afc568b75354221f28bc 100644 (file)
@@ -541,7 +541,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
        }
 
        /* add temp handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
@@ -625,7 +625,7 @@ static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event)
        viewops_data(C, op, event);
 
        /* add temp handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
 
        return OPERATOR_RUNNING_MODAL;
 }
@@ -823,7 +823,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
                viewops_data(C, op, event);
 
                /* add temp handler */
-               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               WM_event_add_modal_handler(C, op);
 
                return OPERATOR_RUNNING_MODAL;
        }
index 7dfae33bc398af1f4d96f4397033ff213af11f92..f9597b81114befe4ec436a48e7c9aec63b897e3e 100644 (file)
@@ -270,7 +270,7 @@ static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event)
                TransInfo *t = op->customdata;
 
                /* add temp handler */
-               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               WM_event_add_modal_handler(C, op);
 
                t->flag |= T_MODAL; // XXX meh maybe somewhere else
 
index ccdc51430bc5f7109887a73d8076a9eefaf19f82..b848bd4fb097f4e0cf9c44b05d42e5118340aad5 100644 (file)
@@ -342,7 +342,7 @@ static int minimize_stretch_invoke(bContext *C, wmOperator *op, wmEvent *event)
        minimize_stretch_iteration(C, op, 1);
 
        ms= op->customdata;
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        ms->timer= WM_event_add_window_timer(CTX_wm_window(C), TIMER, 0.01f);
 
        return OPERATOR_RUNNING_MODAL;
index 00fbc04844c5478f8fa0408e5a6bb66f61343b9d..67a6b3153e442a356e95ef3a0fed440d9a015e68 100644 (file)
@@ -162,7 +162,8 @@ typedef struct wmWindow {
        ListBase timers;
        
        ListBase queue;                         /* all events (ghost level events were handled) */
-       ListBase handlers;                      /* window+screen handlers, overriding all queues */
+       ListBase handlers;                      /* window+screen handlers, handled last */
+       ListBase modalhandlers;         /* modal handlers, overriding all queues */
        
        ListBase subwindows;    /* opengl stuff for sub windows, see notes in wm_subwindow.c */
        ListBase gesture;               /* gesture stuff */
index b2edbc324eaa6133cef1dfc1a8b39e90d5fad51e..a757deb4a8a300e21a8cd7d62a71d209da0ddae2 100644 (file)
@@ -119,7 +119,7 @@ void                WM_event_remove_ui_handler(ListBase *handlers,
                        int (*func)(struct bContext *C, struct wmEvent *event, void *userdata),
                        void (*remove)(struct bContext *C, void *userdata), void *userdata);
 
-struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, ListBase *handlers, struct wmOperator *op);
+struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op);
 void           WM_event_remove_handlers(struct bContext *C, ListBase *handlers);
 
 void           WM_event_add_mousemove(struct bContext *C);
index 22c5788b0ae13cd748c864d74474072377d0a502..2a2e0141381abbc7b74adf78619e29b3c370b07c 100644 (file)
@@ -1024,7 +1024,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
                                                        event->keymap_idname= kmi->idname;      /* weak, but allows interactive callback to not use rawkey */
                                                        
                                                        action= wm_handler_operator_call(C, handlers, handler, event, kmi->ptr);
-                                                       if(action==WM_HANDLER_BREAK)  /* not wm_event_always_pass(event) here, it denotes removed handler */
+                                                       if(action==WM_HANDLER_BREAK)  /* not always_pass here, it denotes removed handler */
                                                                break;
                                                }
                                        }
@@ -1042,8 +1042,12 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
                                action= wm_handler_operator_call(C, handlers, handler, event, NULL);
                        }
 
-                       if(!always_pass && action==WM_HANDLER_BREAK)
-                               break;
+                       if(action==WM_HANDLER_BREAK) {
+                               if(always_pass)
+                                       action= WM_HANDLER_CONTINUE;
+                               else
+                                       break;
+                       }
                }
                
                /* fileread case */
@@ -1055,6 +1059,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
 
 static int wm_event_inside_i(wmEvent *event, rcti *rect)
 {
+       if(wm_event_always_pass(event))
+               return 1;
        if(BLI_in_rcti(rect, event->x, event->y))
           return 1;
        if(event->type==MOUSEMOVE) {
@@ -1156,58 +1162,70 @@ void wm_event_do_handlers(bContext *C)
                        /* MVC demands to not draw in event handlers... but we need to leave it for ogl selecting etc */
                        wm_window_make_drawable(C, win);
                        
-                       action= wm_handlers_do(C, event, &win->handlers);
+                       /* first we do modal handlers */
+                       action= wm_handlers_do(C, event, &win->modalhandlers);
                        
                        /* fileread case */
-                       if(CTX_wm_window(C)==NULL) {
+                       if(CTX_wm_window(C)==NULL)
                                return;
-                       }
                        
                        /* builtin tweak, if action is break it removes tweak */
-                       if(!wm_event_always_pass(event))
-                               wm_tweakevent_test(C, event, action);
+                       wm_tweakevent_test(C, event, action);
                        
-                       if(wm_event_always_pass(event) || action==WM_HANDLER_CONTINUE) {
+                       if(action==WM_HANDLER_CONTINUE) {
                                ScrArea *sa;
                                ARegion *ar;
                                int doit= 0;
                                
                                /* XXX to solve, here screen handlers? */
-                               if(!wm_event_always_pass(event)) {
-                                       if(event->type==MOUSEMOVE) {
-                                               /* state variables in screen, cursors */
-                                               ED_screen_set_subwinactive(win, event); 
-                                               /* for regions having custom cursors */
-                                               wm_paintcursor_test(C, event);
-                                       }
+                               if(event->type==MOUSEMOVE) {
+                                       /* state variables in screen, cursors */
+                                       ED_screen_set_subwinactive(win, event); 
+                                       /* for regions having custom cursors */
+                                       wm_paintcursor_test(C, event);
                                }
                                
                                for(sa= win->screen->areabase.first; sa; sa= sa->next) {
-                                       if(wm_event_always_pass(event) || wm_event_inside_i(event, &sa->totrct)) {
-                                               
+                                       if(wm_event_inside_i(event, &sa->totrct)) {
                                                CTX_wm_area_set(C, sa);
-                                               CTX_wm_region_set(C, NULL);
-                                               action= wm_handlers_do(C, event, &sa->handlers);
 
-                                               if(wm_event_always_pass(event) || action==WM_HANDLER_CONTINUE) {
+                                               if(action==WM_HANDLER_CONTINUE) {
                                                        for(ar=sa->regionbase.first; ar; ar= ar->next) {
-                                                               if(wm_event_always_pass(event) || wm_event_inside_i(event, &ar->winrct)) {
+                                                               if(wm_event_inside_i(event, &ar->winrct)) {
                                                                        CTX_wm_region_set(C, ar);
                                                                        action= wm_handlers_do(C, event, &ar->handlers);
 
                                                                        doit |= (BLI_in_rcti(&ar->winrct, event->x, event->y));
                                                                        
-                                                                       if(!wm_event_always_pass(event)) {
-                                                                               if(action==WM_HANDLER_BREAK)
-                                                                                       break;
-                                                                       }
+                                                                       if(action==WM_HANDLER_BREAK)
+                                                                               break;
                                                                }
                                                        }
                                                }
+
+                                               CTX_wm_region_set(C, NULL);
+
+                                               if(action==WM_HANDLER_CONTINUE)
+                                                       action= wm_handlers_do(C, event, &sa->handlers);
+
+                                               CTX_wm_area_set(C, NULL);
+
                                                /* NOTE: do not escape on WM_HANDLER_BREAK, mousemove needs handled for previous area */
                                        }
                                }
                                
+                               if(action==WM_HANDLER_CONTINUE) {
+                                       /* also some non-modal handlers need active area/region */
+                                       CTX_wm_area_set(C, area_event_inside(C, event->x, event->y));
+                                       CTX_wm_region_set(C, region_event_inside(C, event->x, event->y));
+
+                                       action= wm_handlers_do(C, event, &win->handlers);
+
+                                       /* fileread case */
+                                       if(CTX_wm_window(C)==NULL)
+                                               return;
+                               }
+
                                /* XXX hrmf, this gives reliable previous mouse coord for area change, feels bad? 
                                   doing it on ghost queue gives errors when mousemoves go over area borders */
                                if(doit && win->screen->subwinactive != win->screen->mainwin) {
@@ -1274,7 +1292,7 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op)
        handler->op_region= CTX_wm_region(C);
        handler->filescreen= CTX_wm_screen(C);
        
-       BLI_addhead(&win->handlers, handler);
+       BLI_addhead(&win->modalhandlers, handler);
        
        WM_event_fileselect_event(C, op, full?EVT_FILESELECT_FULL_OPEN:EVT_FILESELECT_OPEN);
 }
@@ -1285,9 +1303,10 @@ void WM_event_set_handler_flag(wmEventHandler *handler, int flag)
        handler->flag= flag;
 }
 
-wmEventHandler *WM_event_add_modal_handler(bContext *C, ListBase *handlers, wmOperator *op)
+wmEventHandler *WM_event_add_modal_handler(bContext *C, wmOperator *op)
 {
        wmEventHandler *handler= MEM_callocN(sizeof(wmEventHandler), "event modal handler");
+       wmWindow *win= CTX_wm_window(C);
        
        /* operator was part of macro */
        if(op->opm) {
@@ -1302,7 +1321,7 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, ListBase *handlers, wmOp
        handler->op_area= CTX_wm_area(C);               /* means frozen screen context for modal handlers! */
        handler->op_region= CTX_wm_region(C);
        
-       BLI_addhead(handlers, handler);
+       BLI_addhead(&win->modalhandlers, handler);
 
        return handler;
 }
index 9a268f8be17ae785a85199f9f767b03d7b5bfe2f..5c78b32f3f85913bdf793f92106529e6a793b1b2 100644 (file)
@@ -186,6 +186,7 @@ void WM_exit(bContext *C)
                        
                        CTX_wm_window_set(C, win);      /* needed by operator close callbacks */
                        WM_event_remove_handlers(C, &win->handlers);
+                       WM_event_remove_handlers(C, &win->modalhandlers);
                        ED_screen_exit(C, win, win->screen);
                }
        }
index 2e2d463bbd92ddb751afb7fb54ea74a321f8e2fe..f31d62967aebba9e7c77f1c7eab113b0aad6928f 100644 (file)
@@ -1366,7 +1366,7 @@ int WM_border_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
                op->customdata= WM_gesture_new(C, event, WM_GESTURE_CROSS_RECT);
 
        /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        
        wm_gesture_tag_redraw(C);
 
@@ -1430,7 +1430,7 @@ int WM_gesture_circle_invoke(bContext *C, wmOperator *op, wmEvent *event)
        op->customdata= WM_gesture_new(C, event, WM_GESTURE_CIRCLE);
        
        /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        
        wm_gesture_tag_redraw(C);
        
@@ -1607,7 +1607,7 @@ int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, wmEvent *event)
        op->customdata= WM_gesture_new(C, event, WM_GESTURE_LASSO);
        
        /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        
        wm_gesture_tag_redraw(C);
        
@@ -1622,7 +1622,7 @@ int WM_gesture_lines_invoke(bContext *C, wmOperator *op, wmEvent *event)
        op->customdata= WM_gesture_new(C, event, WM_GESTURE_LINES);
        
        /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        
        wm_gesture_tag_redraw(C);
        
@@ -1929,7 +1929,7 @@ int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
                                              wm_radial_control_paint, op->customdata);
 
        /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       WM_event_add_modal_handler(C, op);
        
        WM_radial_control_modal(C, op, event);
        
index cbb5bed4c00422c93318d3365ec91bb3d6d6d9dd..2eee11c6820a4adfe45c5abf819cfa613a127f56 100644 (file)
@@ -146,6 +146,7 @@ void wm_window_free(bContext *C, wmWindow *win)
                        CTX_wm_window_set(C, NULL);
                
                WM_event_remove_handlers(C, &win->handlers);
+               WM_event_remove_handlers(C, &win->modalhandlers);
 
                /* end running jobs, a job end also removes its timer */
                for(wt= win->timers.first; wt; wt= wtnext) {