diff --git a/Userland/Services/WindowServer/ConnectionFromClient.cpp b/Userland/Services/WindowServer/ConnectionFromClient.cpp index a30976012d5..d67a97a8533 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.cpp +++ b/Userland/Services/WindowServer/ConnectionFromClient.cpp @@ -67,10 +67,10 @@ ConnectionFromClient::~ConnectionFromClient() MenuManager::the().close_all_menus_from_client({}, *this); auto windows = move(m_windows); - for (auto& window : windows) { - window.value->detach_client({}); - if (window.value->type() == WindowType::Applet) - AppletManager::the().remove_applet(window.value); + for (auto& [_, window] : windows) { + window->detach_client({}); + if (window->type() == WindowType::Applet) + AppletManager::the().remove_applet(window); } if (m_show_screen_number) @@ -105,11 +105,10 @@ void ConnectionFromClient::set_menu_name(i32 menu_id, String const& name) } auto& menu = *it->value; menu.set_name(name); - for (auto& it : m_windows) { - auto& window = *it.value; - window.menubar().for_each_menu([&](Menu& other_menu) { + for (auto& [_, window] : m_windows) { + window->menubar().for_each_menu([&](Menu& other_menu) { if (&menu == &other_menu) { - window.invalidate_menubar(); + window->invalidate_menubar(); return IterationDecision::Break; } return IterationDecision::Continue; @@ -126,11 +125,10 @@ void ConnectionFromClient::set_menu_minimum_width(i32 menu_id, i32 minimum_width } auto& menu = *it->value; menu.set_minimum_width(minimum_width); - for (auto& it : m_windows) { - auto& window = *it.value; - window.menubar().for_each_menu([&](Menu& other_menu) { + for (auto& [_, window] : m_windows) { + window->menubar().for_each_menu([&](Menu& other_menu) { if (&menu == &other_menu) { - window.invalidate_menubar(); + window->invalidate_menubar(); return IterationDecision::Break; } return IterationDecision::Continue; diff --git a/Userland/Services/WindowServer/ConnectionFromClient.h b/Userland/Services/WindowServer/ConnectionFromClient.h index a3b7ba8bd31..13312a6bdb0 100644 --- a/Userland/Services/WindowServer/ConnectionFromClient.h +++ b/Userland/Services/WindowServer/ConnectionFromClient.h @@ -64,16 +64,16 @@ public: template void for_each_window(Callback callback) { - for (auto& it : m_windows) { - if (callback(*it.value) == IterationDecision::Break) + for (auto& [_, window] : m_windows) { + if (callback(*window) == IterationDecision::Break) break; } } template void for_each_menu(Callback callback) { - for (auto& it : m_menus) { - if (callback(*it.value) == IterationDecision::Break) + for (auto& [_, menu] : m_menus) { + if (callback(*menu) == IterationDecision::Break) break; } } diff --git a/Userland/Services/WindowServer/Screen.cpp b/Userland/Services/WindowServer/Screen.cpp index f841d6f39bd..9f29402f838 100644 --- a/Userland/Services/WindowServer/Screen.cpp +++ b/Userland/Services/WindowServer/Screen.cpp @@ -8,7 +8,6 @@ #include "Screen.h" #include "Compositor.h" #include "Event.h" -#include "EventLoop.h" #include "ScreenBackend.h" #include "VirtualScreenBackend.h" #include "WindowManager.h" @@ -85,22 +84,21 @@ bool Screen::apply_layout(ScreenLayout&& screen_layout, ByteString& error_msg) } HashMap screens_with_resolution_change; HashMap screens_with_scale_change; - for (auto& it : current_to_new_indices_map) { - auto& screen = s_layout.screens[it.key]; - auto& new_screen = screen_layout.screens[it.value]; + for (auto [current_index, new_index] : current_to_new_indices_map) { + auto& screen = s_layout.screens[current_index]; + auto& new_screen = screen_layout.screens[new_index]; if (screen.resolution != new_screen.resolution) - screens_with_resolution_change.set(s_screens[it.key], it.value); + screens_with_resolution_change.set(s_screens[current_index], new_index); if (screen.scale_factor != new_screen.scale_factor) - screens_with_scale_change.set(s_screens[it.key], it.value); + screens_with_scale_change.set(s_screens[current_index], new_index); } auto screens_backup = move(s_screens); auto layout_backup = move(s_layout); - for (auto& it : screens_with_resolution_change) { - auto& existing_screen = *it.key; - dbgln("Closing device {} in preparation for resolution change", layout_backup.screens[existing_screen.index()].device.value_or("")); - existing_screen.close_device(); + for (auto& [existing_screen, _] : screens_with_resolution_change) { + dbgln("Closing device {} in preparation for resolution change", layout_backup.screens[existing_screen->index()].device.value_or("")); + existing_screen->close_device(); } AK::ArmedScopeGuard rollback([&] { diff --git a/Userland/Services/WindowServer/WindowFrame.h b/Userland/Services/WindowServer/WindowFrame.h index f15c77221d1..c0da3e2c53b 100644 --- a/Userland/Services/WindowServer/WindowFrame.h +++ b/Userland/Services/WindowServer/WindowFrame.h @@ -7,6 +7,8 @@ #pragma once #include +#include +#include #include #include #include @@ -101,10 +103,9 @@ public: void set_dirty(bool re_render_shadow = false) { - for (auto& it : m_rendered_cache) { - auto& cached = *it.value; - cached.m_dirty = true; - cached.m_shadow_dirty |= re_render_shadow; + for (auto& [_, cached] : m_rendered_cache) { + cached->m_dirty = true; + cached->m_shadow_dirty |= re_render_shadow; } } diff --git a/Userland/Services/WindowServer/WindowManager.h b/Userland/Services/WindowServer/WindowManager.h index 9cdc9f65655..89142607d1e 100644 --- a/Userland/Services/WindowServer/WindowManager.h +++ b/Userland/Services/WindowServer/WindowManager.h @@ -583,8 +583,8 @@ void WindowManager::for_each_window_manager(Callback callback) auto& connections = WMConnectionFromClient::s_connections; // FIXME: this isn't really ordered... does it need to be? - for (auto it = connections.begin(); it != connections.end(); ++it) { - if (callback(*it->value) == IterationDecision::Break) + for (auto [_, connection] : connections) { + if (callback(connection) == IterationDecision::Break) return; } }