[Bf-blender-cvs] [0bd8b8f] workspaces: Add/use function to get/set window workspace
Julian Eisel
noreply at git.blender.org
Sat Dec 24 01:32:22 CET 2016
Commit: 0bd8b8fc7175e201e5b8c8460e1b5e266a440f7f
Author: Julian Eisel
Date: Sat Dec 24 01:31:32 2016 +0100
Branches: workspaces
https://developer.blender.org/rB0bd8b8fc7175e201e5b8c8460e1b5e266a440f7f
Add/use function to get/set window workspace
===================================================================
M source/blender/editors/screen/screen_edit.c
M source/blender/editors/screen/screen_ops.c
M source/blender/editors/screen/workspace_edit.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm.c
M source/blender/windowmanager/intern/wm_event_system.c
M source/blender/windowmanager/intern/wm_files.c
M source/blender/windowmanager/intern/wm_window.c
===================================================================
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 8bc923e..159b111 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -956,8 +956,8 @@ void ED_screens_initialize(wmWindowManager *wm)
wmWindow *win;
for (win = wm->windows.first; win; win = win->next) {
- if (win->workspace == NULL) {
- win->workspace = G.main->workspaces.first;
+ if (WM_window_get_active_workspace(win) == NULL) {
+ WM_window_set_active_workspace(win, G.main->workspaces.first);
}
ED_screen_refresh(wm, win);
@@ -1450,6 +1450,7 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa)
ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const short state)
{
wmWindowManager *wm = CTX_wm_manager(C);
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
bScreen *sc, *oldscreen;
ARegion *ar;
@@ -1506,7 +1507,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
ED_screen_set(C, sc);
- BKE_workspace_layout_remove(win->workspace, layout_old, CTX_data_main(C));
+ BKE_workspace_layout_remove(workspace, layout_old, CTX_data_main(C));
/* After we've restored back to SCREENNORMAL, we have to wait with
* screen handling as it uses the area coords which aren't updated yet.
@@ -1516,7 +1517,6 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
}
else {
/* change from SCREENNORMAL to new state */
- WorkSpace *workspace = win->workspace;
WorkSpaceLayout *layout_new;
ScrArea *newa;
char newname[MAX_ID_NAME - 2];
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 74222a9..86e5f1f 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -979,8 +979,10 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot)
/* operator callback */
static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- wmWindow *newwin, *win;
+ wmWindow *newwin, *win = CTX_wm_window(C);
Scene *scene;
+ WorkSpace *workspace_old = WM_window_get_active_workspace(win);
+ WorkSpace *workspace_new;
WorkSpaceLayout *layout_new;
bScreen *newsc, *sc;
ScrArea *sa;
@@ -1016,9 +1018,12 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
*newwin->stereo3d_format = *win->stereo3d_format;
newwin->scene = scene;
- newwin->workspace = BKE_workspace_add(CTX_data_main(C), BKE_workspace_name_get(win->workspace));
+
+ workspace_new = BKE_workspace_add(CTX_data_main(C), BKE_workspace_name_get(workspace_old));
+ WM_window_set_active_workspace(newwin, workspace_new);
+
/* allocs new screen and adds to newly created window, using window size */
- layout_new = ED_workspace_layout_add(newwin->workspace, newwin, sc->id.name + 2);
+ layout_new = ED_workspace_layout_add(workspace_new, newwin, sc->id.name + 2);
newsc = BKE_workspace_layout_screen_get(layout_new);
WM_window_set_active_layout(newwin, layout_new);
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index 31527cd..ef5375f 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -59,7 +59,8 @@
bool ED_workspace_change(bContext *C, wmWindow *win, WorkSpace *ws_new)
{
Main *bmain = CTX_data_main(C);
- bScreen *screen_old = BKE_workspace_active_screen_get(win->workspace);
+ WorkSpace *workspace_old = WM_window_get_active_workspace(win);
+ bScreen *screen_old = BKE_workspace_active_screen_get(workspace_old);
bScreen *screen_new = BKE_workspace_active_screen_get(ws_new);
if (!(screen_new = screen_set_ensure_valid(bmain, win, screen_new))) {
@@ -68,7 +69,7 @@ bool ED_workspace_change(bContext *C, wmWindow *win, WorkSpace *ws_new)
if (screen_old != screen_new) {
screen_set_prepare(C, win, screen_new, screen_old);
- win->workspace = ws_new;
+ WM_window_set_active_workspace(win, ws_new);
screen_set_refresh(bmain, C, win);
}
BLI_assert(CTX_wm_workspace(C) == ws_new);
@@ -108,7 +109,7 @@ bool ED_workspace_delete(Main *bmain, bContext *C, wmWindow *win, WorkSpace *ws)
return false;
}
- if (win->workspace == ws) {
+ if (WM_window_get_active_workspace(win) == ws) {
WorkSpace *prev = BKE_workspace_prev_get(ws);
WorkSpace *next = BKE_workspace_next_get(ws);
@@ -140,10 +141,8 @@ static int workspace_new_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
- WorkSpace *workspace_old = win->workspace;
- WorkSpace *workspace;
+ WorkSpace *workspace = ED_workspace_duplicate(WM_window_get_active_workspace(win), bmain, win);
- workspace = ED_workspace_duplicate(workspace_old, bmain, win);
WM_event_add_notifier(C, NC_WORKSPACE | ND_WORKSPACE_SET, workspace);
return OPERATOR_FINISHED;
@@ -166,7 +165,7 @@ static int workspace_delete_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
- ED_workspace_delete(bmain, C, win, win->workspace);
+ ED_workspace_delete(bmain, C, win, WM_window_get_active_workspace(win));
return OPERATOR_FINISHED;
}
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 2fa4ebb..809f086 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -106,6 +106,8 @@ void WM_windows_scene_data_sync(const ListBase *win_lb, struct Scene *scene) ATT
struct Scene *WM_window_get_active_scene(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
void WM_window_set_active_scene(struct Main *bmain, struct bContext *C, struct wmWindow *win,
struct Scene *scene_new) ATTR_NONNULL();
+struct WorkSpace *WM_window_get_active_workspace(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
+void WM_window_set_active_workspace(struct wmWindow *win, struct WorkSpace *workspace) ATTR_NONNULL(1);
struct WorkSpaceLayout *WM_window_get_active_layout(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
void WM_window_set_active_layout(struct wmWindow *win, struct WorkSpaceLayout *layout) ATTR_NONNULL(1);
struct bScreen *WM_window_get_active_screen(const struct wmWindow *win) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index eefd832..337315b 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -420,7 +420,7 @@ void wm_add_default(bContext *C)
CTX_wm_manager_set(C, wm);
win = wm_window_new(C);
- win->workspace = G.main->workspaces.last;
+ WM_window_set_active_workspace(win, G.main->workspaces.last);
WM_window_set_active_screen(win, screen);
screen->winid = win->winid;
BLI_strncpy(win->screenname, screen->id.name + 2, sizeof(win->screenname));
@@ -442,7 +442,7 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
wm_autosave_timer_ended(wm);
while ((win = BLI_pophead(&wm->windows))) {
- win->workspace = NULL; /* prevent draw clear to use screen */
+ WM_window_set_active_workspace(win, NULL); /* prevent draw clear to use screen */
wm_draw_window_clear(win);
wm_window_free(C, wm, win);
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 82a0e4b..4a8dec1 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -314,7 +314,7 @@ void wm_event_do_notifiers(bContext *C)
printf("%s: screen set %p\n", __func__, note->reference);
}
else if (note->data == ND_SCREENDELETE) {
- WorkSpace *workspace = win->workspace;
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
WorkSpaceLayout *layout = note->reference;
ED_workspace_layout_delete(C, workspace, layout); // XXX hrms, think this over!
@@ -360,7 +360,7 @@ void wm_event_do_notifiers(bContext *C)
if (note->category == NC_WORKSPACE &&
note->reference &&
note->reference != screen &&
- note->reference != win->workspace &&
+ note->reference != WM_window_get_active_workspace(win) &&
note->reference != WM_window_get_active_layout(win))
{
/* pass */
@@ -2453,7 +2453,7 @@ void wm_event_do_handlers(bContext *C)
if (is_playing_sound != -1) {
bool is_playing_screen;
CTX_wm_window_set(C, win);
- CTX_wm_workspace_set(C, win->workspace);
+ CTX_wm_workspace_set(C, WM_window_get_active_workspace(win));
CTX_data_scene_set(C, scene);
is_playing_screen = (ED_screen_animation_playing(wm) != NULL);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index b6c982a..6d61aa3 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -256,7 +256,7 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
WM_window_set_active_screen(win, screen);
}
else {
- WorkSpace *workspace = win->workspace;
+ WorkSpace *workspace = WM_window_get_active_workspace(win);
WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate(workspace, layout_old, win);
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 7ca6596..1d93033 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -253,6 +253,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src)
{
Main *bmain = CTX_data_main(C);
wmWindow *win_dst = wm_window_new(C);
+ WorkSpace *workspace_src = WM_window_get_active_workspace(win_src);
Scene *scene = WM_window_get_active_scene(win_src);
bScreen *new_screen;
@@ -262,7 +263,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src)
win
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list