1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:57:46 +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

@ -189,10 +189,10 @@ void Application::did_delete_last_window(Badge<Window>)
m_event_loop->quit(0);
}
void Application::set_system_palette(SharedBuffer& buffer)
void Application::set_system_palette(Core::AnonymousBuffer& buffer)
{
if (!m_system_palette)
m_system_palette = Gfx::PaletteImpl::create_with_shared_buffer(buffer);
m_system_palette = Gfx::PaletteImpl::create_with_anonymous_buffer(buffer);
else
m_system_palette->replace_internal_buffer({}, buffer);

View file

@ -71,7 +71,7 @@ public:
Gfx::Palette palette() const;
void set_palette(const Gfx::Palette&);
void set_system_palette(SharedBuffer&);
void set_system_palette(Core::AnonymousBuffer&);
bool focus_debugging_enabled() const { return m_focus_debugging_enabled; }
bool dnd_debugging_enabled() const { return m_dnd_debugging_enabled; }

View file

@ -56,25 +56,23 @@ WindowServerConnection& WindowServerConnection::the()
return *s_connection;
}
static void set_system_theme_from_shbuf_id(int id)
static void set_system_theme_from_anonymous_buffer(Core::AnonymousBuffer buffer)
{
auto system_theme = SharedBuffer::create_from_shbuf_id(id);
ASSERT(system_theme);
Gfx::set_system_theme(*system_theme);
Application::the()->set_system_palette(*system_theme);
Gfx::set_system_theme(buffer);
Application::the()->set_system_palette(buffer);
}
void WindowServerConnection::handshake()
{
auto response = send_sync<Messages::WindowServer::Greet>();
set_my_client_id(response->client_id());
set_system_theme_from_shbuf_id(response->system_theme_buffer_id());
set_system_theme_from_anonymous_buffer(response->theme_buffer());
Desktop::the().did_receive_screen_rect({}, response->screen_rect());
}
void WindowServerConnection::handle(const Messages::WindowClient::UpdateSystemTheme& message)
{
set_system_theme_from_shbuf_id(message.system_theme_buffer_id());
set_system_theme_from_anonymous_buffer(message.theme_buffer());
Window::update_all_windows({});
Window::for_each_window({}, [](auto& window) {
Core::EventLoop::current().post_event(window, make<ThemeChangeEvent>());