diff options
author | Ben Maxwell <macdue@dueutil.tech> | 2022-04-03 10:51:54 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-03 12:58:46 +0200 |
commit | 8070a982887be775ee657798452248ce42506d21 (patch) | |
tree | e9b781a33cb2b5ca856c445bbb785f61c5b2c658 /Userland/Services | |
parent | e6ad55ab5328dc2bb5538c2ed7469b2a973f12ee (diff) | |
download | serenity-8070a982887be775ee657798452248ce42506d21.zip |
DisplaySettings+WindowServer: Allow updating theme without background
With this change you can now set the theme and background color at the
same time in the Display Settings. Before if both were changed
before hitting 'apply' the theme background color would overwrite
the custom background.
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/Taskbar/main.cpp | 2 | ||||
-rw-r--r-- | Userland/Services/WindowServer/ConnectionFromClient.cpp | 4 | ||||
-rw-r--r-- | Userland/Services/WindowServer/ConnectionFromClient.h | 2 | ||||
-rw-r--r-- | Userland/Services/WindowServer/WindowManager.cpp | 5 | ||||
-rw-r--r-- | Userland/Services/WindowServer/WindowManager.h | 2 | ||||
-rw-r--r-- | Userland/Services/WindowServer/WindowServer.ipc | 2 |
6 files changed, 9 insertions, 8 deletions
diff --git a/Userland/Services/Taskbar/main.cpp b/Userland/Services/Taskbar/main.cpp index 5d3f66376a..4150145aa0 100644 --- a/Userland/Services/Taskbar/main.cpp +++ b/Userland/Services/Taskbar/main.cpp @@ -217,7 +217,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu() auto action = GUI::Action::create_checkable(theme.name, [theme_identifier](auto&) { auto& theme = g_themes[theme_identifier]; dbgln("Theme switched to {} at path {}", theme.name, theme.path); - auto success = GUI::ConnectionToWindowServer::the().set_system_theme(theme.path, theme.name); + auto success = GUI::ConnectionToWindowServer::the().set_system_theme(theme.path, theme.name, false); VERIFY(success); }); if (theme.name == current_theme_name) diff --git a/Userland/Services/WindowServer/ConnectionFromClient.cpp b/Userland/Services/WindowServer/ConnectionFromClient.cpp index aebd1f3e72..76f05ff10f 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.cpp +++ b/Userland/Services/WindowServer/ConnectionFromClient.cpp @@ -790,9 +790,9 @@ Messages::WindowServer::StartDragResponse ConnectionFromClient::start_drag(Strin return true; } -Messages::WindowServer::SetSystemThemeResponse ConnectionFromClient::set_system_theme(String const& theme_path, String const& theme_name) +Messages::WindowServer::SetSystemThemeResponse ConnectionFromClient::set_system_theme(String const& theme_path, String const& theme_name, bool keep_desktop_background) { - bool success = WindowManager::the().update_theme(theme_path, theme_name); + bool success = WindowManager::the().update_theme(theme_path, theme_name, keep_desktop_background); return success; } diff --git a/Userland/Services/WindowServer/ConnectionFromClient.h b/Userland/Services/WindowServer/ConnectionFromClient.h index 6b12169355..1a87563b9c 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.h +++ b/Userland/Services/WindowServer/ConnectionFromClient.h @@ -140,7 +140,7 @@ private: virtual void dismiss_menu(i32) override; virtual void set_window_icon_bitmap(i32, Gfx::ShareableBitmap const&) override; virtual Messages::WindowServer::StartDragResponse start_drag(String const&, HashMap<String, ByteBuffer> const&, Gfx::ShareableBitmap const&) override; - virtual Messages::WindowServer::SetSystemThemeResponse set_system_theme(String const&, String const&) override; + virtual Messages::WindowServer::SetSystemThemeResponse set_system_theme(String const&, String const&, bool keep_desktop_background) override; virtual Messages::WindowServer::GetSystemThemeResponse get_system_theme() override; virtual void apply_cursor_theme(String const&) override; virtual Messages::WindowServer::GetCursorThemeResponse get_cursor_theme() override; diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index bf57e84207..bdbbe2c1a5 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -2089,7 +2089,7 @@ void WindowManager::invalidate_after_theme_or_font_change() Compositor::the().invalidate_after_theme_or_font_change(); } -bool WindowManager::update_theme(String theme_path, String theme_name) +bool WindowManager::update_theme(String theme_path, String theme_name, bool keep_desktop_background) { auto new_theme = Gfx::load_system_theme(theme_path); if (!new_theme.is_valid()) @@ -2097,7 +2097,8 @@ bool WindowManager::update_theme(String theme_path, String theme_name) Gfx::set_system_theme(new_theme); m_palette = Gfx::PaletteImpl::create_with_anonymous_buffer(new_theme); m_config->write_entry("Theme", "Name", theme_name); - m_config->remove_entry("Background", "Color"); + if (!keep_desktop_background) + m_config->remove_entry("Background", "Color"); if (auto result = m_config->sync(); result.is_error()) { dbgln("Failed to save config file: {}", result.error()); return false; diff --git a/Userland/Services/WindowServer/WindowManager.h b/Userland/Services/WindowServer/WindowManager.h index 047d6f3866..115b718350 100644 --- a/Userland/Services/WindowServer/WindowManager.h +++ b/Userland/Services/WindowServer/WindowManager.h @@ -213,7 +213,7 @@ public: return nullptr; } - bool update_theme(String theme_path, String theme_name); + bool update_theme(String theme_path, String theme_name, bool keep_desktop_background); void invalidate_after_theme_or_font_change(); bool set_hovered_window(Window*); diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc index 53849dd3ba..91f69a4467 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -113,7 +113,7 @@ endpoint WindowServer start_drag([UTF8] String text, HashMap<String,ByteBuffer> mime_data, Gfx::ShareableBitmap drag_bitmap) => (bool started) - set_system_theme(String theme_path, [UTF8] String theme_name) => (bool success) + set_system_theme(String theme_path, [UTF8] String theme_name, bool keep_desktop_background) => (bool success) get_system_theme() => ([UTF8] String theme_name) refresh_system_theme() =| |