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.
This commit is contained in:
Brecht Van Lommel 2018-05-17 10:56:36 +02:00
parent 35a298db52
commit 12e523d12c
5 changed files with 19 additions and 10 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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);