diff --git a/do/settings_def.go b/do/settings_def.go index 15f6139f40a7..4ce230602c67 100644 --- a/do/settings_def.go +++ b/do/settings_def.go @@ -292,6 +292,7 @@ var ( "after UseDefaultState in FileStates)"), mkField("RestoreSession", Bool, true, "if true and SessionData isn't empty, that session will be restored at startup").setExpert(), + mkField("LazyLoading", Bool, true, "when restoring session, delay loading of documents until their tab is selected").setVersion("3.6"), mkField("UiLanguage", String, nil, "ISO code of the current UI language").setDoc("[ISO code](langs.html) of the current UI language"), mkField("InverseSearchCmdLine", String, nil, diff --git a/do/settings_gen_code.go b/do/settings_gen_code.go index ddbe86eca614..da015bcef4eb 100644 --- a/do/settings_gen_code.go +++ b/do/settings_gen_code.go @@ -458,7 +458,7 @@ func updateSumatraWebsite() string { cmd.Dir = dir runCmdLoggedMust(cmd) } - dir = filepath.Join(dir, "www") + dir = filepath.Join(dir, "server", "www") panicIf(!dirExists(dir), "directory for sumatra website '%s' doesn't exist", dir) return dir } diff --git a/docs/releasenotes.txt b/docs/releasenotes.txt index 1d72ba447fbf..1db1d749d9e8 100644 --- a/docs/releasenotes.txt +++ b/docs/releasenotes.txt @@ -5,6 +5,7 @@ Next version: 3.6 * -search now copies search term to find box so that F3 works +* add LazyLoading advanced setting 3.5.2 (2023-10-25) * fix not showing tab text diff --git a/src/Settings.h b/src/Settings.h index 424445f83f28..2745450f19e4 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -345,6 +345,9 @@ struct GlobalPrefs { // if true and SessionData isn't empty, that session will be restored // at startup bool restoreSession; + // when restoring session, delay loading of documents until their tab + // is selected + bool lazyLoading; // ISO code of the current UI language char* uiLanguage; // pattern used to launch the LaTeX editor when doing inverse search @@ -654,7 +657,7 @@ static const StructInfo gFILETIMEInfo = {sizeof(FILETIME), 2, gFILETIMEFields, " static const FieldInfo gGlobalPrefsFields[] = { {(size_t)-1, SettingType::Comment, - (intptr_t) "For documentation, see https://www.sumatrapdfreader.org/settings/settings3-5.html"}, + (intptr_t) "For documentation, see https://www.sumatrapdfreader.org/settings/settings3-6.html"}, {offsetof(GlobalPrefs, theme), SettingType::String, (intptr_t) ""}, {offsetof(GlobalPrefs, fixedPageUI), SettingType::Struct, (intptr_t)&gFixedPageUIInfo}, {offsetof(GlobalPrefs, comicBookUI), SettingType::Struct, (intptr_t)&gComicBookUIInfo}, @@ -676,6 +679,7 @@ static const FieldInfo gGlobalPrefsFields[] = { {offsetof(GlobalPrefs, rememberOpenedFiles), SettingType::Bool, true}, {offsetof(GlobalPrefs, rememberStatePerDocument), SettingType::Bool, true}, {offsetof(GlobalPrefs, restoreSession), SettingType::Bool, true}, + {offsetof(GlobalPrefs, lazyLoading), SettingType::Bool, true}, {offsetof(GlobalPrefs, uiLanguage), SettingType::String, 0}, {offsetof(GlobalPrefs, inverseSearchCmdLine), SettingType::String, 0}, {offsetof(GlobalPrefs, enableTeXEnhancements), SettingType::Bool, false}, @@ -719,13 +723,14 @@ static const FieldInfo gGlobalPrefsFields[] = { {(size_t)-1, SettingType::Comment, (intptr_t) "Settings below are not recognized by the current version"}, }; static const StructInfo gGlobalPrefsInfo = { - sizeof(GlobalPrefs), 61, gGlobalPrefsFields, + sizeof(GlobalPrefs), 62, gGlobalPrefsFields, "\0Theme\0FixedPageUI\0ComicBookUI\0ChmUI\0\0SelectionHandlers\0ExternalViewers\0\0ZoomLevels\0ZoomIncrement\0\0Pri" "nterDefaults\0ForwardSearch\0Annotations\0DefaultPasswords\0\0RememberOpenedFiles\0RememberStatePerDocument\0Resto" - "reSession\0UiLanguage\0InverseSearchCmdLine\0EnableTeXEnhancements\0DefaultDisplayMode\0DefaultZoom\0Shortcuts\0Es" - "cToExit\0ReuseInstance\0ReloadModifiedDocuments\0\0MainWindowBackground\0FullPathInTitle\0ShowMenubar\0ShowToolbar" - "\0ShowFavorites\0ShowToc\0NoHomeTab\0TocDy\0SidebarDx\0ToolbarSize\0TabWidth\0TreeFontSize\0TreeFontWeightOffset\0" - "TreeFontName\0SmoothScroll\0ShowStartPage\0CheckForUpdates\0VersionToSkip\0WindowState\0WindowPos\0UseTabs\0UseSys" - "Colors\0CustomScreenDPI\0\0FileStates\0SessionData\0ReopenOnce\0TimeOfLastUpdateCheck\0OpenCountWeek\0\0"}; + "reSession\0LazyLoading\0UiLanguage\0InverseSearchCmdLine\0EnableTeXEnhancements\0DefaultDisplayMode\0DefaultZoom\0" + "Shortcuts\0EscToExit\0ReuseInstance\0ReloadModifiedDocuments\0\0MainWindowBackground\0FullPathInTitle\0ShowMenubar" + "\0ShowToolbar\0ShowFavorites\0ShowToc\0NoHomeTab\0TocDy\0SidebarDx\0ToolbarSize\0TabWidth\0TreeFontSize\0TreeFontW" + "eightOffset\0TreeFontName\0SmoothScroll\0ShowStartPage\0CheckForUpdates\0VersionToSkip\0WindowState\0WindowPos\0Us" + "eTabs\0UseSysColors\0CustomScreenDPI\0\0FileStates\0SessionData\0ReopenOnce\0TimeOfLastUpdateCheck\0OpenCountWeek" + "\0\0"}; #endif diff --git a/src/SumatraPDF.cpp b/src/SumatraPDF.cpp index d113b32ffde5..8d86cb55b2d9 100644 --- a/src/SumatraPDF.cpp +++ b/src/SumatraPDF.cpp @@ -102,9 +102,6 @@ bool gDebugShowLinks = false; // so always disable bool gShowFrameRate = false; -// if true, Enable lazyload session tabs on startup -bool gEnableLazyLoad = true; - // in plugin mode, the window's frame isn't drawn and closing and // fullscreen are disabled, so that SumatraPDF can be displayed // embedded (e.g. in a web browser) @@ -1269,7 +1266,7 @@ void ReloadDocument(MainWindow* win, bool autoRefresh) { return; } // TODO: maybe should ensure it never is called for IsAboutTab() ? - // This only happens if gEnableLazyLoad is true + // This only happens if gLazyLoading is true if (tab->IsAboutTab()) { return; } @@ -1976,7 +1973,7 @@ void LoadModelIntoTab(WindowTab* tab) { } MainWindow* win = tab->win; - if (gEnableLazyLoad && win->ctrl && !tab->ctrl && !tab->IsAboutTab()) { + if (gGlobalPrefs->lazyLoading && win->ctrl && !tab->ctrl && !tab->IsAboutTab()) { NotificationCreateArgs args; args.hwndParent = win->hwndCanvas; args.msg = str::FormatTemp(_TRA("Please wait - loading...")); @@ -2027,7 +2024,7 @@ void LoadModelIntoTab(WindowTab* tab) { SetFocus(win->hwndFrame); if (!tab->IsAboutTab()) { - if (gEnableLazyLoad && !tab->ctrl) { + if (gGlobalPrefs->lazyLoading && !tab->ctrl) { ReloadDocument(win, false); } else { if (tab->reloadOnFocus) { diff --git a/src/SumatraPDF.h b/src/SumatraPDF.h index c830f0e17e4e..e2fe59de4f2e 100644 --- a/src/SumatraPDF.h +++ b/src/SumatraPDF.h @@ -97,8 +97,6 @@ extern HCURSOR gCursorDrag; extern bool gCrashOnOpen; extern HWND gLastActiveFrameHwnd; -extern bool gEnableLazyLoad; - #define gPluginMode (gPluginURL != nullptr) void InitializePolicies(bool restrict); diff --git a/src/SumatraStartup.cpp b/src/SumatraStartup.cpp index 5e478a5052e2..e9d374adffa6 100644 --- a/src/SumatraStartup.cpp +++ b/src/SumatraStartup.cpp @@ -1286,10 +1286,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { logf("WinMain: skipping RestoreTabOnStartup() because state->filePath is empty\n"); continue; } - RestoreTabOnStartup(win, state, gEnableLazyLoad); + RestoreTabOnStartup(win, state, gGlobalPrefs->lazyLoading); } TabsSelect(win, data->tabIndex - 1); - if (gEnableLazyLoad) { + if (gGlobalPrefs->lazyLoading) { ReloadDocument(win, false); } }