diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 50 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 15 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 43 | ||||
-rw-r--r-- | source/blender/editors/space_time/ed_markers.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_time/time_ops.c | 3 |
6 files changed, 61 insertions, 57 deletions
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 90f888e652d..2d515aafc13 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -2627,13 +2627,15 @@ static void button_activate_state(bContext *C, uiBut *but, uiActivateButState st ui_blockopen_begin(C, but, data); /* note we move the handler to the region when the block is open, * so we don't interfere with the events as long as it's open */ - WM_event_remove_modal_handler(&C->window->handlers, data->operator); - WM_event_add_modal_handler(&data->region->handlers, data->operator); + /* XXX (to brecht) removing this makes thing work proper */ + //WM_event_remove_modal_handler(&C->window->handlers, data->operator); + //WM_event_add_modal_handler(C, &data->region->handlers, data->operator); } else if(data->state == BUTTON_STATE_BLOCK_OPEN) { ui_blockopen_end(C, but, data); - WM_event_remove_modal_handler(&data->region->handlers, data->operator); - WM_event_add_modal_handler(&C->window->handlers, data->operator); + /* XXX (to brecht) removing this makes thing work proper */ + //WM_event_remove_modal_handler(&data->region->handlers, data->operator); + //WM_event_add_modal_handler(C, &C->window->handlers, data->operator); } if(state == BUTTON_STATE_WAIT_FLASH) { @@ -2673,9 +2675,9 @@ static void button_activate_init(bContext *C, ARegion *ar, wmOperator *op, uiBut if(!lastbut && but->block->auto_open) if(but->block->auto_open_last+BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer()) but->block->auto_open= 0; - + /* modal handler */ - WM_event_add_modal_handler(&C->window->handlers, op); + WM_event_add_modal_handler(C, &C->window->handlers, op); button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); @@ -2708,10 +2710,7 @@ static void button_activate_exit(bContext *C, uiActivateBut *data, wmOperator *o if(data->state == BUTTON_STATE_BLOCK_OPEN) { ui_blockopen_end(C, but, data); - WM_event_remove_modal_handler(&data->region->handlers, data->operator); } - else - WM_event_remove_modal_handler(&C->window->handlers, op); if(but) { /* if someone is expecting a message */ @@ -2792,7 +2791,7 @@ static int button_activate_try_exit(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar; uiActivateBut *data; uiBut *but; - int state; + int state= OPERATOR_FINISHED; data= op->customdata; ar= data->region; @@ -2801,7 +2800,8 @@ static int button_activate_try_exit(bContext *C, wmOperator *op, wmEvent *event) /* exit the current button, but try to re-init as well */ button_activate_exit(C, op->customdata, op); - state= button_activate_try_init(C, ar, op, event, but); + /* XXX re-init has to be done differently... */ + /* XXX state= button_activate_try_init(C, ar, op, event, but); */ return (state != OPERATOR_RUNNING_MODAL); } @@ -2830,7 +2830,10 @@ static int button_activate_modal(bContext *C, wmOperator *op, wmEvent *event) int handled= 0; data= op->customdata; - + /* XXX (for brecht) this happens when cancel() frees, and modal handler still runs */ + if(data==NULL) + return OPERATOR_FINISHED; + /* check if the button dissappeared somehow */ if(!(but= ui_but_find_activated(data->region, data, &block))) { data->cancel= 1; @@ -3031,7 +3034,6 @@ static int menu_block_handle_cancel(bContext *C, wmOperator *op) if(op->customdata) { MEM_freeN(op->customdata); op->customdata= NULL; - WM_event_remove_modal_handler(&C->window->handlers, op); } return OPERATOR_CANCELLED; @@ -3057,7 +3059,7 @@ static int menu_block_handle_invoke(bContext *C, wmOperator *op, wmEvent *event) handle->region= C->region; op->customdata= handle; - WM_event_add_modal_handler(&C->window->handlers, op); + WM_event_add_modal_handler(C, &C->window->handlers, op); return OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH; } @@ -3077,13 +3079,25 @@ static int menu_block_handle_block_open(uiBlock *block) return 0; } +#include "wm_event_system.h" +static void testing123(bContext *C) +{ + wmEventHandler *handler; + + for(handler= C->window->handlers.first; handler; handler= handler->next) { + if(handler->op) + printf("handler has op %s\n", handler->op->type->idname); + } +} + +/* moves focus on button/menu from mousemove-based to hotkey */ static void menu_block_handle_activate_button(bContext *C, wmEvent *event, ARegion *butregion, uiBut *but, int activateflag) { wmOperatorType *ot; ot= WM_operatortype_find("ED_UI_OT_button_activate"); - - WM_operator_cancel(C, &butregion->modalops, ot); + testing123(C); +// XXX WM_operator_cancel(C, &butregion->modalops, ot); but->activateflag= activateflag; SWAP(ARegion*, C->region, butregion); /* XXX 2.50 bad state manipulation? */ @@ -3173,6 +3187,10 @@ static int menu_block_handle_modal(bContext *C, wmOperator *op, wmEvent *event) int inside, act, count, mx, my, handled; bhandle= op->customdata; + /* XXX (for brecht) this happens when cancel() frees, and modal handler still runs */ + if(bhandle==NULL) + return OPERATOR_FINISHED; + ar= bhandle->region; block= ar->uiblocks.first; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 2ddbaeeb79b..9e6a9a6dada 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -184,7 +184,7 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event) #endif // XXX - enable this when cursors are working properly /* add temp handler */ - WM_event_add_modal_handler(&C->window->handlers, op); + WM_event_add_modal_handler(C, &C->window->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -216,7 +216,6 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) view_pan_exit(C, op); //WM_set_cursor(C, CURSOR_STD); // XXX - enable this when cursors are working properly - WM_event_remove_modal_handler(&C->window->handlers, op); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 742022ea370..31ac5d63835 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -268,8 +268,8 @@ static short testsplitpoint(wmWindow *win, ScrArea *sa, char dir, float fac) short x, y; // area big enough? - if(sa->v4->vec.x- sa->v1->vec.x <= 2*AREAMINX) return 0; - if(sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY) return 0; + if(dir=='v' && (sa->v4->vec.x- sa->v1->vec.x <= 2*AREAMINX)) return 0; + if(dir=='h' && (sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY)) return 0; // to be sure if(fac<0.0) fac= 0.0; @@ -305,7 +305,7 @@ ScrArea *area_split(wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac ScrVert *sv1, *sv2; short split; - if(sa==0) return NULL; + if(sa==NULL) return NULL; split= testsplitpoint(win, sa, dir, fac); if(split==0) return NULL; @@ -920,8 +920,7 @@ void ED_screens_initialize(wmWindowManager *wm) void ED_region_exit(bContext *C, ARegion *ar) { - WM_operator_cancel(C, &ar->modalops, NULL); - WM_event_remove_handlers(&ar->handlers); + WM_event_remove_handlers(C, &ar->handlers); } void ED_area_exit(bContext *C, ScrArea *sa) @@ -931,8 +930,7 @@ void ED_area_exit(bContext *C, ScrArea *sa) for(ar= sa->regionbase.first; ar; ar= ar->next) ED_region_exit(C, ar); - WM_operator_cancel(C, &sa->modalops, NULL); - WM_event_remove_handlers(&sa->handlers); + WM_event_remove_handlers(C, &sa->handlers); } void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) @@ -946,8 +944,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) for(sa= screen->areabase.first; sa; sa= sa->next) ED_area_exit(C, sa); - WM_operator_cancel(C, &window->modalops, NULL); - WM_event_remove_handlers(&window->handlers); + WM_event_remove_handlers(C, &window->handlers); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4c7a98e97c3..095f6e1a74b 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -125,7 +125,7 @@ static AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) int i= 0; for(az= sa->actionzones.first, i= 0; az; az= az->next, i++) { - if(az && az->type == AZONE_TRI) { + if(az->type == AZONE_TRI) { if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y)) break; } @@ -154,7 +154,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) sad->x= event->x; sad->y= event->y; /* add modal handler */ - WM_event_add_modal_handler(&C->window->handlers, op); + WM_event_add_modal_handler(C, &C->window->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -209,15 +209,12 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) actionzone_apply(C, op); actionzone_exit(C, op); - WM_event_remove_modal_handler(&C->window->handlers, op); - return OPERATOR_FINISHED; } break; case ESCKEY: case LEFTMOUSE: actionzone_exit(C, op); - WM_event_remove_modal_handler(&C->window->handlers, op); return OPERATOR_CANCELLED; } @@ -560,14 +557,13 @@ static int area_move_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_PASS_THROUGH; /* add temp handler */ - WM_event_add_modal_handler(&C->window->handlers, op); + WM_event_add_modal_handler(C, &C->window->handlers, op); return OPERATOR_RUNNING_MODAL; } static int area_move_cancel(bContext *C, wmOperator *op) { - WM_event_remove_modal_handler(&C->window->handlers, op); RNA_int_set(op->ptr, "delta", 0); area_move_apply(C, op); @@ -599,7 +595,6 @@ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: if(event->val==0) { area_move_exit(C, op); - WM_event_remove_modal_handler(&C->window->handlers, op); return OPERATOR_FINISHED; } break; @@ -740,8 +735,8 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) } -/* do the split */ -static void area_split_apply(bContext *C, wmOperator *op) +/* do the split, return success */ +static int area_split_apply(bContext *C, wmOperator *op) { sAreaSplitData *sd= (sAreaSplitData *)op->customdata; float fac; @@ -767,10 +762,12 @@ static void area_split_apply(bContext *C, wmOperator *op) if(dir=='h') sd->origval= sd->nedge->v1->vec.y; else sd->origval= sd->nedge->v1->vec.x; + WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); + + return 1; } - WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); - + return 0; } static void area_split_exit(bContext *C, wmOperator *op) @@ -826,13 +823,14 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) sd->y= event->y; /* do the split */ - area_split_apply(C, op); - area_move_set_limits(C->screen, dir, &sd->bigger, &sd->smaller); - - /* add temp handler for edge move or cancel */ - WM_event_add_modal_handler(&C->window->handlers, op); - - return OPERATOR_RUNNING_MODAL; + if(area_split_apply(C, op)) { + area_move_set_limits(C->screen, dir, &sd->bigger, &sd->smaller); + + /* add temp handler for edge move or cancel */ + WM_event_add_modal_handler(C, &C->window->handlers, op); + + return OPERATOR_RUNNING_MODAL; + } } else { @@ -861,8 +859,6 @@ static int area_split_cancel(bContext *C, wmOperator *op) { sAreaSplitData *sd= (sAreaSplitData *)op->customdata; - WM_event_remove_modal_handler(&C->window->handlers, op); - if (screen_area_join(C->screen,sd->sarea, sd->narea)) { if (C->area == sd->narea) { C->area = NULL; @@ -893,7 +889,6 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: if(event->val==0) { /* mouse up */ area_split_exit(C, op); - WM_event_remove_modal_handler(&C->window->handlers, op); return OPERATOR_FINISHED; } break; @@ -1070,7 +1065,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->window->handlers, op); + WM_event_add_modal_handler(C, &C->window->handlers, op); return OPERATOR_RUNNING_MODAL; } @@ -1092,7 +1087,6 @@ static int area_join_cancel(bContext *C, wmOperator *op) } WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_WINDOW_REDRAW, 0, NULL); - WM_event_remove_modal_handler(&C->window->handlers, op); area_join_exit(C, op); @@ -1174,7 +1168,6 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) area_join_apply(C, op); WM_event_add_notifier(C->wm, C->window, 0, WM_NOTE_SCREEN_CHANGED, 0, NULL); area_join_exit(C, op); - WM_event_remove_modal_handler(&C->window->handlers, op); return OPERATOR_FINISHED; } break; diff --git a/source/blender/editors/space_time/ed_markers.c b/source/blender/editors/space_time/ed_markers.c index 83ede869360..1829435bf8d 100644 --- a/source/blender/editors/space_time/ed_markers.c +++ b/source/blender/editors/space_time/ed_markers.c @@ -297,7 +297,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->window->handlers, op); + WM_event_add_modal_handler(C, &C->window->handlers, op); /* reset frs delta */ RNA_int_set(op->ptr, "frs", 0); @@ -333,7 +333,6 @@ static void ed_marker_move_cancel(bContext *C, wmOperator *op) ed_marker_move_apply(C, op); ed_marker_move_exit(C, op); - WM_event_remove_modal_handler(&C->window->handlers, op); WM_event_add_notifier(C->wm, C->window, mm->swinid, WM_NOTE_AREA_REDRAW, 0, NULL); } @@ -376,7 +375,6 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) case RIGHTMOUSE: if(WM_modal_tweak_check(evt, mm->event_type)) { ed_marker_move_exit(C, op); - WM_event_remove_modal_handler(&C->window->handlers, op); WM_event_add_notifier(C->wm, C->window, mm->swinid, WM_NOTE_AREA_REDRAW, 0, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index bc30d07f878..27e89422f98 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -126,7 +126,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->region->handlers, op); // XXX should be for window, but we crash otherwise + WM_event_add_modal_handler(C, &C->region->handlers, op);// XXX should be for window, but we crash otherwise return OPERATOR_RUNNING_MODAL; } @@ -149,7 +149,6 @@ static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: if(event->val==0) { change_frame_exit(C, op); - WM_event_remove_modal_handler(&C->region->handlers, op); // XXX should be for window, but we crash otherwise return OPERATOR_FINISHED; } break; |