From c434a91c91fff5509fdb848ad567ba31988262c6 Mon Sep 17 00:00:00 2001 From: Luke Date: Fri, 14 Aug 2020 21:17:46 +0100 Subject: [PATCH] FileManager: Apply wallpaper on startup I noticed that nothing actually applies the wallpaper on startup. I wasn't sure where to put the responsibility, so I gave it to the desktop mode file manager. Also adds a save_config option to set_wallpaper so it doesn't needlessly save the config. --- Applications/FileManager/main.cpp | 7 +++++++ Libraries/LibGUI/Desktop.cpp | 4 ++-- Libraries/LibGUI/Desktop.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index 2cdd992c134..11becb159cb 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -242,6 +243,12 @@ int run_in_desktop_mode(RefPtr config, String initial_location desktop_view_context_menu->popup(event.screen_position()); }; + auto wm_config = Core::ConfigFile::get_for_app("WindowManager"); + auto selected_wallpaper = wm_config->read_entry("Background", "Wallpaper", ""); + if (!selected_wallpaper.is_empty()) { + GUI::Desktop::the().set_wallpaper(selected_wallpaper, false); + } + window->show(); return GUI::Application::the()->exec(); } diff --git a/Libraries/LibGUI/Desktop.cpp b/Libraries/LibGUI/Desktop.cpp index f68613a5de9..5f882c366bf 100644 --- a/Libraries/LibGUI/Desktop.cpp +++ b/Libraries/LibGUI/Desktop.cpp @@ -64,12 +64,12 @@ void Desktop::set_wallpaper_mode(const StringView& mode) WindowServerConnection::the().post_message(Messages::WindowServer::SetWallpaperMode(mode)); } -bool Desktop::set_wallpaper(const StringView& path) +bool Desktop::set_wallpaper(const StringView& path, bool save_config) { WindowServerConnection::the().post_message(Messages::WindowServer::AsyncSetWallpaper(path)); auto ret_val = WindowServerConnection::the().wait_for_specific_message()->success(); - if (ret_val) { + if (ret_val && save_config) { RefPtr config = Core::ConfigFile::get_for_app("WindowManager"); dbg() << "Saving wallpaper path '" << path << "' to config file at " << config->file_name(); config->write_entry("Background", "Wallpaper", path); diff --git a/Libraries/LibGUI/Desktop.h b/Libraries/LibGUI/Desktop.h index fcd2f7d943f..5b531ad3d1b 100644 --- a/Libraries/LibGUI/Desktop.h +++ b/Libraries/LibGUI/Desktop.h @@ -43,7 +43,7 @@ public: void set_wallpaper_mode(const StringView& mode); String wallpaper() const; - bool set_wallpaper(const StringView& path); + bool set_wallpaper(const StringView& path, bool save_config = true); Gfx::IntRect rect() const { return m_rect; }