mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-13 12:52:32 +08:00
fix: improve how default background is determinated, hopefully improves #219
This commit is contained in:
parent
cdfa4ff7a1
commit
9712f20140
@ -107,6 +107,11 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) {
|
||||
// to have any value
|
||||
this->settings.general.screenBackgrounds [lastScreen] = translateBackground (optarg);
|
||||
this->settings.general.screenScalings [lastScreen] = this->settings.render.window.scalingMode;
|
||||
|
||||
// update default background if not set
|
||||
if (this->settings.general.defaultBackground.empty()) {
|
||||
this->settings.general.defaultBackground = translateBackground (optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'o': {
|
||||
|
@ -27,7 +27,6 @@ namespace WallpaperEngine::Application {
|
||||
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context,
|
||||
WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext) :
|
||||
m_context (context),
|
||||
m_defaultBackground (nullptr),
|
||||
m_browserContext (browserContext) {
|
||||
this->loadBackgrounds ();
|
||||
this->setupProperties ();
|
||||
@ -168,17 +167,12 @@ void CWallpaperApplication::setupContainer (CCombinedContainer& container, const
|
||||
}
|
||||
|
||||
void CWallpaperApplication::loadBackgrounds () {
|
||||
// load default background if specified
|
||||
if (!this->m_context.settings.general.defaultBackground.empty ()) {
|
||||
this->m_defaultBackground = this->loadBackground (this->m_context.settings.general.defaultBackground);
|
||||
}
|
||||
|
||||
for (const auto& [background, path] : this->m_context.settings.general.screenBackgrounds) {
|
||||
// screens with no background should use the default
|
||||
for (const auto& [screen, path] : this->m_context.settings.general.screenBackgrounds) {
|
||||
// screens with no screen should use the default
|
||||
if (path.empty ()) {
|
||||
this->m_backgrounds [background] = this->m_defaultBackground;
|
||||
this->m_backgrounds [screen] = this->loadBackground (this->m_context.settings.general.defaultBackground);
|
||||
} else {
|
||||
this->m_backgrounds [background] = this->loadBackground (path);
|
||||
this->m_backgrounds [screen] = this->loadBackground (path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -211,9 +205,6 @@ void CWallpaperApplication::setupPropertiesForProject (const Core::CProject* pro
|
||||
void CWallpaperApplication::setupProperties () {
|
||||
for (const auto& [backgrounc, info] : this->m_backgrounds)
|
||||
this->setupPropertiesForProject (info);
|
||||
|
||||
if (this->m_defaultBackground != nullptr)
|
||||
this->setupPropertiesForProject (this->m_defaultBackground);
|
||||
}
|
||||
|
||||
void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filename, FREE_IMAGE_FORMAT format) {
|
||||
@ -419,10 +410,6 @@ const std::map<std::string, Core::CProject*>& CWallpaperApplication::getBackgrou
|
||||
return this->m_backgrounds;
|
||||
}
|
||||
|
||||
Core::CProject* CWallpaperApplication::getDefaultBackground () const {
|
||||
return this->m_defaultBackground;
|
||||
}
|
||||
|
||||
CApplicationContext& CWallpaperApplication::getContext () const {
|
||||
return this->m_context;
|
||||
}
|
||||
|
@ -59,10 +59,6 @@ class CWallpaperApplication {
|
||||
* @return Maps screens to loaded backgrounds
|
||||
*/
|
||||
[[nodiscard]] const std::map<std::string, Core::CProject*>& getBackgrounds () const;
|
||||
/**
|
||||
* @return The default background to use if no specific project is loaded
|
||||
*/
|
||||
[[nodiscard]] Core::CProject* getDefaultBackground () const;
|
||||
/**
|
||||
* @return The current application context
|
||||
*/
|
||||
@ -114,8 +110,6 @@ class CWallpaperApplication {
|
||||
*/
|
||||
void takeScreenshot (const std::filesystem::path& filename, FREE_IMAGE_FORMAT format);
|
||||
|
||||
/** The default background to display if no specific background was loaded */
|
||||
Core::CProject* m_defaultBackground;
|
||||
/** The application context that contains the current app settings */
|
||||
CApplicationContext& m_context;
|
||||
/** Maps screens to backgrounds */
|
||||
|
@ -27,19 +27,6 @@ const ITexture* CTextureCache::resolve (const std::string& filename) {
|
||||
}
|
||||
}
|
||||
|
||||
if (this->getContext ().getApp ().getDefaultBackground () != nullptr) {
|
||||
try {
|
||||
const ITexture* texture =
|
||||
this->getContext ().getApp ().getDefaultBackground ()->getContainer ()->readTexture (filename);
|
||||
|
||||
this->store (filename, texture);
|
||||
|
||||
return texture;
|
||||
} catch (CAssetLoadException&) {
|
||||
// ignored, this happens if we're looking at the wrong background
|
||||
}
|
||||
}
|
||||
|
||||
throw CAssetLoadException (filename, "Cannot find file");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user