From 7e33857afa4f1d1174f172ee25d4c6400ef4aa2b Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sun, 16 Apr 2023 12:45:43 +0200 Subject: [PATCH] WindowServer+LibGUI: Port WindowServer's Menu name to new String --- Userland/Libraries/LibGUI/Menu.cpp | 4 ++-- Userland/Services/WindowServer/ConnectionFromClient.cpp | 4 ++-- Userland/Services/WindowServer/ConnectionFromClient.h | 4 ++-- Userland/Services/WindowServer/Menu.cpp | 4 ++-- Userland/Services/WindowServer/Menu.h | 8 ++++---- Userland/Services/WindowServer/Window.cpp | 2 +- Userland/Services/WindowServer/WindowServer.ipc | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Userland/Libraries/LibGUI/Menu.cpp b/Userland/Libraries/LibGUI/Menu.cpp index 49374c98c2..91f5b576f8 100644 --- a/Userland/Libraries/LibGUI/Menu.cpp +++ b/Userland/Libraries/LibGUI/Menu.cpp @@ -93,7 +93,7 @@ void Menu::set_name(String name) { m_name = move(name); if (m_menu_id != -1) { - ConnectionToWindowServer::the().async_set_menu_name(m_menu_id, m_name.to_deprecated_string()); + ConnectionToWindowServer::the().async_set_menu_name(m_menu_id, m_name); update_parent_menu_item(); } } @@ -168,7 +168,7 @@ int Menu::realize_menu(RefPtr default_action) unrealize_menu(); m_menu_id = s_menu_id_allocator.allocate(); - ConnectionToWindowServer::the().async_create_menu(m_menu_id, m_name.to_deprecated_string()); + ConnectionToWindowServer::the().async_create_menu(m_menu_id, m_name); dbgln_if(MENU_DEBUG, "GUI::Menu::realize_menu(): New menu ID: {}", m_menu_id); VERIFY(m_menu_id > 0); diff --git a/Userland/Services/WindowServer/ConnectionFromClient.cpp b/Userland/Services/WindowServer/ConnectionFromClient.cpp index c953622ab5..dcb57422e7 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.cpp +++ b/Userland/Services/WindowServer/ConnectionFromClient.cpp @@ -90,13 +90,13 @@ void ConnectionFromClient::notify_about_new_screen_rects() async_screen_rects_changed(Screen::rects(), Screen::main().index(), wm.window_stack_rows(), wm.window_stack_columns()); } -void ConnectionFromClient::create_menu(i32 menu_id, DeprecatedString const& name) +void ConnectionFromClient::create_menu(i32 menu_id, String const& name) { auto menu = Menu::construct(this, menu_id, name); m_menus.set(menu_id, move(menu)); } -void ConnectionFromClient::set_menu_name(i32 menu_id, DeprecatedString const& name) +void ConnectionFromClient::set_menu_name(i32 menu_id, String const& name) { auto it = m_menus.find(menu_id); if (it == m_menus.end()) { diff --git a/Userland/Services/WindowServer/ConnectionFromClient.h b/Userland/Services/WindowServer/ConnectionFromClient.h index 988e537c88..71d5471636 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.h +++ b/Userland/Services/WindowServer/ConnectionFromClient.h @@ -93,8 +93,8 @@ private: void set_unresponsive(bool); void destroy_window(Window&, Vector& destroyed_window_ids); - virtual void create_menu(i32, DeprecatedString const&) override; - virtual void set_menu_name(i32, DeprecatedString const&) override; + virtual void create_menu(i32, String const&) override; + virtual void set_menu_name(i32, String const&) override; virtual void destroy_menu(i32) override; virtual void add_menu(i32, i32) override; virtual void add_menu_item(i32, i32, i32, DeprecatedString const&, bool, bool, bool, bool, bool, DeprecatedString const&, Gfx::ShareableBitmap const&, bool) override; diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp index c8d4f489db..82cd2cd9d7 100644 --- a/Userland/Services/WindowServer/Menu.cpp +++ b/Userland/Services/WindowServer/Menu.cpp @@ -38,7 +38,7 @@ u32 find_ampersand_shortcut_character(StringView string) return 0; } -Menu::Menu(ConnectionFromClient* client, int menu_id, DeprecatedString name) +Menu::Menu(ConnectionFromClient* client, int menu_id, String name) : Core::Object(client) , m_client(client) , m_menu_id(menu_id) @@ -752,7 +752,7 @@ void Menu::set_hovered_index(int index, bool make_input) redraw(*old_hovered_item); } -void Menu::set_name(DeprecatedString name) +void Menu::set_name(String name) { m_name = move(name); } diff --git a/Userland/Services/WindowServer/Menu.h b/Userland/Services/WindowServer/Menu.h index 00ae15329d..1e653c55d5 100644 --- a/Userland/Services/WindowServer/Menu.h +++ b/Userland/Services/WindowServer/Menu.h @@ -58,8 +58,8 @@ public: void update_alt_shortcuts_for_items(); void add_item(NonnullOwnPtr); - DeprecatedString const& name() const { return m_name; } - void set_name(DeprecatedString); + String const& name() const { return m_name; } + void set_name(String); template IterationDecision for_each_item(Callback callback) @@ -138,7 +138,7 @@ public: Vector const* items_with_alt_shortcut(u32 alt_shortcut) const; private: - Menu(ConnectionFromClient*, int menu_id, DeprecatedString name); + Menu(ConnectionFromClient*, int menu_id, String name); virtual void event(Core::Event&) override; @@ -155,7 +155,7 @@ private: ConnectionFromClient* m_client { nullptr }; int m_menu_id { 0 }; - DeprecatedString m_name; + String m_name; u32 m_alt_shortcut_character { 0 }; Gfx::IntRect m_rect_in_window_menubar; Gfx::IntPoint m_unadjusted_position; diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp index 3ca0538613..7239b13dbe 100644 --- a/Userland/Services/WindowServer/Window.cpp +++ b/Userland/Services/WindowServer/Window.cpp @@ -718,7 +718,7 @@ void Window::request_update(Gfx::IntRect const& rect, bool ignore_occlusion) void Window::ensure_window_menu() { if (!m_window_menu) { - m_window_menu = Menu::construct(nullptr, -1, "(Window Menu)"); + m_window_menu = Menu::construct(nullptr, -1, "(Window Menu)"_string.release_value_but_fixme_should_propagate_errors()); m_window_menu->set_window_menu_of(*this); auto minimize_item = make(*m_window_menu, (unsigned)WindowMenuAction::MinimizeOrUnminimize, ""); diff --git a/Userland/Services/WindowServer/WindowServer.ipc b/Userland/Services/WindowServer/WindowServer.ipc index 19124a1fba..33a3b2b6a1 100644 --- a/Userland/Services/WindowServer/WindowServer.ipc +++ b/Userland/Services/WindowServer/WindowServer.ipc @@ -4,8 +4,8 @@ endpoint WindowServer { - create_menu(i32 menu_id, [UTF8] DeprecatedString name) =| - set_menu_name(i32 menu_id, DeprecatedString name) =| + create_menu(i32 menu_id, [UTF8] String name) =| + set_menu_name(i32 menu_id, String name) =| destroy_menu(i32 menu_id) =| add_menu(i32 window_id, i32 menu_id) =|