1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:47:34 +00:00

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

This commit is contained in:
Andreas Kling 2019-04-04 13:33:09 +02:00
parent 9e1682c265
commit 1374195a0d
2 changed files with 18 additions and 0 deletions

View file

@ -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()));

View file

@ -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;
}
}