Fix #108643: Blender window does not open to full dimensions of the desktop.

When opening 'homefile' (i.e. startup or factory startup) at Blender
start (i.e. when there is no existing WM yet), the size of the windows
in the newly read WM is reset to zero, which will then cause `WM_check`
to re-size them the the maximum possible size on current monitor.

Regression from ebb5643e59.
This commit is contained in:
Bastien Montagne 2023-06-07 20:01:11 +02:00
parent 16d077e7e4
commit 32bbfbb06e
2 changed files with 15 additions and 8 deletions

View File

@ -72,6 +72,8 @@ typedef struct BlendFileData {
*/
typedef struct BlendFileReadWMSetupData {
struct wmWindowManager *old_wm; /** The existing WM when filereading process is started. */
bool is_read_homefile;
} BlendFileReadWMSetupData;
struct BlendFileReadParams {

View File

@ -182,11 +182,14 @@ bool wm_file_or_session_data_has_unsaved_changes(const Main *bmain, const wmWind
* Clear several WM/UI runtime data that would make later complex WM handling impossible.
*
* Return data should be cleared by #wm_file_read_setup_wm_finalize. */
static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C, Main *bmain)
static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C,
Main *bmain,
const bool is_read_homefile)
{
BLI_assert(BLI_listbase_count_at_most(&bmain->wm, 2) <= 1);
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
BlendFileReadWMSetupData *wm_setup_data = MEM_cnew<BlendFileReadWMSetupData>(__func__);
wm_setup_data->is_read_homefile = is_read_homefile;
if (wm == nullptr) {
return wm_setup_data;
@ -401,6 +404,13 @@ static void wm_file_read_setup_wm_finalize(bContext *C,
BLI_assert(wm_setup_data != nullptr);
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
/* If reading home (startup) file, and there was no previous WM, clear the size of the windows in
* newly read WM so that they get resized to occupy the whole available space on current monitor.
*/
if (wm_setup_data->is_read_homefile && wm_setup_data->old_wm == nullptr) {
wm_clear_default_size(C);
}
if (wm == nullptr) {
/* Add a default WM in case none exists in newly read main (should only happen when opening
* an old pre-2.5 .blend file at startup). */
@ -994,7 +1004,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
/* Put WM into a stable state for post-readfile processes (kill jobs, removes event handlers,
* message bus, and so on). */
BlendFileReadWMSetupData *wm_setup_data = wm_file_read_setup_wm_init(C, bmain);
BlendFileReadWMSetupData *wm_setup_data = wm_file_read_setup_wm_init(C, bmain, false);
/* This flag is initialized by the operator but overwritten on read.
* need to re-enable it here else drivers and registered scripts won't work. */
@ -1117,7 +1127,6 @@ void wm_homefile_read_ex(bContext *C,
/* Context does not always have valid main pointer here. */
Main *bmain = G_MAIN;
#endif
ListBase wmbase;
bool success = false;
/* May be enabled, when the user configuration doesn't exist. */
@ -1223,7 +1232,7 @@ void wm_homefile_read_ex(bContext *C,
if (use_data) {
/* Put WM into a stable state for post-readfile processes (kill jobs, removes event handlers,
* message bus, and so on). */
wm_setup_data = wm_file_read_setup_wm_init(C, bmain);
wm_setup_data = wm_file_read_setup_wm_init(C, bmain, true);
}
filepath_startup[0] = '\0';
@ -1357,10 +1366,6 @@ void wm_homefile_read_ex(bContext *C,
success = true;
bmain = CTX_data_main(C);
}
if (use_data && BLI_listbase_is_empty(&wmbase)) {
wm_clear_default_size(C);
}
}
if (use_empty_data) {