2.5: Handlers are now evaluated in a different order, fixing some

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
This commit is contained in:
Brecht Van Lommel 2009-09-18 12:43:36 +00:00
parent ab518939b5
commit 854ea35a24
28 changed files with 106 additions and 83 deletions

View 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;

View 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);

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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)

View 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))

View 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);
}

View 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 {

View 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];

View 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;
}

View 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;
}

View 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;
}

View 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);

View 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);

View 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;

View 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;
}

View 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);

View 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;
}

View 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

View 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;

View 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 */

View 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);

View 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;
}

View 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);
}
}

View 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);

View 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) {