Fix #108746: Defaults / Save startup file don't save the window size.

Hopefully now the behavior is fully consistent with before the refactor,
current implemented one by this commit:

- When loading factory settings file on startup, go full-screen.
- In all other startup cases, use size as stored in the startup .blend
  file.

Regression from ebb5643e59 and 32bbfbb06e.
This commit is contained in:
Bastien Montagne 2023-06-09 11:26:00 +02:00
parent 34bca3be26
commit 7ef8389dad
2 changed files with 14 additions and 3 deletions

View File

@ -76,7 +76,10 @@ typedef struct BlendFileReadWMSetupData {
/** The existing WM when filereading process is started. */ /** The existing WM when filereading process is started. */
struct wmWindowManager *old_wm; struct wmWindowManager *old_wm;
/** The startup file is being read. */
bool is_read_homefile; bool is_read_homefile;
/** The factory startup file is being read. */
bool is_factory_startup;
} BlendFileReadWMSetupData; } BlendFileReadWMSetupData;
struct BlendFileReadParams { struct BlendFileReadParams {

View File

@ -190,6 +190,8 @@ static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C,
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first); wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
BlendFileReadWMSetupData *wm_setup_data = MEM_cnew<BlendFileReadWMSetupData>(__func__); BlendFileReadWMSetupData *wm_setup_data = MEM_cnew<BlendFileReadWMSetupData>(__func__);
wm_setup_data->is_read_homefile = is_read_homefile; wm_setup_data->is_read_homefile = is_read_homefile;
/* This info is not always known yet when this function is called. */
wm_setup_data->is_factory_startup = false;
if (wm == nullptr) { if (wm == nullptr) {
return wm_setup_data; return wm_setup_data;
@ -404,10 +406,13 @@ static void wm_file_read_setup_wm_finalize(bContext *C,
BLI_assert(wm_setup_data != nullptr); BLI_assert(wm_setup_data != nullptr);
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first); 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 /* If reading factory startup file, and there was no previous WM, clear the size of the windows
* newly read WM so that they get resized to occupy the whole available space on current monitor. * 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) { if (wm_setup_data->is_read_homefile && wm_setup_data->is_factory_startup &&
wm_setup_data->old_wm == nullptr)
{
wm_clear_default_size(C); wm_clear_default_size(C);
} }
@ -1352,6 +1357,7 @@ void wm_homefile_read_ex(bContext *C,
BKE_reportf(reports, RPT_ERROR, "Could not read \"%s\"", filepath_startup_override); BKE_reportf(reports, RPT_ERROR, "Could not read \"%s\"", filepath_startup_override);
} }
bool loaded_factory_settings = false;
if (success == false) { if (success == false) {
BlendFileReadParams read_file_params{}; BlendFileReadParams read_file_params{};
read_file_params.is_startup = true; read_file_params.is_startup = true;
@ -1364,6 +1370,7 @@ void wm_homefile_read_ex(bContext *C,
BKE_blendfile_read_setup_readfile( BKE_blendfile_read_setup_readfile(
C, bfd, &read_file_params, wm_setup_data, &read_report, true, nullptr); C, bfd, &read_file_params, wm_setup_data, &read_report, true, nullptr);
success = true; success = true;
loaded_factory_settings = true;
bmain = CTX_data_main(C); bmain = CTX_data_main(C);
} }
} }
@ -1418,6 +1425,7 @@ void wm_homefile_read_ex(bContext *C,
if (use_data) { if (use_data) {
/* Finalize handling of WM, using the read WM and/or the current WM depending on things like /* Finalize handling of WM, using the read WM and/or the current WM depending on things like
* whether the UI is loaded from the .blend file or not, etc. */ * whether the UI is loaded from the .blend file or not, etc. */
wm_setup_data->is_factory_startup = loaded_factory_settings;
wm_file_read_setup_wm_finalize(C, bmain, wm_setup_data); wm_file_read_setup_wm_finalize(C, bmain, wm_setup_data);
} }