diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-10 00:00:40 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-10 00:02:05 +0200 |
commit | 353a831c8cab0de3484069169f98bed99023f637 (patch) | |
tree | 4aababa7337b34fe1576ac3d53010b88490c250c /Userland/Libraries | |
parent | 1f24ab91f2f67735e87e34cff5fe46a9be67ac86 (diff) | |
download | serenity-353a831c8cab0de3484069169f98bed99023f637.zip |
WindowServer: Compute final window title before passing to WM clients
We were not substituting the window modified marker ("[*]") in the
title strings we were sending to WM clients. This caused the Taskbar
to show pre-substitution window titles for the Text Editor application.
This patch moves the window title resolution to Window::compute_title()
which is then used throughout.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGfx/ClassicWindowTheme.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
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()); |