summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-07-18 01:46:51 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-18 01:50:24 +0200
commit82c38f6fdf6e5c08fd52bcc612299b9da61da0fe (patch)
tree5aa630feb5c60f2e05666be67f5db64e0ad0cbfe
parentbecbf36711351c32e96b3d80b8d6e7af8b0fd815 (diff)
downloadserenity-82c38f6fdf6e5c08fd52bcc612299b9da61da0fe.zip
WindowServer: Decide on a window title before measuring its width
If we add "(Not responding)" to the title of an unresponsive window, the title rect needs to be wider or we'll have text-on-stripes. Thanks to @SharpOB for reporting this bug!
-rw-r--r--Services/WindowServer/WindowFrame.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/Services/WindowServer/WindowFrame.cpp b/Services/WindowServer/WindowFrame.cpp
index 746556a759..68f2457644 100644
--- a/Services/WindowServer/WindowFrame.cpp
+++ b/Services/WindowServer/WindowFrame.cpp
@@ -217,6 +217,15 @@ void WindowFrame::paint_normal_frame(Gfx::Painter& painter)
auto palette = WindowManager::the().palette();
auto& window = m_window;
Gfx::IntRect outer_rect = { {}, rect().size() };
+ String title_text;
+ if (window.client() && window.client()->is_unresponsive()) {
+ StringBuilder builder;
+ builder.append(window.title());
+ builder.append(" (Not responding)");
+ title_text = builder.to_string();
+ } else {
+ title_text = window.title();
+ }
Gfx::StylePainter::paint_window_frame(painter, outer_rect, palette);
@@ -224,7 +233,7 @@ void WindowFrame::paint_normal_frame(Gfx::Painter& painter)
auto titlebar_icon_rect = title_bar_icon_rect();
auto titlebar_inner_rect = title_bar_text_rect();
auto titlebar_title_rect = titlebar_inner_rect;
- titlebar_title_rect.set_width(Gfx::Font::default_bold_font().width(window.title()));
+ titlebar_title_rect.set_width(Gfx::Font::default_bold_font().width(title_text));
auto [title_color, border_color, border_color2] = compute_frame_colors();
@@ -244,17 +253,6 @@ void WindowFrame::paint_normal_frame(Gfx::Painter& painter)
}
}
- String title_text;
-
- if (window.client() && window.client()->is_unresponsive()) {
- StringBuilder builder;
- builder.append(window.title());
- builder.append(" (Not responding)");
- title_text = builder.to_string();
- } else {
- title_text = window.title();
- }
-
auto clipped_title_rect = titlebar_title_rect;
clipped_title_rect.set_width(stripe_right - clipped_title_rect.x());
if (!clipped_title_rect.is_empty()) {