From 7ef8389dad6b65264a5aee7de6a579256d0a01e2 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 9 Jun 2023 11:26:00 +0200 Subject: [PATCH] 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. --- source/blender/blenloader/BLO_readfile.h | 3 +++ source/blender/windowmanager/intern/wm_files.cc | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 3069a1405fd..b046d467baf 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -76,7 +76,10 @@ typedef struct BlendFileReadWMSetupData { /** The existing WM when filereading process is started. */ struct wmWindowManager *old_wm; + /** The startup file is being read. */ bool is_read_homefile; + /** The factory startup file is being read. */ + bool is_factory_startup; } BlendFileReadWMSetupData; struct BlendFileReadParams { diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index 7e559a5b945..30750dbfa18 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -190,6 +190,8 @@ static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C, wmWindowManager *wm = static_cast(bmain->wm.first); BlendFileReadWMSetupData *wm_setup_data = MEM_cnew(__func__); 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) { return wm_setup_data; @@ -404,10 +406,13 @@ static void wm_file_read_setup_wm_finalize(bContext *C, BLI_assert(wm_setup_data != nullptr); wmWindowManager *wm = static_cast(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 reading factory 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) { + if (wm_setup_data->is_read_homefile && wm_setup_data->is_factory_startup && + wm_setup_data->old_wm == nullptr) + { 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); } + bool loaded_factory_settings = false; if (success == false) { BlendFileReadParams read_file_params{}; read_file_params.is_startup = true; @@ -1364,6 +1370,7 @@ void wm_homefile_read_ex(bContext *C, BKE_blendfile_read_setup_readfile( C, bfd, &read_file_params, wm_setup_data, &read_report, true, nullptr); success = true; + loaded_factory_settings = true; bmain = CTX_data_main(C); } } @@ -1418,6 +1425,7 @@ void wm_homefile_read_ex(bContext *C, if (use_data) { /* 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. */ + wm_setup_data->is_factory_startup = loaded_factory_settings; wm_file_read_setup_wm_finalize(C, bmain, wm_setup_data); }