diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-28 05:41:36 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-28 05:41:36 +0300 |
commit | dcf0860dabf326e3a4b37ae15baae491e661cbf8 (patch) | |
tree | d922c5698ee58ae5153545798ebaaf4957803b98 /source | |
parent | 54295369049f9004cce6d8ccacaeda3a52e59a68 (diff) |
Fix tool not being initialized switching windows
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_toolsystem.h | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_toolsystem.c | 12 |
6 files changed, 29 insertions, 5 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 53476adf2ce..42b672d47b5 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6729,6 +6729,8 @@ static void direct_link_area(FileData *fd, ScrArea *area) area->butspacetype = SPACE_EMPTY; /* Should always be unset so that rna_Area_type_get works correctly */ area->region_active_win = -1; + area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE; + area->global = newdataadr(fd, area->global); /* if we do not have the spacetype registered we cannot diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index d2bc4079e08..3a6cac5d958 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1639,7 +1639,11 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) region_azones_add(screen, sa, ar, ar->alignment & ~RGN_SPLIT_PREV); } - WM_toolsystem_refresh_screen_area(workspace, view_layer, sa); + + if ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) { + WM_toolsystem_refresh_screen_area(workspace, view_layer, sa); + sa->flag |= AREA_FLAG_ACTIVE_TOOL_UPDATE; + } } static void region_update_rect(ARegion *ar) diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 99404fbf057..a62e7bc5036 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -368,7 +368,7 @@ enum { #endif /* update size of regions within the area */ AREA_FLAG_REGION_SIZE_UPDATE = (1 << 3), -// AREA_FLAG_DEPRECATED_4 = (1 << 4), + AREA_FLAG_ACTIVE_TOOL_UPDATE = (1 << 4), // AREA_FLAG_DEPRECATED_5 = (1 << 5), /* used to check if we should switch back to prevspace (of a different type) */ AREA_FLAG_TEMP_TYPE = (1 << 6), diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h index 9b056ddcae6..4318179c203 100644 --- a/source/blender/windowmanager/WM_toolsystem.h +++ b/source/blender/windowmanager/WM_toolsystem.h @@ -86,11 +86,11 @@ int WM_toolsystem_mode_from_spacetype( struct ViewLayer *view_layer, struct ScrArea *sa, int space_type); bool WM_toolsystem_key_from_context( struct ViewLayer *view_layer, struct ScrArea *sa, bToolKey *tkey); -void WM_toolsystem_update_from_context( - struct bContext *C, - struct WorkSpace *workspace, struct Scene *scene, struct ScrArea *sa); void WM_toolsystem_update_from_context_view3d(struct bContext *C); +void WM_toolsystem_update_from_context( + struct bContext *C, struct WorkSpace *workspace, struct ViewLayer *view_layer, + struct ScrArea *sa); bool WM_toolsystem_active_tool_is_brush(const struct bContext *C); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index d760780beb8..654a3cf05b9 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -73,6 +73,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "WM_toolsystem.h" #include "wm.h" #include "wm_draw.h" #include "wm_window.h" @@ -542,6 +543,11 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) ED_area_update_region_sizes(wm, win, sa); + if (sa->flag & AREA_FLAG_ACTIVE_TOOL_UPDATE) { + WM_toolsystem_update_from_context(C, CTX_wm_workspace(C), CTX_data_view_layer(C), sa); + sa->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE; + } + /* Then do actual drawing of regions. */ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->visible && ar->do_draw) { diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index 6857e057893..2b2a4f5e43a 100644 --- a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -851,6 +851,18 @@ void WM_toolsystem_update_from_context_view3d(bContext *C) toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); } +void WM_toolsystem_update_from_context( + bContext *C, WorkSpace *workspace, ViewLayer *view_layer, + ScrArea *sa) +{ + const bToolKey tkey = { + .space_type = sa->spacetype, + .mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype), + }; + toolsystem_reinit_ensure_toolref(C, workspace, &tkey, NULL); +} + + /** * For paint modes to support non-brush tools. */ |