diff --git a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp index 9c3ea5e7ba..e8aa426847 100644 --- a/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp +++ b/Userland/Libraries/LibGfx/ClassicWindowTheme.cpp @@ -52,11 +52,8 @@ Gfx::IntRect ClassicWindowTheme::titlebar_text_rect(WindowType window_type, cons }; } -void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window_state, const IntRect& window_rect, const StringView& window_title, const Bitmap& icon, const Palette& palette, const IntRect& leftmost_button_rect, int menu_row_count, bool window_modified) const +void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window_state, const IntRect& window_rect, const StringView& window_title, const Bitmap& icon, const Palette& palette, const IntRect& leftmost_button_rect, int menu_row_count, [[maybe_unused]] bool window_modified) const { - String final_title = window_title; - final_title.replace("[*]", window_modified ? " (*)" : ""); - auto frame_rect = frame_rect_for_window(WindowType::Normal, window_rect, palette, menu_row_count); frame_rect.set_location({ 0, 0 }); Gfx::StylePainter::paint_window_frame(painter, frame_rect, palette); @@ -67,7 +64,7 @@ void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window auto titlebar_icon_rect = this->titlebar_icon_rect(WindowType::Normal, window_rect, palette); auto titlebar_inner_rect = titlebar_text_rect(WindowType::Normal, window_rect, palette); auto titlebar_title_rect = titlebar_inner_rect; - titlebar_title_rect.set_width(FontDatabase::default_bold_font().width(final_title)); + titlebar_title_rect.set_width(FontDatabase::default_bold_font().width(window_title)); auto [title_color, border_color, border_color2, stripes_color, shadow_color] = compute_frame_colors(window_state, palette); @@ -89,9 +86,9 @@ void ClassicWindowTheme::paint_normal_frame(Painter& painter, WindowState window auto clipped_title_rect = titlebar_title_rect; clipped_title_rect.set_width(stripe_right - clipped_title_rect.x()); if (!clipped_title_rect.is_empty()) { - painter.draw_text(clipped_title_rect.translated(1, 2), final_title, title_font, Gfx::TextAlignment::CenterLeft, shadow_color, Gfx::TextElision::Right); + painter.draw_text(clipped_title_rect.translated(1, 2), window_title, title_font, Gfx::TextAlignment::CenterLeft, shadow_color, Gfx::TextElision::Right); // FIXME: The translated(0, 1) wouldn't be necessary if we could center text based on its baseline. - painter.draw_text(clipped_title_rect.translated(0, 1), final_title, title_font, Gfx::TextAlignment::CenterLeft, title_color, Gfx::TextElision::Right); + painter.draw_text(clipped_title_rect.translated(0, 1), window_title, title_font, Gfx::TextAlignment::CenterLeft, title_color, Gfx::TextElision::Right); } painter.draw_scaled_bitmap(titlebar_icon_rect, icon, icon.rect()); diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp index 5e7946ebe8..01dfe74c67 100644 --- a/Userland/Services/WindowServer/Window.cpp +++ b/Userland/Services/WindowServer/Window.cpp @@ -1002,4 +1002,13 @@ void Window::set_modified(bool modified) frame().invalidate_titlebar(); } +String Window::computed_title() const +{ + String title = m_title; + title.replace("[*]", is_modified() ? " (*)" : ""); + if (client() && client()->is_unresponsive()) + return String::formatted("{} (Not responding)", title); + return title; +} + } diff --git a/Userland/Services/WindowServer/Window.h b/Userland/Services/WindowServer/Window.h index c66f9a921f..53f9f67d75 100644 --- a/Userland/Services/WindowServer/Window.h +++ b/Userland/Services/WindowServer/Window.h @@ -125,6 +125,8 @@ public: String title() const { return m_title; } void set_title(const String&); + String computed_title() const; + float opacity() const { return m_opacity; } void set_opacity(float); diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp index 67ee92d342..c4c089d7e2 100644 --- a/Userland/Services/WindowServer/WindowFrame.cpp +++ b/Userland/Services/WindowServer/WindowFrame.cpp @@ -270,18 +270,11 @@ void WindowFrame::paint_notification_frame(Gfx::Painter& painter) Gfx::WindowTheme::current().paint_notification_frame(painter, m_window.rect(), palette, m_buttons.last().relative_rect()); } -String WindowFrame::compute_title_text() const -{ - if (m_window.client() && m_window.client()->is_unresponsive()) - return String::formatted("{} (Not responding)", m_window.title()); - return m_window.title(); -} - void WindowFrame::paint_tool_window_frame(Gfx::Painter& painter) { auto palette = WindowManager::the().palette(); auto leftmost_button_rect = m_buttons.is_empty() ? Gfx::IntRect() : m_buttons.last().relative_rect(); - Gfx::WindowTheme::current().paint_tool_window_frame(painter, window_state_for_theme(), m_window.rect(), compute_title_text(), palette, leftmost_button_rect); + Gfx::WindowTheme::current().paint_tool_window_frame(painter, window_state_for_theme(), m_window.rect(), m_window.computed_title(), palette, leftmost_button_rect); } void WindowFrame::paint_menubar(Gfx::Painter& painter) @@ -316,7 +309,7 @@ void WindowFrame::paint_normal_frame(Gfx::Painter& painter) { auto palette = WindowManager::the().palette(); auto leftmost_button_rect = m_buttons.is_empty() ? Gfx::IntRect() : m_buttons.last().relative_rect(); - Gfx::WindowTheme::current().paint_normal_frame(painter, window_state_for_theme(), m_window.rect(), compute_title_text(), m_window.icon(), palette, leftmost_button_rect, menu_row_count(), m_window.is_modified()); + Gfx::WindowTheme::current().paint_normal_frame(painter, window_state_for_theme(), m_window.rect(), m_window.computed_title(), m_window.icon(), palette, leftmost_button_rect, menu_row_count(), m_window.is_modified()); if (m_window.menubar() && m_window.should_show_menubar()) paint_menubar(painter); diff --git a/Userland/Services/WindowServer/WindowFrame.h b/Userland/Services/WindowServer/WindowFrame.h index ed094355f2..623241c32e 100644 --- a/Userland/Services/WindowServer/WindowFrame.h +++ b/Userland/Services/WindowServer/WindowFrame.h @@ -94,7 +94,7 @@ private: void handle_menu_mouse_event(Menu&, const MouseEvent&); Gfx::WindowTheme::WindowState window_state_for_theme() const; - String compute_title_text() const; + String computed_title() const; Window& m_window; NonnullOwnPtrVector