From d57e79714725e0397803215daa1f61cc0798a15b Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 18 Oct 2024 17:17:58 +0300 Subject: [PATCH] WindowServer: Don't kill window on key event, instead send close event This allows notifying the client about window close and let client handle it as it wants --- userspace/programs/WindowServer/WindowServer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/userspace/programs/WindowServer/WindowServer.cpp b/userspace/programs/WindowServer/WindowServer.cpp index e89ebc99..349d6b09 100644 --- a/userspace/programs/WindowServer/WindowServer.cpp +++ b/userspace/programs/WindowServer/WindowServer.cpp @@ -224,8 +224,11 @@ void WindowServer::on_key_event(LibInput::KeyEvent event) // Kill window with mod+Q if (m_is_mod_key_held && event.pressed() && event.key == LibInput::Key::Q) { - if (m_focused_window) - remove_client_fd(m_focused_window->client_fd()); + if (!m_focused_window) + return; + LibGUI::EventPacket::CloseWindowEvent packet; + if (auto ret = packet.send_serialized(m_focused_window->client_fd()); ret.is_error()) + dwarnln("could not send window close event: {}", ret.error()); return; }