Commit: 12e523d12c88d05d220f426bdb08525a572649d6
Author: Brecht Van Lommel
Date:   Thu May 17 10:56:36 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB12e523d12c88d05d220f426bdb08525a572649d6

Fix menu navigation and modal tools affecting the active region.

We updated the active region during redraw to fix missing updates on
file load, restrict it more now to avoid unwanted updates.

===================================================================

M       source/blender/editors/include/ED_screen.h
M       source/blender/editors/screen/screen_edit.c
M       source/blender/windowmanager/intern/wm_draw.c
M       source/blender/windowmanager/intern/wm_event_system.c
M       source/blender/windowmanager/intern/wm_window.c

===================================================================

diff --git a/source/blender/editors/include/ED_screen.h 
b/source/blender/editors/include/ED_screen.h
index 4b22e691885..3d17afc2878 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -173,7 +173,7 @@ void    ED_screen_update_after_scene_change(
         const struct bScreen *screen,
         struct Scene *scene_new,
         struct ViewLayer *view_layer);
-void    ED_screen_set_active_region(struct bContext *C, const int xy[2]);
+void    ED_screen_set_active_region(struct bContext *C, struct wmWindow *win, 
const int xy[2]);
 void    ED_screen_exit(struct bContext *C, struct wmWindow *window, struct 
bScreen *screen);
 void    ED_screen_animation_timer(struct bContext *C, int redraws, int 
refresh, int sync, int enable);
 void    ED_screen_animation_timer_update(struct bScreen *screen, int redraws, 
int refresh);
diff --git a/source/blender/editors/screen/screen_edit.c 
b/source/blender/editors/screen/screen_edit.c
index 8ebdb5f32b8..7167b48c06e 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -848,6 +848,7 @@ void ED_screens_initialize(wmWindowManager *wm)
                        ED_screen_global_areas_create(win);
                }
                ED_screen_refresh(wm, win);
+               ED_screen_set_active_region(NULL, win, &win->eventstate->x);
        }
 }
 
@@ -992,9 +993,8 @@ static void screen_cursor_set(wmWindow *win, const int 
xy[2])
 
 /* called in wm_event_system.c. sets state vars in screen, cursors */
 /* event type is mouse move */
-void ED_screen_set_active_region(bContext *C, const int xy[2])
+void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
 {
-       wmWindow *win = CTX_wm_window(C);
        bScreen *scr = WM_window_get_active_screen(win);
 
        if (scr) {
@@ -1058,7 +1058,9 @@ void ED_screen_set_active_region(bContext *C, const int 
xy[2])
                                /* this used to be a notifier, but needs to be 
done immediate
                                 * because it can undo setting the right button 
as active due
                                 * to delayed notifier handling */
-                               UI_screen_free_active_but(C, scr);
+                               if (C) {
+                                       UI_screen_free_active_but(C, scr);
+                               }
                        }
                        else
                                region_cursor_set(win, false);
diff --git a/source/blender/windowmanager/intern/wm_draw.c 
b/source/blender/windowmanager/intern/wm_draw.c
index c7cd381747a..af70b3f1a5b 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -811,7 +811,6 @@ void wm_draw_update(bContext *C)
                        wm_window_make_drawable(wm, win);
 
                        /* notifiers for screen redraw */
-                       ED_screen_set_active_region(C, &win->eventstate->x);
                        ED_screen_ensure_updated(wm, win, screen);
 
                        wm_draw_window(C, win);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c 
b/source/blender/windowmanager/intern/wm_event_system.c
index b141433a58f..7963bf16534 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2818,7 +2818,7 @@ void wm_event_do_handlers(bContext *C)
                                /* Note: setting subwin active should be done 
here, after modal handlers have been done */
                                if (event->type == MOUSEMOVE) {
                                        /* state variables in screen, cursors. 
Also used in wm_draw.c, fails for modal handlers though */
-                                       ED_screen_set_active_region(C, 
&event->x);
+                                       ED_screen_set_active_region(C, win, 
&event->x);
                                        /* for regions having custom cursors */
                                        wm_paintcursor_test(C, event);
                                }
diff --git a/source/blender/windowmanager/intern/wm_window.c 
b/source/blender/windowmanager/intern/wm_window.c
index 2d94cc1dae7..2c28819ee58 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -608,6 +608,16 @@ void WM_window_set_dpi(wmWindow *win)
        BLF_default_dpi(U.pixelsize * U.dpi);
 }
 
+static void wm_window_ensure_eventstate(wmWindow *win)
+{
+       if (win->eventstate) {
+               return;
+       }
+
+       win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state");
+       wm_get_cursor_position(win, &win->eventstate->x, &win->eventstate->y);
+}
+
 /* belongs to below */
 static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, 
wmWindow *win)
 {
@@ -651,8 +661,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, 
const char *title, wm
                win->ghostwin = ghostwin;
                GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
                
-               if (win->eventstate == NULL)
-                       win->eventstate = MEM_callocN(sizeof(wmEvent), "window 
event state");
+               wm_window_ensure_eventstate(win);
 
                /* store actual window size in blender window */
                bounds = GHOST_GetClientBounds(win->ghostwin);
@@ -758,8 +767,7 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
                        wm_window_ghostwindow_add(wm, "Blender", win);
                }
                /* happens after fileread */
-               if (win->eventstate == NULL)
-                       win->eventstate = MEM_callocN(sizeof(wmEvent), "window 
event state");
+               wm_window_ensure_eventstate(win);
 
                /* add keymap handlers (1 handler for all keys in map!) */
                keymap = WM_keymap_find(wm->defaultconf, "Window", 0, 0);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to