fix for middle mouse up events not working with modal keymaps (used for fly mode).
authorCampbell Barton <ideasman42@gmail.com>
Thu, 24 Sep 2009 10:35:04 +0000 (10:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 24 Sep 2009 10:35:04 +0000 (10:35 +0000)
With mouse events event->val started as 0/1 for press/release but later the tweak function made LMB and RMB zero value into KM_RELEASE, somehow MMB didnt get used by the tweak function so was left at 0 and the modal keymap function failed when comparing MMB Mouse ups.

now initialize event->val as KM_PRESS/KM_RELEASE

12 files changed:
source/blender/editors/animation/anim_ops.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/mesh/loopcut.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c

index 80077a6..40c5b88 100644 (file)
@@ -193,7 +193,7 @@ static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event)
                        /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init 
                         * the modal op) doesn't work for some reason
                         */
-                       if (event->val==0) {
+                       if (event->val==KM_RELEASE) {
                                change_frame_exit(C, op);
                                return OPERATOR_FINISHED;
                        }
index 7f2f2a3..7487669 100644 (file)
@@ -2675,7 +2675,7 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short
                retval = OPERATOR_CANCELLED;
                break;
        case LEFTMOUSE:
-               if (event->val == 0)
+               if (event->val == KM_RELEASE)
                {
                        if (gesture == 0)
                        {
index 01a8f98..b5de855 100644 (file)
@@ -1660,7 +1660,7 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u
                        break;
                }
                case LEFTMOUSE:
-                       if(event->val == 0)
+                       if(event->val == KM_RELEASE)
                                button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
                        retval= WM_UI_HANDLER_BREAK;
                        break;
index ae4fe4e..0af5a5c 100644 (file)
@@ -237,7 +237,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
                        
                case LEFTMOUSE:
                case MIDDLEMOUSE:
-                       if (event->val==0) {
+                       if (event->val==KM_RELEASE) {
                                /* calculate overall delta mouse-movement for redo */
                                RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx));
                                RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty));
@@ -836,7 +836,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
                        
                case LEFTMOUSE:
                case MIDDLEMOUSE:
