1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57:45 +00:00

LibGUI+WindowServer: Create IPC calls for passing SystemEffects

SystemEffects are sent to the WindowManager through
set_system_effects() and broadcast to Desktop clients with
update_system_effects(). WindowManager is reponsible for saving,
loading and rebroadcasting effects from WindowServer.ini on
config changes.
This commit is contained in:
thankyouverycool 2022-08-07 19:54:22 -04:00 committed by Andreas Kling
parent e2318dffe3
commit 841d06f676
8 changed files with 71 additions and 4 deletions

View file

@ -50,13 +50,14 @@ ConnectionToWindowServer::ConnectionToWindowServer(NonnullOwnPtr<Core::Stream::L
auto message = wait_for_specific_message<Messages::WindowClient::FastGreet>();
set_system_theme_from_anonymous_buffer(message->theme_buffer());
Desktop::the().did_receive_screen_rects({}, message->screen_rects(), message->main_screen_index(), message->workspace_rows(), message->workspace_columns());
Desktop::the().set_system_effects(message->effects());
Gfx::FontDatabase::set_default_font_query(message->default_font_query());
Gfx::FontDatabase::set_fixed_width_font_query(message->fixed_width_font_query());
Gfx::FontDatabase::set_window_title_font_query(message->window_title_font_query());
m_client_id = message->client_id();
}
void ConnectionToWindowServer::fast_greet(Vector<Gfx::IntRect> const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, String const&, i32)
void ConnectionToWindowServer::fast_greet(Vector<Gfx::IntRect> const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, String const&, Vector<bool> const&, i32)
{
// NOTE: This message is handled in the constructor.
}
@ -83,6 +84,11 @@ void ConnectionToWindowServer::update_system_fonts(String const& default_font_qu
});
}
void ConnectionToWindowServer::update_system_effects(Vector<bool> const& effects)
{
Desktop::the().set_system_effects(effects);
}
void ConnectionToWindowServer::paint(i32 window_id, Gfx::IntSize const& window_size, Vector<Gfx::IntRect> const& rects)
{
if (auto* window = Window::from_window_id(window_id))

View file

@ -24,7 +24,7 @@ public:
private:
ConnectionToWindowServer(NonnullOwnPtr<Core::Stream::LocalSocket>);
virtual void fast_greet(Vector<Gfx::IntRect> const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, String const&, i32) override;
virtual void fast_greet(Vector<Gfx::IntRect> const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, String const&, Vector<bool> const&, i32) override;
virtual void paint(i32, Gfx::IntSize const&, Vector<Gfx::IntRect> const&) override;
virtual void mouse_move(i32, Gfx::IntPoint const&, u32, u32, u32, i32, i32, i32, i32, bool, Vector<String> const&) override;
virtual void mouse_down(i32, Gfx::IntPoint const&, u32, u32, u32, i32, i32, i32, i32) override;
@ -52,6 +52,7 @@ private:
virtual void drag_cancelled() override;
virtual void update_system_theme(Core::AnonymousBuffer const&) override;
virtual void update_system_fonts(String const&, String const&, String const&) override;
virtual void update_system_effects(Vector<bool> const&) override;
virtual void window_state_changed(i32, bool, bool, bool) override;
virtual void display_link_notification() override;
virtual void track_mouse_move(Gfx::IntPoint const&) override;

View file

@ -53,7 +53,7 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::Stream::LocalSock
s_connections->set(client_id, *this);
auto& wm = WindowManager::the();
async_fast_greet(Screen::rects(), Screen::main().index(), wm.window_stack_rows(), wm.window_stack_columns(), Gfx::current_system_theme_buffer(), Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query(), client_id);
async_fast_greet(Screen::rects(), Screen::main().index(), wm.window_stack_rows(), wm.window_stack_columns(), Gfx::current_system_theme_buffer(), Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query(), wm.system_effects().effects(), client_id);
}
ConnectionFromClient::~ConnectionFromClient()
@ -922,6 +922,14 @@ Messages::WindowServer::SetSystemFontsResponse ConnectionFromClient::set_system_
return true;
}
void ConnectionFromClient::set_system_effects(Vector<bool> const& effects, u8 geometry)
{
WindowManager::the().apply_system_effects(effects, static_cast<ShowGeometry>(geometry));
ConnectionFromClient::for_each_client([&](auto& client) {
client.async_update_system_effects(effects);
});
}
void ConnectionFromClient::set_window_base_size_and_size_increment(i32 window_id, Gfx::IntSize const& base_size, Gfx::IntSize const& size_increment)
{
auto it = m_windows.find(window_id);

View file

@ -155,6 +155,7 @@ private:
virtual Messages::WindowServer::GetCursorHighlightColorResponse get_cursor_highlight_color() override;
virtual Messages::WindowServer::GetCursorThemeResponse get_cursor_theme() override;
virtual Messages::WindowServer::SetSystemFontsResponse set_system_fonts(String const&, String const&, String const&) override;
virtual void set_system_effects(Vector<bool> const&, u8) override;
virtual void set_window_base_size_and_size_increment(i32, Gfx::IntSize const&, Gfx::IntSize const&) override;
virtual void set_window_resize_aspect_ratio(i32, Optional<Gfx::IntSize> const&) override;
virtual void enable_display_link() override;

View file

@ -3,7 +3,7 @@
endpoint WindowClient
{
fast_greet(Vector<Gfx::IntRect> screen_rects, u32 main_screen_index, u32 workspace_rows, u32 workspace_columns, Core::AnonymousBuffer theme_buffer, String default_font_query, String fixed_width_font_query, String window_title_font_query, i32 client_id) =|
fast_greet(Vector<Gfx::IntRect> screen_rects, u32 main_screen_index, u32 workspace_rows, u32 workspace_columns, Core::AnonymousBuffer theme_buffer, String default_font_query, String fixed_width_font_query, String window_title_font_query, Vector<bool> effects, i32 client_id) =|
paint(i32 window_id, Gfx::IntSize window_size, Vector<Gfx::IntRect> rects) =|
mouse_move(i32 window_id, Gfx::IntPoint mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta_x, i32 wheel_delta_y, i32 wheel_raw_delta_x, i32 wheel_raw_delta_y, bool is_drag, Vector<String> mime_types) =|
@ -39,6 +39,7 @@ endpoint WindowClient
update_system_theme(Core::AnonymousBuffer theme_buffer) =|
update_system_fonts(String default_font_query, String fixed_width_font_query, String window_title_font_query) =|
update_system_effects(Vector<bool> effects) =|
display_link_notification() =|

View file

@ -101,6 +101,8 @@ void WindowManager::reload_config()
Compositor::the().invalidate_after_theme_or_font_change();
WindowFrame::reload_config();
load_system_effects();
}
Gfx::Font const& WindowManager::font() const
@ -2331,6 +2333,46 @@ void WindowManager::set_cursor_highlight_color(Gfx::Color const& color)
sync_config_to_disk();
}
void WindowManager::apply_system_effects(Vector<bool> effects, ShowGeometry geometry)
{
if (m_system_effects == SystemEffects { effects, geometry })
return;
m_system_effects = { effects, geometry };
m_config->write_bool_entry("Effects", "AnimateMenus", m_system_effects.animate_menus());
m_config->write_bool_entry("Effects", "FlashMenus", m_system_effects.flash_menus());
m_config->write_bool_entry("Effects", "AnimateWindows", m_system_effects.animate_windows());
m_config->write_bool_entry("Effects", "SmoothScrolling", m_system_effects.smooth_scrolling());
m_config->write_bool_entry("Effects", "TabAccents", m_system_effects.tab_accents());
m_config->write_bool_entry("Effects", "SplitterKnurls", m_system_effects.splitter_knurls());
m_config->write_bool_entry("Effects", "MenuShadow", m_system_effects.menu_shadow());
m_config->write_bool_entry("Effects", "WindowShadow", m_system_effects.window_shadow());
m_config->write_bool_entry("Effects", "TooltipShadow", m_system_effects.tooltip_shadow());
m_config->write_entry("Effects", "ShowGeometry", ShowGeometryTools::enum_to_string(geometry));
sync_config_to_disk();
}
void WindowManager::load_system_effects()
{
Vector<bool> effects = {
m_config->read_bool_entry("Effects", "AnimateMenus", true),
m_config->read_bool_entry("Effects", "FlashMenus", true),
m_config->read_bool_entry("Effects", "AnimateWindows", true),
m_config->read_bool_entry("Effects", "SmoothScrolling", true),
m_config->read_bool_entry("Effects", "TabAccents", true),
m_config->read_bool_entry("Effects", "SplitterKnurls", true),
m_config->read_bool_entry("Effects", "MenuShadow", true),
m_config->read_bool_entry("Effects", "WindowShadow", true),
m_config->read_bool_entry("Effects", "TooltipShadow", true)
};
ShowGeometry geometry = ShowGeometryTools::string_to_enum(m_config->read_entry("Effects", "ShowGeometry", "OnMoveAndResize"));
m_system_effects = { effects, geometry };
ConnectionFromClient::for_each_client([&](auto& client) {
client.async_update_system_effects(effects);
});
}
bool WindowManager::sync_config_to_disk()
{
if (auto result = m_config->sync(); result.is_error()) {

View file

@ -22,6 +22,7 @@
#include <WindowServer/KeymapSwitcher.h>
#include <WindowServer/MenuManager.h>
#include <WindowServer/ScreenLayout.h>
#include <WindowServer/SystemEffects.h>
#include <WindowServer/WMConnectionFromClient.h>
#include <WindowServer/WindowSwitcher.h>
#include <WindowServer/WindowType.h>
@ -336,6 +337,10 @@ public:
bool is_cursor_highlight_enabled() const { return m_cursor_highlight_radius > 0 && m_cursor_highlight_enabled; }
void load_system_effects();
void apply_system_effects(Vector<bool>, ShowGeometry);
SystemEffects& system_effects() { return m_system_effects; }
RefPtr<KeymapSwitcher> keymap_switcher() { return m_keymap_switcher; }
private:
@ -478,6 +483,8 @@ private:
WindowStack* m_switching_to_window_stack { nullptr };
Vector<WeakPtr<Window>, 4> m_carry_window_to_new_stack;
SystemEffects m_system_effects;
};
template<typename Callback>

View file

@ -144,6 +144,7 @@ endpoint WindowServer
get_cursor_highlight_color() => (Gfx::Color color)
set_system_fonts(String default_font_query, String fixed_width_font_query, String window_title_font_query) => (bool success)
set_system_effects(Vector<bool> effects, u8 geometry) =|
set_window_base_size_and_size_increment(i32 window_id, Gfx::IntSize base_size, Gfx::IntSize size_increment) =|
set_window_resize_aspect_ratio(i32 window_id, Optional<Gfx::IntSize> resize_aspect_ratio) =|