diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-06-08 19:36:27 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-08 19:14:24 +0200 |
commit | 7ac196974de3a85430f4ccd1db883943853d8ae0 (patch) | |
tree | efc838bfc282a16379e1c80b7f3e721a6eb8b297 /Userland/Services/WindowServer | |
parent | 3d94b5051d8a783858cde04eb4d2e1ecf63ac180 (diff) | |
download | serenity-7ac196974de3a85430f4ccd1db883943853d8ae0.zip |
Everywhere: Replace Vector<T*> with nonnull entries with Vector<T&>
Diffstat (limited to 'Userland/Services/WindowServer')
-rw-r--r-- | Userland/Services/WindowServer/MenuManager.cpp | 20 | ||||
-rw-r--r-- | Userland/Services/WindowServer/MenuManager.h | 2 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Menubar.cpp | 2 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Menubar.h | 4 | ||||
-rw-r--r-- | Userland/Services/WindowServer/WindowManager.h | 6 |
5 files changed, 17 insertions, 17 deletions
diff --git a/Userland/Services/WindowServer/MenuManager.cpp b/Userland/Services/WindowServer/MenuManager.cpp index 2dc82f3c4e..3e0dd512df 100644 --- a/Userland/Services/WindowServer/MenuManager.cpp +++ b/Userland/Services/WindowServer/MenuManager.cpp @@ -227,34 +227,34 @@ void MenuManager::close_everyone() void MenuManager::close_everyone_not_in_lineage(Menu& menu) { - Vector<Menu*> menus_to_close; + Vector<Menu&> menus_to_close; for (auto& open_menu : m_open_menu_stack) { if (!open_menu) continue; if (&menu == open_menu.ptr() || open_menu->is_menu_ancestor_of(menu)) continue; - menus_to_close.append(open_menu); + menus_to_close.append(*open_menu); } close_menus(menus_to_close); } -void MenuManager::close_menus(const Vector<Menu*>& menus) +void MenuManager::close_menus(const Vector<Menu&>& menus) { for (auto& menu : menus) { - if (menu == m_current_menu) + if (&menu == m_current_menu) clear_current_menu(); - menu->set_visible(false); - menu->clear_hovered_item(); + menu.set_visible(false); + menu.clear_hovered_item(); m_open_menu_stack.remove_first_matching([&](auto& entry) { - return entry == menu; + return entry == &menu; }); } refresh(); } -static void collect_menu_subtree(Menu& menu, Vector<Menu*>& menus) +static void collect_menu_subtree(Menu& menu, Vector<Menu&>& menus) { - menus.append(&menu); + menus.append(menu); for (size_t i = 0; i < menu.item_count(); ++i) { auto& item = menu.item(i); if (!item.is_submenu()) @@ -265,7 +265,7 @@ static void collect_menu_subtree(Menu& menu, Vector<Menu*>& menus) void MenuManager::close_menu_and_descendants(Menu& menu) { - Vector<Menu*> menus_to_close; + Vector<Menu&> menus_to_close; collect_menu_subtree(menu, menus_to_close); close_menus(menus_to_close); } diff --git a/Userland/Services/WindowServer/MenuManager.h b/Userland/Services/WindowServer/MenuManager.h index b3af227fcc..8132e3a459 100644 --- a/Userland/Services/WindowServer/MenuManager.h +++ b/Userland/Services/WindowServer/MenuManager.h @@ -50,7 +50,7 @@ public: Menu* hovered_menu() { return m_hovered_menu; } private: - void close_menus(const Vector<Menu*>&); + void close_menus(const Vector<Menu&>&); virtual void event(Core::Event&) override; void handle_mouse_event(MouseEvent&); diff --git a/Userland/Services/WindowServer/Menubar.cpp b/Userland/Services/WindowServer/Menubar.cpp index 34991bee79..3bd9ecea88 100644 --- a/Userland/Services/WindowServer/Menubar.cpp +++ b/Userland/Services/WindowServer/Menubar.cpp @@ -21,7 +21,7 @@ Menubar::~Menubar() void Menubar::add_menu(Menu& menu) { - m_menus.append(&menu); + m_menus.append(menu); } } diff --git a/Userland/Services/WindowServer/Menubar.h b/Userland/Services/WindowServer/Menubar.h index 03e10d14c5..838718252b 100644 --- a/Userland/Services/WindowServer/Menubar.h +++ b/Userland/Services/WindowServer/Menubar.h @@ -29,7 +29,7 @@ public: void for_each_menu(Callback callback) { for (auto& menu : m_menus) { - if (callback(*menu) == IterationDecision::Break) + if (callback(menu) == IterationDecision::Break) return; } } @@ -39,7 +39,7 @@ private: ClientConnection& m_client; int m_menubar_id { 0 }; - Vector<Menu*> m_menus; + Vector<Menu&> m_menus; }; } diff --git a/Userland/Services/WindowServer/WindowManager.h b/Userland/Services/WindowServer/WindowManager.h index 4bd6ceabc7..92c0af8fe8 100644 --- a/Userland/Services/WindowServer/WindowManager.h +++ b/Userland/Services/WindowServer/WindowManager.h @@ -200,19 +200,19 @@ public: { auto* blocking_modal_window = window.blocking_modal_window(); if (blocking_modal_window || window.is_modal()) { - Vector<Window*> modal_stack; + Vector<Window&> modal_stack; auto* modal_stack_top = blocking_modal_window ? blocking_modal_window : &window; for (auto* parent = modal_stack_top->parent_window(); parent; parent = parent->parent_window()) { auto* blocked_by = parent->blocking_modal_window(); if (!blocked_by || (blocked_by != modal_stack_top && !modal_stack_top->is_descendant_of(*blocked_by))) break; - modal_stack.append(parent); + modal_stack.append(*parent); if (!parent->is_modal()) break; } if (!modal_stack.is_empty()) { for (size_t i = modal_stack.size(); i > 0; i--) { - IterationDecision decision = f(*modal_stack[i - 1], false); + IterationDecision decision = f(modal_stack[i - 1], false); if (decision != IterationDecision::Continue) return decision; } |