1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:57:44 +00:00

WindowServer+LibGUI: Pass the system theme using Core::AnonymousBuffer

This was the last remaining user of shbufs in WindowServer, and so
WindowServer no longer pledges "shared_buffer" :^)
This commit is contained in:
Andreas Kling 2021-01-16 17:20:53 +01:00
parent 9c6c18d9b6
commit 04f95f9160
13 changed files with 51 additions and 56 deletions

View file

@ -713,7 +713,7 @@ void ClientConnection::handle(const Messages::WindowServer::WM_SetWindowMinimize
OwnPtr<Messages::WindowServer::GreetResponse> ClientConnection::handle(const Messages::WindowServer::Greet&)
{
return make<Messages::WindowServer::GreetResponse>(client_id(), Screen::the().rect(), Gfx::current_system_theme_buffer_id());
return make<Messages::WindowServer::GreetResponse>(client_id(), Screen::the().rect(), Gfx::current_system_theme_buffer());
}
void ClientConnection::handle(const Messages::WindowServer::WM_SetWindowTaskbarRect& message)
@ -836,7 +836,7 @@ void ClientConnection::handle(const Messages::WindowServer::SetWindowProgress& m
void ClientConnection::handle(const Messages::WindowServer::RefreshSystemTheme&)
{
// Post the client an UpdateSystemTheme message to refresh its theme.
post_message(Messages::WindowClient::UpdateSystemTheme(Gfx::current_system_theme_buffer_id()));
post_message(Messages::WindowClient::UpdateSystemTheme(Gfx::current_system_theme_buffer()));
}
void ClientConnection::handle(const Messages::WindowServer::Pong&)

View file

@ -34,7 +34,7 @@ endpoint WindowClient = 4
DragDropped(i32 window_id, Gfx::IntPoint mouse_position, [UTF8] String text, HashMap<String,ByteBuffer> mime_data) =|
UpdateSystemTheme(i32 system_theme_buffer_id) =|
UpdateSystemTheme(Core::AnonymousBuffer theme_buffer) =|
DisplayLinkNotification() =|

View file

@ -1404,17 +1404,16 @@ Gfx::IntRect WindowManager::dnd_rect() const
bool WindowManager::update_theme(String theme_path, String theme_name)
{
auto new_theme = Gfx::load_system_theme(theme_path);
if (!new_theme)
if (!new_theme.is_valid())
return false;
ASSERT(new_theme);
Gfx::set_system_theme(*new_theme);
m_palette = Gfx::PaletteImpl::create_with_shared_buffer(*new_theme);
Gfx::set_system_theme(new_theme);
m_palette = Gfx::PaletteImpl::create_with_anonymous_buffer(new_theme);
Compositor::the().set_background_color(palette().desktop_background().to_string());
HashTable<ClientConnection*> notified_clients;
for_each_window([&](Window& window) {
if (window.client()) {
if (!notified_clients.contains(window.client())) {
window.client()->post_message(Messages::WindowClient::UpdateSystemTheme(Gfx::current_system_theme_buffer_id()));
window.client()->post_message(Messages::WindowClient::UpdateSystemTheme(Gfx::current_system_theme_buffer()));
notified_clients.set(window.client());
}
}

View file

@ -1,6 +1,6 @@
endpoint WindowServer = 2
{
Greet() => (i32 client_id, Gfx::IntRect screen_rect, i32 system_theme_buffer_id)
Greet() => (i32 client_id, Gfx::IntRect screen_rect, Core::AnonymousBuffer theme_buffer)
CreateMenubar() => (i32 menubar_id)
DestroyMenubar(i32 menubar_id) => ()

View file

@ -39,7 +39,7 @@
int main(int, char**)
{
if (pledge("stdio video thread sendfd recvfd shared_buffer accept rpath wpath cpath unix proc fattr sigaction", nullptr) < 0) {
if (pledge("stdio video thread sendfd recvfd accept rpath wpath cpath unix proc fattr sigaction", nullptr) < 0) {
perror("pledge");
return 1;
}
@ -78,13 +78,13 @@ int main(int, char**)
auto theme_name = wm_config->read_entry("Theme", "Name", "Default");
auto theme = Gfx::load_system_theme(String::formatted("/res/themes/{}.ini", theme_name));
ASSERT(theme);
Gfx::set_system_theme(*theme);
auto palette = Gfx::PaletteImpl::create_with_shared_buffer(*theme);
ASSERT(theme.is_valid());
Gfx::set_system_theme(theme);
auto palette = Gfx::PaletteImpl::create_with_anonymous_buffer(theme);
WindowServer::EventLoop loop;
if (pledge("stdio video thread sendfd recvfd shared_buffer accept rpath wpath cpath proc", nullptr) < 0) {
if (pledge("stdio video thread sendfd recvfd accept rpath wpath cpath proc", nullptr) < 0) {
perror("pledge");
return 1;
}