From 0fa7cf70b5606dc4a4335a8e406340a28a645c07 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 21 Apr 2020 18:40:27 +0200 Subject: [PATCH] WindowServer+SystemMenu: Check the current system theme on startup --- Applications/SystemMenu/main.cpp | 4 ++++ Servers/WindowServer/ClientConnection.cpp | 7 +++++++ Servers/WindowServer/ClientConnection.h | 1 + Servers/WindowServer/WindowServer.ipc | 1 + 4 files changed, 13 insertions(+) diff --git a/Applications/SystemMenu/main.cpp b/Applications/SystemMenu/main.cpp index 98ff7a0565..4398acb82d 100644 --- a/Applications/SystemMenu/main.cpp +++ b/Applications/SystemMenu/main.cpp @@ -185,6 +185,8 @@ NonnullRefPtr build_system_menu() quick_sort(g_themes, [](auto& a, auto& b) { return a.name < b.name; }); } + auto current_theme_name = GUI::WindowServerConnection::the().send_sync()->theme_name(); + { int theme_identifier = 0; for (auto& theme : g_themes) { @@ -194,6 +196,8 @@ NonnullRefPtr build_system_menu() auto response = GUI::WindowServerConnection::the().send_sync(theme.path, theme.name); ASSERT(response->success()); }); + if (theme.name == current_theme_name) + action->set_checked(true); g_themes_group.add_action(action); g_themes_menu->add_action(action); ++theme_identifier; diff --git a/Servers/WindowServer/ClientConnection.cpp b/Servers/WindowServer/ClientConnection.cpp index 9f28a77a87..8a4d61bf41 100644 --- a/Servers/WindowServer/ClientConnection.cpp +++ b/Servers/WindowServer/ClientConnection.cpp @@ -730,6 +730,13 @@ OwnPtr ClientConnection::handle( return make(success); } +OwnPtr ClientConnection::handle(const Messages::WindowServer::GetSystemTheme&) +{ + auto wm_config = Core::ConfigFile::open("/etc/WindowServer/WindowServer.ini"); + auto name = wm_config->read_entry("Theme", "Name"); + return make(name); +} + void ClientConnection::boost() { // FIXME: Re-enable this when we have a solution for boosting. diff --git a/Servers/WindowServer/ClientConnection.h b/Servers/WindowServer/ClientConnection.h index 3a8766c6c5..ebbcb3d282 100644 --- a/Servers/WindowServer/ClientConnection.h +++ b/Servers/WindowServer/ClientConnection.h @@ -122,6 +122,7 @@ private: virtual OwnPtr handle(const Messages::WindowServer::StartDrag&) override; virtual OwnPtr handle(const Messages::WindowServer::SetSystemMenu&) override; virtual OwnPtr handle(const Messages::WindowServer::SetSystemTheme&) override; + virtual OwnPtr handle(const Messages::WindowServer::GetSystemTheme&) override; virtual OwnPtr handle(const Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement&) override; virtual void handle(const Messages::WindowServer::EnableDisplayLink&) override; virtual void handle(const Messages::WindowServer::DisableDisplayLink&) override; diff --git a/Servers/WindowServer/WindowServer.ipc b/Servers/WindowServer/WindowServer.ipc index 82348778eb..ab73161f90 100644 --- a/Servers/WindowServer/WindowServer.ipc +++ b/Servers/WindowServer/WindowServer.ipc @@ -87,6 +87,7 @@ endpoint WindowServer = 2 StartDrag(String text, String data_type, String data, i32 bitmap_id, Gfx::Size bitmap_size) => (bool started) SetSystemTheme(String theme_path, String theme_name) => (bool success) + GetSystemTheme() => (String theme_name) SetWindowBaseSizeAndSizeIncrement(i32 window_id, Gfx::Size base_size, Gfx::Size size_increment) => ()