diff --git a/Base/etc/WindowServer.ini b/Base/etc/WindowServer.ini index 5f721b86c3..53aaaea6aa 100644 --- a/Base/etc/WindowServer.ini +++ b/Base/etc/WindowServer.ini @@ -12,6 +12,7 @@ ScaleFactor=1 [Fonts] Default=Katica 10 400 0 +WindowTitle=Katica 10 700 0 FixedWidth=Csilla 10 400 0 [Theme] diff --git a/Userland/Applications/DisplaySettings/FontSettings.gml b/Userland/Applications/DisplaySettings/FontSettings.gml index 9470bb6a9e..dfcf434397 100644 --- a/Userland/Applications/DisplaySettings/FontSettings.gml +++ b/Userland/Applications/DisplaySettings/FontSettings.gml @@ -33,6 +33,34 @@ } } + @GUI::Widget { + preferred_height: "fit" + layout: @GUI::HorizontalBoxLayout { + spacing: 6 + } + + @GUI::Label { + fixed_width: 100 + text: "Window title font:" + text_alignment: "CenterLeft" + } + + @GUI::Label { + background_role: "Base" + shadow: "Sunken" + shape: "Container" + thickness: 2 + fill_with_background_color: true + name: "window_title_font_label" + } + + @GUI::Button { + text: "..." + name: "window_title_font_button" + fixed_width: 30 + } + } + @GUI::Widget { preferred_height: "fit" layout: @GUI::HorizontalBoxLayout { diff --git a/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp b/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp index 7a683a4dce..5a55f48c65 100644 --- a/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp @@ -34,6 +34,19 @@ FontSettingsWidget::FontSettingsWidget() } }; + auto& window_title_font = Gfx::FontDatabase::window_title_font(); + m_window_title_font_label = *find_descendant_of_type_named("window_title_font_label"); + update_label_with_font(*m_window_title_font_label, window_title_font); + + auto& window_title_font_button = *find_descendant_of_type_named("window_title_font_button"); + window_title_font_button.on_click = [this](auto) { + auto font_picker = GUI::FontPicker::construct(window(), &m_window_title_font_label->font(), false); + if (font_picker->exec() == GUI::Dialog::ExecResult::OK) { + update_label_with_font(*m_window_title_font_label, *font_picker->font()); + set_modified(true); + } + }; + auto& default_fixed_width_font = Gfx::FontDatabase::default_fixed_width_font(); m_fixed_width_font_label = *find_descendant_of_type_named("fixed_width_font_label"); update_label_with_font(*m_fixed_width_font_label, default_fixed_width_font); @@ -56,7 +69,10 @@ static void update_label_with_font(GUI::Label& label, Gfx::Font const& font) void FontSettingsWidget::apply_settings() { - GUI::ConnectionToWindowServer::the().set_system_fonts(m_default_font_label->font().qualified_name(), m_fixed_width_font_label->font().qualified_name()); + GUI::ConnectionToWindowServer::the().set_system_fonts( + m_default_font_label->font().qualified_name(), + m_fixed_width_font_label->font().qualified_name(), + m_window_title_font_label->font().qualified_name()); } } diff --git a/Userland/Applications/DisplaySettings/FontSettingsWidget.h b/Userland/Applications/DisplaySettings/FontSettingsWidget.h index 490b6e00b9..7c3fe08ed9 100644 --- a/Userland/Applications/DisplaySettings/FontSettingsWidget.h +++ b/Userland/Applications/DisplaySettings/FontSettingsWidget.h @@ -24,6 +24,7 @@ private: FontSettingsWidget(); RefPtr m_default_font_label; + RefPtr m_window_title_font_label; RefPtr m_fixed_width_font_label; }; diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp index 11637bf2a1..60e90e154f 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp +++ b/Userland/Libraries/LibGUI/ConnectionToWindowServer.cpp @@ -52,10 +52,11 @@ ConnectionToWindowServer::ConnectionToWindowServer(NonnullOwnPtrscreen_rects(), message->main_screen_index(), message->workspace_rows(), message->workspace_columns()); 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 const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, i32) +void ConnectionToWindowServer::fast_greet(Vector const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, String const&, i32) { // NOTE: This message is handled in the constructor. } @@ -71,10 +72,11 @@ void ConnectionToWindowServer::update_system_theme(Core::AnonymousBuffer const& Application::the()->dispatch_event(*make()); } -void ConnectionToWindowServer::update_system_fonts(String const& default_font_query, String const& fixed_width_font_query) +void ConnectionToWindowServer::update_system_fonts(String const& default_font_query, String const& fixed_width_font_query, String const& window_title_font_query) { 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); Window::update_all_windows({}); Window::for_each_window({}, [](auto& window) { Core::EventLoop::current().post_event(window, make()); diff --git a/Userland/Libraries/LibGUI/ConnectionToWindowServer.h b/Userland/Libraries/LibGUI/ConnectionToWindowServer.h index e1eb0f5fbd..9bb4336f2b 100644 --- a/Userland/Libraries/LibGUI/ConnectionToWindowServer.h +++ b/Userland/Libraries/LibGUI/ConnectionToWindowServer.h @@ -24,7 +24,7 @@ public: private: ConnectionToWindowServer(NonnullOwnPtr); - virtual void fast_greet(Vector const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, i32) override; + virtual void fast_greet(Vector const&, u32, u32, u32, Core::AnonymousBuffer const&, String const&, String const&, String const&, i32) override; virtual void paint(i32, Gfx::IntSize const&, Vector const&) override; virtual void mouse_move(i32, Gfx::IntPoint const&, u32, u32, u32, i32, i32, i32, i32, bool, Vector const&) override; virtual void mouse_down(i32, Gfx::IntPoint const&, u32, u32, u32, i32, i32, i32, i32) override; @@ -52,7 +52,7 @@ private: virtual void drag_accepted() override; virtual void drag_cancelled() override; virtual void update_system_theme(Core::AnonymousBuffer const&) override; - virtual void update_system_fonts(String const&, String const&) override; + virtual void update_system_fonts(String const&, String const&, String 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; diff --git a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp index 185fbfd74a..62388448c1 100644 --- a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp +++ b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp @@ -51,7 +51,7 @@ void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window frame_rect.set_location({ 0, 0 }); Gfx::StylePainter::paint_window_frame(painter, frame_rect, palette); - auto& title_font = FontDatabase::default_font().bold_variant(); + auto& title_font = FontDatabase::window_title_font(); auto titlebar_rect = this->titlebar_rect(WindowType::Normal, window_rect, palette); auto titlebar_icon_rect = this->titlebar_icon_rect(WindowType::Normal, window_rect, palette); @@ -118,7 +118,7 @@ void ClassicWindowTheme::paint_tool_window_frame(Painter& painter, WindowState w frame_rect.set_location({ 0, 0 }); Gfx::StylePainter::paint_window_frame(painter, frame_rect, palette); - auto& title_font = FontDatabase::default_font().bold_variant(); + auto& title_font = FontDatabase::window_title_font(); auto titlebar_rect = this->titlebar_rect(WindowType::ToolWindow, window_rect, palette); auto titlebar_inner_rect = titlebar_text_rect(WindowType::ToolWindow, window_rect, palette); @@ -152,7 +152,7 @@ IntRect ClassicWindowTheme::menubar_rect(WindowType window_type, IntRect const& IntRect ClassicWindowTheme::titlebar_rect(WindowType window_type, IntRect const& window_rect, Palette const& palette) const { - auto& title_font = FontDatabase::default_font().bold_variant(); + auto& title_font = FontDatabase::window_title_font(); auto window_titlebar_height = titlebar_height(window_type, palette); // FIXME: The top of the titlebar doesn't get redrawn properly if this padding is different int total_vertical_padding = title_font.glyph_height() - 1; @@ -254,7 +254,7 @@ Vector ClassicWindowTheme::layout_buttons(WindowType window_type, IntRe int ClassicWindowTheme::titlebar_height(WindowType window_type, Palette const& palette) const { - auto& title_font = FontDatabase::default_font().bold_variant(); + auto& title_font = FontDatabase::window_title_font(); switch (window_type) { case WindowType::Normal: case WindowType::Notification: diff --git a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp index a55837e9be..99fcc48616 100644 --- a/Userland/Libraries/LibGfx/Font/FontDatabase.cpp +++ b/Userland/Libraries/LibGfx/Font/FontDatabase.cpp @@ -25,8 +25,13 @@ FontDatabase& FontDatabase::the() static RefPtr s_default_font; static String s_default_font_query; + +static RefPtr s_window_title_font; +static String s_window_title_font_query; + static RefPtr s_fixed_width_font; static String s_fixed_width_font_query; + static String s_default_fonts_lookup_path = "/res/fonts"; void FontDatabase::set_default_font_query(String query) @@ -42,6 +47,19 @@ String FontDatabase::default_font_query() return s_default_font_query; } +void FontDatabase::set_window_title_font_query(String query) +{ + if (s_window_title_font_query == query) + return; + s_window_title_font_query = move(query); + s_window_title_font = nullptr; +} + +String FontDatabase::window_title_font_query() +{ + return s_window_title_font_query; +} + void FontDatabase::set_default_fonts_lookup_path(String path) { if (s_default_fonts_lookup_path == path) @@ -64,6 +82,16 @@ Font& FontDatabase::default_font() return *s_default_font; } +Font& FontDatabase::window_title_font() +{ + if (!s_window_title_font) { + VERIFY(!s_window_title_font_query.is_empty()); + s_window_title_font = FontDatabase::the().get_by_name(s_window_title_font_query); + VERIFY(s_window_title_font); + } + return *s_window_title_font; +} + void FontDatabase::set_fixed_width_font_query(String query) { if (s_fixed_width_font_query == query) diff --git a/Userland/Libraries/LibGfx/Font/FontDatabase.h b/Userland/Libraries/LibGfx/Font/FontDatabase.h index 46a068789d..d75432b517 100644 --- a/Userland/Libraries/LibGfx/Font/FontDatabase.h +++ b/Userland/Libraries/LibGfx/Font/FontDatabase.h @@ -36,11 +36,15 @@ public: static Font& default_font(); static Font& default_fixed_width_font(); + static Font& window_title_font(); static String default_font_query(); + static String window_title_font_query(); static String fixed_width_font_query(); + static String default_fonts_lookup_path(); static void set_default_font_query(String); + static void set_window_title_font_query(String); static void set_fixed_width_font_query(String); static void set_default_fonts_lookup_path(String); diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index ac56242659..88bb329817 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -69,7 +69,7 @@ void OutOfProcessWebView::create_client() }; client().async_update_system_theme(Gfx::current_system_theme_buffer()); - client().async_update_system_fonts(Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query()); + client().async_update_system_fonts(Gfx::FontDatabase::default_font_query(), Gfx::FontDatabase::fixed_width_font_query(), Gfx::FontDatabase::window_title_font_query()); client().async_update_screen_rects(GUI::Desktop::the().rects(), GUI::Desktop::the().main_screen_index()); } diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index 47830e7408..f5148e7c4d 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -65,10 +65,11 @@ void ConnectionFromClient::update_system_theme(Core::AnonymousBuffer const& them m_page_host->set_palette_impl(*impl); } -void ConnectionFromClient::update_system_fonts(String const& default_font_query, String const& fixed_width_font_query) +void ConnectionFromClient::update_system_fonts(String const& default_font_query, String const& fixed_width_font_query, String const& window_title_font_query) { 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); } void ConnectionFromClient::update_screen_rects(Vector const& rects, u32 main_screen) diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h index 8071e5d3fe..ffb00dbfab 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.h +++ b/Userland/Services/WebContent/ConnectionFromClient.h @@ -41,7 +41,7 @@ private: Web::Page const& page() const; virtual void update_system_theme(Core::AnonymousBuffer const&) override; - virtual void update_system_fonts(String const&, String const&) override; + virtual void update_system_fonts(String const&, String const&, String const&) override; virtual void update_screen_rects(Vector const&, u32) override; virtual void load_url(URL const&) override; virtual void load_html(String const&, URL const&) override; diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index b8b01749f3..8b7bb8a3b0 100644 --- a/Userland/Services/WebContent/WebContentServer.ipc +++ b/Userland/Services/WebContent/WebContentServer.ipc @@ -8,7 +8,7 @@ endpoint WebContentServer { 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) =| update_screen_rects(Vector rects, u32 main_screen_index) =| load_url(URL url) =| diff --git a/Userland/Services/WindowServer/ConnectionFromClient.cpp b/Userland/Services/WindowServer/ConnectionFromClient.cpp index e4f4353574..0cbad6b1ef 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.cpp +++ b/Userland/Services/WindowServer/ConnectionFromClient.cpp @@ -53,7 +53,7 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtrset(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; } diff --git a/Userland/Services/WindowServer/ConnectionFromClient.h b/Userland/Services/WindowServer/ConnectionFromClient.h index 0b8e4bf1fb..0ab98d2ac5 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.h +++ b/Userland/Services/WindowServer/ConnectionFromClient.h @@ -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 const&) override; virtual void enable_display_link() override; diff --git a/Userland/Services/WindowServer/WindowClient.ipc b/Userland/Services/WindowServer/WindowClient.ipc index 0c67af3830..9c45c137d3 100644 --- a/Userland/Services/WindowServer/WindowClient.ipc +++ b/Userland/Services/WindowServer/WindowClient.ipc @@ -3,7 +3,7 @@ endpoint WindowClient { - fast_greet(Vector 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 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 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 mime_types) =| @@ -40,7 +40,7 @@ endpoint WindowClient drag_dropped(i32 window_id, Gfx::IntPoint mouse_position, [UTF8] String text, HashMap 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() =| diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 1c66c95a01..8d49fd62b9 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -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) diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc index 691414ab0b..e9b15277b9 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -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 resize_aspect_ratio) =| diff --git a/Userland/Services/WindowServer/main.cpp b/Userland/Services/WindowServer/main.cpp index 8dfa5640e1..28a7470916 100644 --- a/Userland/Services/WindowServer/main.cpp +++ b/Userland/Services/WindowServer/main.cpp @@ -47,9 +47,11 @@ ErrorOr 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. diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index a5811622b5..62f5932c88 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -689,6 +689,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } Gfx::FontDatabase::set_default_font_query("Katica 10 400 0"); + Gfx::FontDatabase::set_window_title_font_query("Katica 10 700 0"); Gfx::FontDatabase::set_fixed_width_font_query("Csilla 10 400 0"); if (!error_page_url.is_empty())