1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 13:15:09 +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

@ -451,10 +451,30 @@ OwnPtr<Messages::WindowServer::GetClipboardContentsResponse> ClientConnection::h
return make<Messages::WindowServer::GetClipboardContentsResponse>(shbuf_id, clipboard.size(), clipboard.data_type());
}
Window* ClientConnection::window_from_id(i32 window_id)
{
auto it = m_windows.find(window_id);
if (it == m_windows.end())
return nullptr;
return it->value.ptr();
}
OwnPtr<Messages::WindowServer::CreateWindowResponse> ClientConnection::handle(const Messages::WindowServer::CreateWindow& message)
{
int window_id = m_next_window_id++;
auto window = Window::construct(*this, (WindowType)message.type(), window_id, message.modal(), message.minimizable(), message.resizable(), message.fullscreen());
dbg() << "Constructing window with parent_window_id=" << message.parent_window_id();
if (message.parent_window_id()) {
auto* parent_window = window_from_id(message.parent_window_id());
if (!parent_window) {
did_misbehave("CreateWindow with bad parent_window_id");
return nullptr;
}
window->set_parent_window(*parent_window);
}
window->set_has_alpha_channel(message.has_alpha_channel());
window->set_title(message.title());
if (!message.fullscreen()) {