Return success when a screen was added/removed
Currently unused, but useful for screen-operators.
This commit is contained in:
parent
3ee74feb2b
commit
acb99cfd7b
|
@ -102,8 +102,8 @@ void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
|
|||
void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note);
|
||||
bScreen *ED_screen_duplicate(struct wmWindow *win, struct bScreen *sc);
|
||||
bScreen *ED_screen_add(struct wmWindow *win, struct Scene *scene, const char *name);
|
||||
void ED_screen_set(struct bContext *C, struct bScreen *sc);
|
||||
void ED_screen_delete(struct bContext *C, struct bScreen *sc);
|
||||
bool ED_screen_set(struct bContext *C, struct bScreen *sc);
|
||||
bool ED_screen_delete(struct bContext *C, struct bScreen *sc);
|
||||
void ED_screen_set_scene(struct bContext *C, struct bScreen *screen, struct Scene *scene);
|
||||
bool ED_screen_delete_scene(struct bContext *C, struct Scene *scene);
|
||||
void ED_screen_set_subwinactive(struct bContext *C, struct wmEvent *event);
|
||||
|
|
|
@ -1469,23 +1469,23 @@ int ED_screen_area_active(const bContext *C)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* operator call, WM + Window + screen already existed before */
|
||||
/* Do NOT call in area/region queues! */
|
||||
void ED_screen_set(bContext *C, bScreen *sc)
|
||||
/**
|
||||
* operator call, WM + Window + screen already existed before
|
||||
*
|
||||
* \warning Do NOT call in area/region queues!
|
||||
* \returns success.
|
||||
*/
|
||||
bool ED_screen_set(bContext *C, bScreen *sc)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *oldscreen = CTX_wm_screen(C);
|
||||
ID *id;
|
||||
|
||||
/* validate screen, it's called with notifier reference */
|
||||
for (id = bmain->screen.first; id; id = id->next)
|
||||
if (sc == (bScreen *)id)
|
||||
break;
|
||||
if (id == NULL)
|
||||
return;
|
||||
|
||||
if (BLI_findindex(&bmain->screen, sc) == -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ELEM(sc->state, SCREENMAXIMIZED, SCREENFULL)) {
|
||||
/* find associated full */
|
||||
|
@ -1500,8 +1500,9 @@ void ED_screen_set(bContext *C, bScreen *sc)
|
|||
}
|
||||
|
||||
/* check for valid winid */
|
||||
if (sc->winid != 0 && sc->winid != win->winid)
|
||||
return;
|
||||
if (sc->winid != 0 && sc->winid != win->winid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oldscreen != sc) {
|
||||
wmTimer *wt = oldscreen->animtimer;
|
||||
|
@ -1566,6 +1567,8 @@ void ED_screen_set(bContext *C, bScreen *sc)
|
|||
*/
|
||||
DAG_on_visible_update(bmain, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ed_screen_used(wmWindowManager *wm, bScreen *sc)
|
||||
|
@ -1589,20 +1592,18 @@ static bool ed_screen_used(wmWindowManager *wm, bScreen *sc)
|
|||
}
|
||||
|
||||
/* only call outside of area/region loops */
|
||||
void ED_screen_delete(bContext *C, bScreen *sc)
|
||||
bool ED_screen_delete(bContext *C, bScreen *sc)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
bScreen *newsc;
|
||||
int delete = 1;
|
||||
|
||||
/* don't allow deleting temp fullscreens for now */
|
||||
if (ELEM(sc->state, SCREENMAXIMIZED, SCREENFULL)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* screen can only be in use by one window at a time, so as
|
||||
* long as we are able to find a screen that is unused, we
|
||||
* can safely assume ours is not in use anywhere an delete it */
|
||||
|
@ -1617,13 +1618,19 @@ void ED_screen_delete(bContext *C, bScreen *sc)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!newsc)
|
||||
return;
|
||||
if (!newsc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ED_screen_set(C, newsc);
|
||||
|
||||
if (delete && win->screen != sc)
|
||||
if (win->screen != sc) {
|
||||
BKE_libblock_free(bmain, sc);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void ed_screen_set_3dview_camera(Scene *scene, bScreen *sc, ScrArea *sa, View3D *v3d)
|
||||
|
|
Loading…
Reference in New Issue