Page Menu
Home
Search
Configure Global Search
Log In
Paste
P472
D2451 workaround
Active
Public
Actions
Authored by
Campbell Barton (campbellbarton)
on May 1 2017, 9:25 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
diff --git a/source/blender/blenkernel/BKE_workspace.h b/source/blender/blenkernel/BKE_workspace.h
index 52aa06aa97c..48c1df19d8b 100644
--- a/source/blender/blenkernel/BKE_workspace.h
+++ b/source/blender/blenkernel/BKE_workspace.h
@@ -58,6 +58,9 @@ void BKE_workspace_remove(WorkSpace *workspace, struct Main *bmain);
WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const struct Main *bmain);
void BKE_workspace_instance_hook_free(WorkSpaceInstanceHook *hook, const struct Main *bmain);
+WorkSpace *BKE_workspaces_find_from_screen(
+ struct Main *bmain, struct bScreen *screen);
+
struct WorkSpaceLayout *BKE_workspace_layout_add(
WorkSpace *workspace,
struct bScreen *screen,
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 07a5e2eae5b..4a2be83f422 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -118,6 +118,19 @@ static void *workspace_relation_get_data_matching_parent(
}
}
+WorkSpace *BKE_workspaces_find_from_screen(
+ Main *bmain, bScreen *screen)
+{
+ for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {
+ if (workspace_layout_find_exec(workspace, screen)) {
+ return workspace;
+ }
+ }
+
+ return NULL;
+}
+
+
/**
* Checks if \a screen is already used within any workspace. A screen should never be assigned to multiple
* WorkSpaceLayouts, but that should be ensured outside of the BKE_workspace module and without such checks.
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index ca63de31578..3452286c874 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1252,9 +1252,16 @@ bScreen *screen_change_prepare(bScreen *screen_old, bScreen *screen_new, Main *b
void screen_changed_update(bContext *C, wmWindow *win, bScreen *sc)
{
+ Main *bmain = CTX_data_main(C);
Scene *scene = WM_window_get_active_scene(win);
- WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
- WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, sc);
+ WorkSpace *workspace_old = BKE_workspace_active_get(win->workspace_hook);
+ WorkSpace *workspace_new = BKE_workspaces_find_from_screen(bmain, sc);
+
+ if (workspace_old != workspace_new) {
+ BKE_workspace_active_set(win->workspace_hook, workspace_new);
+ }
+
+ WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace_new, sc);
CTX_wm_window_set(C, win); /* stores C->wm.screen... hrmf */
Event Timeline
Campbell Barton (campbellbarton)
created this paste.
May 1 2017, 9:25 PM
Campbell Barton (campbellbarton)
mentioned this in
D2451: Main Workspace Integration
.
May 1 2017, 10:31 PM
Log In to Comment