1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

WindowServer+LibGUI: Automatically close child windows with parent

If a window has child windows when it's destroyed, WindowServer will
now automatically tear down all of its children as well.

This is communicated to the client program through a vector of window
ID's included with the response to WindowServer::DestroyWindow.

This does feel a little bit awkward, but managing it on the client side
also seems a bit awkward.
This commit is contained in:
Andreas Kling 2020-05-01 23:53:05 +02:00
parent a726fda546
commit 745b0b27fd
5 changed files with 47 additions and 16 deletions

View file

@ -126,18 +126,29 @@ Window* Window::find_parent_window()
return nullptr;
}
void Window::hide()
void Window::server_did_destroy()
{
if (!is_visible())
return;
reified_windows->remove(m_window_id);
WindowServerConnection::the().send_sync<Messages::WindowServer::DestroyWindow>(m_window_id);
m_window_id = 0;
m_visible = false;
m_pending_paint_event_rects.clear();
m_back_bitmap = nullptr;
m_front_bitmap = nullptr;
m_override_cursor = StandardCursor::None;
}
void Window::hide()
{
if (!is_visible())
return;
reified_windows->remove(m_window_id);
auto response = WindowServerConnection::the().send_sync<Messages::WindowServer::DestroyWindow>(m_window_id);
server_did_destroy();
for (auto child_window_id : response->destroyed_window_ids()) {
if (auto* window = Window::from_window_id(child_window_id)) {
window->server_did_destroy();
}
}
bool app_has_visible_windows = false;
for (auto& window : *all_windows) {