-                       if (event->val==0) {
+                       if (event->val==KM_RELEASE) {
                                /* for redo, store the overall deltas - need to respect zoom-locks here... */
                                if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0)
                                        RNA_float_set(op->ptr, "deltax", vzd->dx);
@@ -1244,7 +1244,7 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
                        break;
                        
                case LEFTMOUSE:
-                       if (event->val==0) {
+                       if (event->val==KM_RELEASE) {
                                scroller_activate_exit(C, op);
                                return OPERATOR_FINISHED;
                        }
index c322a16..1adac71 100644 (file)
@@ -380,7 +380,7 @@ static int ringsel_modal (bContext *C, wmOperator *op, wmEvent *event)
        switch (event->type) {
                case RIGHTMOUSE:
                case LEFTMOUSE: /* confirm */ // XXX hardcoded
-                       if (event->val == 0) {
+                       if (event->val == KM_RELEASE) {
                                /* finish */
                                ED_region_tag_redraw(lcd->ar);
 
index 5cd992e..5f7be1f 100644 (file)
@@ -604,7 +604,7 @@ static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event)
                        sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
                        break;
                case LEFTMOUSE: /* release LMB */
-                       if(event->val==0) {
+                       if(event->val==KM_RELEASE) {
                                if(!sad->sa2 || sad->sa1 == sad->sa2) {
 
                                        return area_swap_cancel(C, op);
@@ -1225,7 +1225,7 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event)
                        break;
                        
                case LEFTMOUSE:
-                       if(event->val==0) { /* mouse up */
+                       if(event->val==KM_RELEASE) { /* mouse up */
                                area_split_exit(C, op);
                                return OPERATOR_FINISHED;
                        }
@@ -1345,7 +1345,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
                        break;
                        
                case LEFTMOUSE:
-                       if(event->val==0) {
+                       if(event->val==KM_RELEASE) {
                                
                                if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) {
                                        if(rmd->ar->flag & RGN_FLAG_HIDDEN) {
@@ -1828,7 +1828,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
                        }
                        break;
                case LEFTMOUSE:
-                       if(event->val==0) {
+                       if(event->val==KM_RELEASE) {
                                area_join_apply(C, op);
                                WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
                                area_join_exit(C, op);
index bd9ea50..b83352a 100644 (file)
@@ -263,7 +263,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
        }
 
        /* TODO: fix hardcoded event here */
-       if(event->type == LEFTMOUSE && event->val == 0) {
+       if(event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                /* Exit stroke, free data */
 
                if(stroke->smooth_stroke_cursor)
index 483d2fc..317a058 100644 (file)
@@ -224,7 +224,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
                        view_pan_exec(C, op);
                        break;
                case MIDDLEMOUSE:
-                       if(event->val==0) {
+                       if(event->val==KM_RELEASE) {
                                view_pan_exit(C, op, 0);
                                return OPERATOR_FINISHED;
                        }
@@ -339,7 +339,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
                        ED_area_tag_redraw(CTX_wm_area(C));
                        break;
                case MIDDLEMOUSE:
-                       if(event->val==0) {
+                       if(event->val==KM_RELEASE) {
                                view_zoom_exit(C, op, 0);
                                return OPERATOR_FINISHED;
                        }
index 94691dd..5e48275 100644 (file)
@@ -140,7 +140,7 @@ static int node_select_modal(bContext *C, wmOperator *op, wmEvent *event)
                        printf("%d %d\n", event->x, event->y);
                        break;
                case SELECTMOUSE:
-                       //if (event->val==0) {
+                       //if (event->val==KM_RELEASE) {
                                /* calculate overall delta mouse-movement for redo */
                                printf("done translating\n");
                                //WM_cursor_restore(CTX_wm_window(C));
index 24ec0d1..5e3a6ae 100644 (file)
@@ -505,7 +505,7 @@ static int viewrotate_modal(bContext *C, wmOperator *op, wmEvent *event)
 
                default:
                        /* origkey may be zero when invoked from a button */
-                       if(ELEM3(event->type, ESCKEY, LEFTMOUSE, RIGHTMOUSE) || (event->type==vod->origkey && event->val==0)) {
+                       if(ELEM3(event->type, ESCKEY, LEFTMOUSE, RIGHTMOUSE) || (event->type==vod->origkey && event->val==KM_RELEASE)) {
                                request_depth_update(CTX_wm_region_view3d(C));
 
                                MEM_freeN(vod);
@@ -606,7 +606,7 @@ static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event)
 
                default:
                        /* origkey may be zero when invoked from a button */
-                       if(ELEM3(event->type, ESCKEY, LEFTMOUSE, RIGHTMOUSE) || (event->type==vod->origkey && event->val==0)) {
+                       if(ELEM3(event->type, ESCKEY, LEFTMOUSE, RIGHTMOUSE) || (event->type==vod->origkey && event->val==KM_RELEASE)) {
                                request_depth_update(CTX_wm_region_view3d(C));
 
                                MEM_freeN(vod);
@@ -767,7 +767,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event)
 
                default:
                        /* origkey may be zero when invoked from a button */
-                       if(ELEM3(event->type, ESCKEY, LEFTMOUSE, RIGHTMOUSE) || (event->type==vod->origkey && event->val==0)) {
+                       if(ELEM3(event->type, ESCKEY, LEFTMOUSE, RIGHTMOUSE) || (event->type==vod->origkey && event->val==KM_RELEASE)) {
                                request_depth_update(CTX_wm_region_view3d(C));
 
                                MEM_freeN(vod);
index 03e1332..af13393 100644 (file)
@@ -1004,7 +1004,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
        int always_pass;
 
        if(handlers==NULL) return action;
-       
+
        /* modal handlers can get removed in this loop, we keep the loop this way */
        for(handler= handlers->first; handler; handler= nexthandler) {
                nexthandler= handler->next;
@@ -1157,7 +1157,7 @@ void wm_event_do_handlers(bContext *C)
                
                while( (event= win->queue.first) ) {
                        int action;
-                       
+
                        CTX_wm_window_set(C, win);
                        
                        /* we let modal handlers get active area/region, also wm_paintcursor_test needs it */
@@ -1176,7 +1176,7 @@ void wm_event_do_handlers(bContext *C)
                        
                        /* builtin tweak, if action is break it removes tweak */
                        wm_tweakevent_test(C, event, action);
-                       
+
                        if(action==WM_HANDLER_CONTINUE) {
                                ScrArea *sa;
                                ARegion *ar;
@@ -1189,7 +1189,7 @@ void wm_event_do_handlers(bContext *C)
                                        /* for regions having custom cursors */
                                        wm_paintcursor_test(C, event);
                                }
-                               
+
                                for(sa= win->screen->areabase.first; sa; sa= sa->next) {
                                        if(wm_event_inside_i(event, &sa->totrct)) {
                                                CTX_wm_area_set(C, sa);
@@ -1575,7 +1575,7 @@ void wm_event_add_ghostevent(wmWindow *win, int type, void *customdata)
                case GHOST_kEventButtonDown:
                case GHOST_kEventButtonUp: {
                        GHOST_TEventButtonData *bd= customdata;
-                       event.val= (type==GHOST_kEventButtonDown);
+                       event.val= (type==GHOST_kEventButtonDown) ? KM_PRESS:KM_RELEASE; /* Note!, this starts as 0/1 but later is converted to KM_PRESS/KM_RELEASE by tweak */
                        
                        if (bd->button == GHOST_kButtonMaskLeft)
                                event.type= LEFTMOUSE;
index 0b5c294..486a887 100644 (file)
@@ -1485,7 +1485,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, wmEvent *event)
                case LEFTMOUSE:
                case MIDDLEMOUSE:
                case RIGHTMOUSE:
-                       if(event->val==0) {     /* key release */
+                       if(event->val==KM_RELEASE) {    /* key release */
                                wm_gesture_end(C, op);
                                return OPERATOR_FINISHED;
                        }
@@ -1568,7 +1568,7 @@ static void tweak_gesture_modal(bContext *C, wmEvent *event)
                        if(gesture->event_type==event->type) {
                                WM_gesture_end(C, gesture);
                                window->tweak= NULL;
-                               
+
                                /* when tweak fails we should give the other keymap entries a chance */
                                event->val= KM_RELEASE;
                        }
@@ -1586,7 +1586,7 @@ void wm_tweakevent_test(bContext *C, wmEvent *event, int action)
        
        if(win->tweak==NULL) {
                if(CTX_wm_region(C)) {
-                       if(event->val) { // pressed
+                       if(event->val==KM_PRESS) { // pressed
                                if( ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) )
                                        win->tweak= WM_gesture_new(C, event, WM_GESTURE_TWEAK);
                        }
@@ -1686,7 +1686,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, wmEvent *event)
                case LEFTMOUSE:
                case MIDDLEMOUSE:
                case RIGHTMOUSE:
-                       if(event->val==0) {     /* key release */
+                       if(event->val==KM_RELEASE) {    /* key release */
                                gesture_lasso_apply(C, op, event->type);
                                return OPERATOR_FINISHED;
                        }