fix [#27458] Links for Logic Bricks no longer work
authorCampbell Barton <ideasman42@gmail.com>
Sun, 22 May 2011 04:05:09 +0000 (04:05 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 22 May 2011 04:05:09 +0000 (04:05 +0000)
event->mval wasn't being set in some cases by the event system.

source/blender/windowmanager/intern/wm_event_system.c

index 440ade914f02c1336136e67fb5db4539466c0eef..615259bda15dc3ebf1e26f4720b0a03ba410e4a3 100644 (file)
@@ -661,6 +661,11 @@ static void wm_region_mouse_co(bContext *C, wmEvent *event)
                event->mval[0]= event->x - ar->winrct.xmin;
                event->mval[1]= event->y - ar->winrct.ymin;
        }
+       else {
+               /* these values are invalid (avoid odd behavior by relying on old mval values) */
+               event->mval[0]= -1;
+               event->mval[1]= -1;
+       }
 }
 
 static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties, ReportList *reports, short poll_only)
@@ -1776,6 +1781,8 @@ 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);
                        
+                       wm_region_mouse_co(C, event);
+
                        /* first we do priority handlers, modal + some limited keymaps */
                        action |= wm_handlers_do(C, event, &win->modalhandlers);
                        
@@ -1811,10 +1818,12 @@ void wm_event_do_handlers(bContext *C)
                                                                if(wm_event_inside_i(event, &ar->winrct)) {
                                                                        CTX_wm_region_set(C, ar);
                                                                        
+                                                                       /* call even on non mouse events, since the */
+                                                                       wm_region_mouse_co(C, event);
+
                                                                        /* does polls for drop regions and checks uibuts */
                                                                        /* need to be here to make sure region context is true */
                                                                        if(ELEM(event->type, MOUSEMOVE, EVT_DROP)) {
-                                                                               wm_region_mouse_co(C, event);
                                                                                wm_drags_check_ops(C, event);
                                                                        }
                                                                        
@@ -1834,9 +1843,10 @@ void wm_event_do_handlers(bContext *C)
 
                                                CTX_wm_region_set(C, NULL);
 
-                                               if((action & WM_HANDLER_BREAK) == 0)
+                                               if((action & WM_HANDLER_BREAK) == 0) {
+                                                       wm_region_mouse_co(C, event); /* only invalidates event->mval in this case */
                                                        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 */
@@ -1848,6 +1858,8 @@ void wm_event_do_handlers(bContext *C)
                                        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));
 
+                                       wm_region_mouse_co(C, event);
+
                                        action |= wm_handlers_do(C, event, &win->handlers);
 
                                        /* fileread case */