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

Userland+Base: Make the window titlebar font configurable separately

Instead of defaulting to "bold variant of the system default font",
let's allow the user to set any font they want as the titlebar font.
This commit is contained in:
Andreas Kling 2022-07-31 18:41:07 +02:00
parent 419e986dcc
commit 548081ea23
20 changed files with 107 additions and 21 deletions

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(), 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(), client_id);
}
ConnectionFromClient::~ConnectionFromClient()
@ -891,7 +891,7 @@ Messages::WindowServer::GetCursorThemeResponse ConnectionFromClient::get_cursor_
return name;
}
Messages::WindowServer::SetSystemFontsResponse ConnectionFromClient::set_system_fonts(String const& default_font_query, String const& fixed_width_font_query)
Messages::WindowServer::SetSystemFontsResponse ConnectionFromClient::set_system_fonts(String const& default_font_query, String const& fixed_width_font_query, String const& window_title_font_query)
{
if (!Gfx::FontDatabase::the().get_by_name(default_font_query)
|| !Gfx::FontDatabase::the().get_by_name(fixed_width_font_query)) {
@ -903,9 +903,10 @@ Messages::WindowServer::SetSystemFontsResponse ConnectionFromClient::set_system_
Gfx::FontDatabase::set_default_font_query(default_font_query);
Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query);
Gfx::FontDatabase::set_window_title_font_query(window_title_font_query);
ConnectionFromClient::for_each_client([&](auto& client) {
client.async_update_system_fonts(default_font_query, fixed_width_font_query);
client.async_update_system_fonts(default_font_query, fixed_width_font_query, window_title_font_query);
});
WindowManager::the().invalidate_after_theme_or_font_change();
@ -918,6 +919,7 @@ Messages::WindowServer::SetSystemFontsResponse ConnectionFromClient::set_system_
auto wm_config = wm_config_or_error.release_value();
wm_config->write_entry("Fonts", "Default", default_font_query);
wm_config->write_entry("Fonts", "FixedWidth", fixed_width_font_query);
wm_config->write_entry("Fonts", "WindowTitle", window_title_font_query);
return true;
}

View file

@ -154,7 +154,7 @@ private:
virtual void set_cursor_highlight_color(Gfx::Color const& color) override;
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&) override;
virtual Messages::WindowServer::SetSystemFontsResponse set_system_fonts(String const&, String const&, String const&) 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, 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, 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) =|
@ -40,7 +40,7 @@ endpoint WindowClient
drag_dropped(i32 window_id, Gfx::IntPoint mouse_position, [UTF8] String text, HashMap<String,ByteBuffer> mime_data) =|
update_system_theme(Core::AnonymousBuffer theme_buffer) =|
update_system_fonts(String default_font_query, String fixed_width_font_query) =|
update_system_fonts(String default_font_query, String fixed_width_font_query, String window_title_font_query) =|
display_link_notification() =|

View file

@ -110,7 +110,7 @@ Gfx::Font const& WindowManager::font() const
Gfx::Font const& WindowManager::window_title_font() const
{
return Gfx::FontDatabase::default_font().bold_variant();
return Gfx::FontDatabase::window_title_font();
}
bool WindowManager::set_screen_layout(ScreenLayout&& screen_layout, bool save, String& error_msg)

View file

@ -143,7 +143,7 @@ endpoint WindowServer
set_cursor_highlight_color(Gfx::Color color) =|
get_cursor_highlight_color() => (Gfx::Color color)
set_system_fonts(String default_font_query, String fixed_width_font_query) => (bool success)
set_system_fonts(String default_font_query, String fixed_width_font_query, String window_title_font_query) => (bool success)
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) =|

View file

@ -47,9 +47,11 @@ ErrorOr<int> serenity_main(Main::Arguments)
auto default_font_query = wm_config->read_entry("Fonts", "Default", "Katica 10 400 0");
auto fixed_width_font_query = wm_config->read_entry("Fonts", "FixedWidth", "Csilla 10 400 0");
auto window_title_font_query = wm_config->read_entry("Fonts", "WindowTitle", "Katica 10 700 0");
Gfx::FontDatabase::set_default_font_query(default_font_query);
Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query);
Gfx::FontDatabase::set_window_title_font_query(window_title_font_query);
{
// FIXME: Map switched tty from screens.