1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:48:11 +00:00

LibGUI+WindowServer: Inform WindowServer about parent/child windows

If a window has another window in its Core::Object ancestor chain,
we now communicate that relationship to WindowServer so that it can
act with awareness of parent/child windows.
This commit is contained in:
Andreas Kling 2020-05-01 22:59:38 +02:00
parent e9b7a51a9a
commit 6228f72b87
7 changed files with 63 additions and 2 deletions

View file

@ -89,6 +89,9 @@ void Window::show()
{
if (is_visible())
return;
auto* parent_window = find_parent_window();
m_override_cursor = StandardCursor::None;
auto response = WindowServerConnection::the().send_sync<Messages::WindowServer::CreateWindow>(
m_rect_when_windowless,
@ -102,7 +105,8 @@ void Window::show()
m_base_size,
m_size_increment,
(i32)m_window_type,
m_title_when_windowless);
m_title_when_windowless,
parent_window ? parent_window->window_id() : 0);
m_window_id = response->window_id();
m_visible = true;
@ -113,6 +117,15 @@ void Window::show()
update();
}
Window* Window::find_parent_window()
{
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
if (ancestor->is_window())
return static_cast<Window*>(ancestor);
}
return nullptr;
}
void Window::hide()
{
if (!is_visible())