Kaynağa Gözat

WindowServer: Broadcast the full window list to new WM listener clients.

Andreas Kling 6 yıl önce
ebeveyn
işleme
1374195a0d

+ 8 - 0
Servers/WindowServer/WSWindowManager.cpp

@@ -493,6 +493,14 @@ void WSWindowManager::add_window(WSWindow& window)
     if (m_switcher.is_visible() && window.type() != WSWindowType::WindowSwitcher)
         m_switcher.refresh();
 
+    if (window.listens_to_wm_events()) {
+        for_each_window([&window] (WSWindow& other_window) {
+            if (&window != &other_window && other_window.client())
+                WSMessageLoop::the().post_message(window, make<WSWMWindowAddedEvent>(other_window.client()->client_id(), other_window.window_id(), other_window.title(), other_window.rect(), other_window.is_active()));
+            return IterationDecision::Continue;
+        });
+    }
+
     for_each_window_listening_to_wm_events([&window] (WSWindow& listener) {
         if (window.client())
             WSMessageLoop::the().post_message(listener, make<WSWMWindowAddedEvent>(window.client()->client_id(), window.window_id(), window.title(), window.rect(), window.is_active()));

+ 10 - 0
Servers/WindowServer/WSWindowManager.h

@@ -113,6 +113,7 @@ private:
     template<typename Callback> IterationDecision for_each_visible_window_from_front_to_back(Callback);
     template<typename Callback> IterationDecision for_each_visible_window_from_back_to_front(Callback);
     template<typename Callback> void for_each_window_listening_to_wm_events(Callback);
+    template<typename Callback> void for_each_window(Callback);
     template<typename Callback> void for_each_active_menubar_menu(Callback);
     void close_current_menu();
     virtual void on_message(const WSMessage&) override;
@@ -278,3 +279,12 @@ void WSWindowManager::for_each_window_listening_to_wm_events(Callback callback)
             return;
     }
 }
+
+template<typename Callback>
+void WSWindowManager::for_each_window(Callback callback)
+{
+    for (auto* window = m_windows_in_order.tail(); window; window = window->prev()) {
+        if (callback(*window) == IterationDecision::Abort)
+            return;
+    }
+}