WindowServer: Make clients nonblock

Also dont allow freezed windows to "steal" focus and lock up the window
server :D
This commit is contained in:
Bananymous 2025-11-16 03:42:21 +02:00
parent f166cb09ec
commit 9803209ba1
2 changed files with 1 additions and 7 deletions

View File

@ -789,10 +789,7 @@ void WindowServer::set_focused_window(BAN::RefPtr<Window> window)
LibGUI::EventPacket::WindowFocusEvent packet; LibGUI::EventPacket::WindowFocusEvent packet;
packet.event.focused = false; packet.event.focused = false;
if (auto ret = packet.send_serialized(m_focused_window->client_fd()); ret.is_error()) if (auto ret = packet.send_serialized(m_focused_window->client_fd()); ret.is_error())
{
dwarnln("could not send window focus event: {}", ret.error()); dwarnln("could not send window focus event: {}", ret.error());
return;
}
} }
for (size_t i = m_client_windows.size(); i > 0; i--) for (size_t i = m_client_windows.size(); i > 0; i--)
@ -812,10 +809,7 @@ void WindowServer::set_focused_window(BAN::RefPtr<Window> window)
LibGUI::EventPacket::WindowFocusEvent packet; LibGUI::EventPacket::WindowFocusEvent packet;
packet.event.focused = true; packet.event.focused = true;
if (auto ret = packet.send_serialized(m_focused_window->client_fd()); ret.is_error()) if (auto ret = packet.send_serialized(m_focused_window->client_fd()); ret.is_error())
{
dwarnln("could not send window focus event: {}", ret.error()); dwarnln("could not send window focus event: {}", ret.error());
return;
}
} }
} }

View File

@ -254,7 +254,7 @@ int main()
if (FD_ISSET(server_fd, &fds)) if (FD_ISSET(server_fd, &fds))
{ {
int window_fd = accept4(server_fd, nullptr, nullptr, SOCK_CLOEXEC); int window_fd = accept4(server_fd, nullptr, nullptr, SOCK_NONBLOCK | SOCK_CLOEXEC);
if (window_fd == -1) if (window_fd == -1)
{ {
dwarnln("accept: {}", strerror(errno)); dwarnln("accept: {}", strerror(errno));