WIP: Brush assets project #106303
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_main.hh"
|
||||
#include "BKE_screen.hh"
|
||||
#include "BKE_workspace.h"
|
||||
|
||||
#include "WM_api.hh"
|
||||
|
@ -49,6 +50,20 @@ static void bpy_rna_context_temp_set_screen_for_window(bContext *C, wmWindow *wi
|
|||
WM_window_set_active_screen(win, workspace, screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switching to or away from this screen is not supported.
|
||||
*/
|
||||
static bool wm_check_screen_switch_supported(const bScreen *screen)
|
||||
{
|
||||
if (screen->temp != 0) {
|
||||
return false;
|
||||
}
|
||||
if (BKE_screen_is_fullscreen_area(screen)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool wm_check_window_exists(const Main *bmain, const wmWindow *win)
|
||||
{
|
||||
LISTBASE_FOREACH (wmWindowManager *, wm, &bmain->wm) {
|
||||
|
@ -233,9 +248,17 @@ static PyObject *bpy_rna_context_temp_override_enter(BPyContextTempOverride *sel
|
|||
|
||||
/* Skip some checks when the screen is unchanged. */
|
||||
if (self->ctx_init.screen_is_set) {
|
||||
if (screen->temp != 0) {
|
||||
/* Switching away from a temporary screen isn't supported. */
|
||||
if ((self->ctx_init.screen != nullptr) &&
|
||||
!wm_check_screen_switch_supported(self->ctx_init.screen))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Overriding context with temporary screen is not supported");
|
||||
"Overriding context with an active temporary screen isn't supported");
|
||||
return nullptr;
|
||||
}
|
||||
if (!wm_check_screen_switch_supported(screen)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Overriding context with temporary screen isn't supported");
|
||||
return nullptr;
|
||||
}
|
||||
if (BKE_workspace_layout_find_global(bmain, screen, nullptr) == nullptr) {
|
||||
|
@ -308,10 +331,15 @@ static PyObject *bpy_rna_context_temp_override_exit(BPyContextTempOverride *self
|
|||
if (self->ctx_temp_orig.screen && wm_check_screen_exists(bmain, self->ctx_temp_orig.screen)) {
|
||||
wmWindow *win = self->ctx_temp.win_is_set ? self->ctx_temp.win : self->ctx_init.win;
|
||||
if (win && wm_check_window_exists(bmain, win)) {
|
||||
/* Disallow switching away from temporary-screens & full-screen areas, while it could be
|
||||
* useful to support this closing a these screens uses different and more involved logic
|
||||
* compared with switching between user managed screens, see: #117188. */
|
||||
if (wm_check_screen_switch_supported(WM_window_get_active_screen(win))) {
|
||||
bpy_rna_context_temp_set_screen_for_window(C, win, self->ctx_temp_orig.screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Account for for the window to be freed on file-read,
|
||||
* in this case the window should not be restored, see: #92818.
|
||||
|
@ -523,6 +551,10 @@ PyDoc_STRVAR(bpy_context_temp_override_doc,
|
|||
" :type window: :class:`bpy.types.Window`\n"
|
||||
" :arg screen: Screen override or None.\n"
|
||||
"\n"
|
||||
" .. note:: Switching to or away from full-screen areas & temporary screens "
|
||||
"isn't supported. Passing in these screens will raise an exception, "
|
||||
"actions that leave the context such screens won't restore the prior screen.\n"
|
||||
"\n"
|
||||
" .. note:: Changing the screen has wider implications "
|
||||
"than other arguments as it will also change the works-space "
|
||||
"and potentially the scene (when pinned).\n"
|
||||
|
|
Loading…
Reference in New Issue