summaryrefslogtreecommitdiff
path: root/Servers/WindowServer/main.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-23 20:24:26 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-23 20:33:01 +0100
commit411058b2a3c5a1058ac5c2e54ec53dba12e198e4 (patch)
tree6288fb17845f38fd966332b9fd47182e6b75a356 /Servers/WindowServer/main.cpp
parent7c8bbea995d9e2a5580c66cca7e8a56f65329fc2 (diff)
downloadserenity-411058b2a3c5a1058ac5c2e54ec53dba12e198e4.zip
WindowServer+LibGUI: Implement basic color theming
Color themes are loaded from .ini files in /res/themes/ The theme can be switched from the "Themes" section in the system menu. The basic mechanism is that WindowServer broadcasts a SharedBuffer with all of the color values of the current theme. Clients receive this with the response to their initial WindowServer::Greet handshake. When the theme is changed, WindowServer tells everyone by sending out an UpdateSystemTheme message with a new SharedBuffer to use. This does feel somewhat bloated somehow, but I'm sure we can iterate on it over time and improve things. To get one of the theme colors, use the Color(SystemColor) constructor: painter.fill_rect(rect, SystemColor::HoverHighlight); Some things don't work 100% right without a reboot. Specifically, when constructing a GWidget, it will set its own background and foreground colors based on the current SystemColor::Window and SystemColor::Text. The widget is then stuck with these values, and they don't update on system theme change, only on app restart. All in all though, this is pretty cool. Merry Christmas! :^)
Diffstat (limited to 'Servers/WindowServer/main.cpp')
-rw-r--r--Servers/WindowServer/main.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/Servers/WindowServer/main.cpp b/Servers/WindowServer/main.cpp
index 542998a3d0..c629f9464d 100644
--- a/Servers/WindowServer/main.cpp
+++ b/Servers/WindowServer/main.cpp
@@ -1,4 +1,5 @@
#include <LibCore/CConfigFile.h>
+#include <LibDraw/SystemTheme.h>
#include <WindowServer/WSCompositor.h>
#include <WindowServer/WSEventLoop.h>
#include <WindowServer/WSScreen.h>
@@ -18,9 +19,15 @@ int main(int, char**)
return 1;
}
+ auto wm_config = CConfigFile::get_for_app("WindowManager");
+ auto theme_name = wm_config->read_entry("Theme", "Name", "Default");
+
+ auto theme = load_system_theme(String::format("/res/themes/%s.ini", theme_name.characters()));
+ ASSERT(theme);
+ set_system_theme(*theme);
+
WSEventLoop loop;
- auto wm_config = CConfigFile::get_for_app("WindowManager");
WSScreen screen(wm_config->read_num_entry("Screen", "Width", 1024),
wm_config->read_num_entry("Screen", "Height", 768));
WSCompositor::the();