summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-04-12 15:24:17 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-12 15:24:17 +0200
commit767bd8cc889bf62e781b7173dc7d858e71021562 (patch)
tree209182d29158694411a12b6fe972edf815dc5ce3 /Userland
parentfbbb4b33955ec089dc8b26df76f59e25ba49d37d (diff)
downloadserenity-767bd8cc889bf62e781b7173dc7d858e71021562.zip
WindowServer: Strip Alt-shortcut marker ('&') when measuring menu texts
We were including these markers when computing the sizes of menus, causing them to get a little too much padding.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Services/WindowServer/Menu.cpp2
-rw-r--r--Userland/Services/WindowServer/Window.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp
index 715a23437d..0b0c10380e 100644
--- a/Userland/Services/WindowServer/Menu.cpp
+++ b/Userland/Services/WindowServer/Menu.cpp
@@ -115,7 +115,7 @@ int Menu::content_width() const
if (item.type() != MenuItem::Text)
continue;
auto& use_font = item.is_default() ? Gfx::FontDatabase::default_bold_font() : font();
- int text_width = use_font.width(item.text());
+ int text_width = use_font.width(Gfx::parse_ampersand_string(item.text()));
if (!item.shortcut_text().is_empty()) {
int shortcut_width = use_font.width(item.shortcut_text());
widest_shortcut = max(shortcut_width, widest_shortcut);
diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp
index 57a21489c4..f9e0a38267 100644
--- a/Userland/Services/WindowServer/Window.cpp
+++ b/Userland/Services/WindowServer/Window.cpp
@@ -990,7 +990,7 @@ void Window::set_menubar(MenuBar* menubar)
Gfx::IntPoint next_menu_location { 0, 0 };
auto menubar_rect = Gfx::WindowTheme::current().menubar_rect(Gfx::WindowTheme::WindowType::Normal, rect(), wm.palette(), 1);
m_menubar->for_each_menu([&](Menu& menu) {
- int text_width = wm.font().width(menu.name());
+ int text_width = wm.font().width(Gfx::parse_ampersand_string(menu.name()));
menu.set_rect_in_window_menubar({ next_menu_location.x(), 0, text_width + menubar_menu_margin, menubar_rect.height() });
next_menu_location.move_by(menu.rect_in_window_menubar().width(), 0);
return IterationDecision::Continue;