Преглед изворни кода

WindowServer+SystemMenu: Check the current system theme on startup

Andreas Kling пре 5 година
родитељ
комит
0fa7cf70b5

+ 4 - 0
Applications/SystemMenu/main.cpp

@@ -185,6 +185,8 @@ NonnullRefPtr<GUI::Menu> 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<Messages::WindowServer::GetSystemTheme>()->theme_name();
+
     {
         int theme_identifier = 0;
         for (auto& theme : g_themes) {
@@ -194,6 +196,8 @@ NonnullRefPtr<GUI::Menu> build_system_menu()
                 auto response = GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::SetSystemTheme>(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;

+ 7 - 0
Servers/WindowServer/ClientConnection.cpp

@@ -730,6 +730,13 @@ OwnPtr<Messages::WindowServer::SetSystemThemeResponse> ClientConnection::handle(
     return make<Messages::WindowServer::SetSystemThemeResponse>(success);
 }
 
+OwnPtr<Messages::WindowServer::GetSystemThemeResponse> 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<Messages::WindowServer::GetSystemThemeResponse>(name);
+}
+
 void ClientConnection::boost()
 {
     // FIXME: Re-enable this when we have a solution for boosting.

+ 1 - 0
Servers/WindowServer/ClientConnection.h

@@ -122,6 +122,7 @@ private:
     virtual OwnPtr<Messages::WindowServer::StartDragResponse> handle(const Messages::WindowServer::StartDrag&) override;
     virtual OwnPtr<Messages::WindowServer::SetSystemMenuResponse> handle(const Messages::WindowServer::SetSystemMenu&) override;
     virtual OwnPtr<Messages::WindowServer::SetSystemThemeResponse> handle(const Messages::WindowServer::SetSystemTheme&) override;
+    virtual OwnPtr<Messages::WindowServer::GetSystemThemeResponse> handle(const Messages::WindowServer::GetSystemTheme&) override;
     virtual OwnPtr<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrementResponse> handle(const Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement&) override;
     virtual void handle(const Messages::WindowServer::EnableDisplayLink&) override;
     virtual void handle(const Messages::WindowServer::DisableDisplayLink&) override;

+ 1 - 0
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) => ()