diff options
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 27 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 63 | ||||
-rw-r--r-- | source/blender/windowmanager/wm.h | 2 |
5 files changed, 46 insertions, 58 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 6f5ad0a80b9..7554d25e770 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -68,7 +68,7 @@ typedef struct wmEvent { short prevx, prevy; /* previous mouse pointer position */ short unicode; /* future, ghost? */ char ascii; /* from ghost */ - char no_tweak; /* set on tweak failure, to allow other events to try it */ + char pad; /* modifier states */ short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ @@ -224,6 +224,7 @@ typedef struct wmNotifier { #define WM_GESTURE_CIRCLE 5 /* wmGesture is registered to window listbase, handled by operator callbacks */ +/* tweak gesture is builtin feature */ typedef struct wmGesture { struct wmGesture *next, *prev; int event_type; /* event->type */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index d8c1e8a5888..6bcca9e2acf 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -542,19 +542,6 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) if(kmi->keymodifier) if(winevent->keymodifier!=kmi->keymodifier) return 0; - /* happens on tweak failure */ - /* weak code, testing only now! (ton) */ - if(kmi->is_tweak) { - /* only after tweak keymap we allow the hack */ - if(winevent->no_tweak) { - winevent->no_tweak= 2; - return 0; - } - } - - if(winevent->no_tweak==1) - return 0; - return 1; } @@ -850,15 +837,23 @@ void wm_event_do_handlers(bContext *C) return; } + /* builtin tweak, if action is break it removes tweak */ + if(!wm_event_always_pass(event)) + wm_tweakevent_test(C, event, action); + if(wm_event_always_pass(event) || action==WM_HANDLER_CONTINUE) { ScrArea *sa; ARegion *ar; int doit= 0; /* XXX to solve, here screen handlers? */ - if(event->type==MOUSEMOVE) { - ED_screen_set_subwinactive(win, event); /* state variables in screen, cursors */ - wm_paintcursor_test(C, event); + 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); + } } for(sa= win->screen->areabase.first; sa; sa= sa->next) { diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 22189b1707c..7528321c7c5 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -125,15 +125,6 @@ wmKeymapItem *WM_keymap_add_item(ListBase *lb, char *idname, short type, short v return kmi; } -/* enables tweak for mouse/modifier combo - on tweak fail, it passes on event with 'val=1', so other keymap items can test */ -void WM_keymap_tweak(ListBase *lb, short type, short val, int modifier, short keymodifier) -{ - wmKeymapItem *km= WM_keymap_add_item(lb, "WM_OT_tweak_gesture", type, val, modifier, keymodifier); - km->is_tweak= 1; -} - - /* ****************** storage in WM ************ */ /* name id's are for storing general or multiple keymaps, diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 707cd5f2254..098443d481a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -729,22 +729,10 @@ void WM_OT_circle_gesture(wmOperatorType *ot) /* **************** Tweak gesture *************** */ -static int tweak_gesture_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - op->customdata= WM_gesture_new(C, event, WM_GESTURE_TWEAK); - - /* add modal handler */ - WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - - wm_gesture_tag_redraw(C); - - return OPERATOR_RUNNING_MODAL; -} - -static int tweak_gesture_modal(bContext *C, wmOperator *op, wmEvent *event) +static void tweak_gesture_modal(bContext *C, wmEvent *event) { wmWindow *window= CTX_wm_window(C); - wmGesture *gesture= op->customdata; + wmGesture *gesture= window->tweak; rcti *rect= gesture->customdata; int sx, sy, val; @@ -758,7 +746,7 @@ static int tweak_gesture_modal(bContext *C, wmOperator *op, wmEvent *event) if((val= wm_gesture_evaluate(C, gesture))) { wmEvent event; - + event= *(window->eventstate); if(gesture->event_type==LEFTMOUSE) event.type= EVT_TWEAK_L; @@ -770,11 +758,9 @@ static int tweak_gesture_modal(bContext *C, wmOperator *op, wmEvent *event) /* mouse coords! */ wm_event_add(window, &event); - wm_gesture_end(C, op); - return OPERATOR_FINISHED; + WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */ + window->tweak= NULL; } - else - wm_gesture_tag_redraw(C); break; @@ -782,29 +768,43 @@ static int tweak_gesture_modal(bContext *C, wmOperator *op, wmEvent *event) case RIGHTMOUSE: case MIDDLEMOUSE: if(gesture->event_type==event->type) { - wm_gesture_end(C, op); + WM_gesture_end(C, gesture); + window->tweak= NULL; /* when tweak fails we should give the other keymap entries a chance * those then won't react to km_press, but km_release * it sets hidden event value where tweak maps fail on, to prevent loops */ - event->val= 1; - event->no_tweak= 1; - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + //event->val= 1; + //event->no_tweak= 1; } break; + default: + WM_gesture_end(C, gesture); + window->tweak= NULL; } - return OPERATOR_RUNNING_MODAL; } -void WM_OT_tweak_gesture(wmOperatorType *ot) +/* standard tweak, called after window handlers passed on event */ +void wm_tweakevent_test(bContext *C, wmEvent *event, int action) { - ot->name= "Tweak Gesture"; - ot->idname= "WM_OT_tweak_gesture"; + wmWindow *win= CTX_wm_window(C); - ot->invoke= tweak_gesture_invoke; - ot->modal= tweak_gesture_modal; - - ot->poll= WM_operator_winactive; + if(win->tweak==NULL) { + if(CTX_wm_region(C)) { + if(event->val) { // pressed + if( ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) ) + win->tweak= WM_gesture_new(C, event, WM_GESTURE_TWEAK); + } + } + } + else { + if(action==WM_HANDLER_BREAK) { + WM_gesture_end(C, win->tweak); + win->tweak= NULL; + } + else + tweak_gesture_modal(C, event); + } } /* *********************** lasso gesture ****************** */ @@ -1171,7 +1171,6 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_save_homefile); WM_operatortype_append(WM_OT_window_fullscreen_toggle); WM_operatortype_append(WM_OT_exit_blender); - WM_operatortype_append(WM_OT_tweak_gesture); WM_operatortype_append(WM_OT_open_recentfile); WM_operatortype_append(WM_OT_open_mainfile); WM_operatortype_append(WM_OT_jobs_timer); diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index 556a3fadcfb..fd5cbe3ff4f 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -55,6 +55,8 @@ void wm_operatortype_free(void); void wm_operatortype_init(void); void wm_window_keymap(wmWindowManager *wm); +void wm_tweakevent_test(bContext *C, wmEvent *event, int action); + /* wm_gesture.c */ #define WM_LASSO_MAX_POINTS 1024 void wm_gesture_draw(struct wmWindow *win); |