WindowServer: Don't allow focusing unfocusable windows after closing

This commit is contained in:
Bananymous 2024-11-17 03:14:27 +02:00
parent df613775b6
commit e1b82e4e43
1 changed files with 9 additions and 2 deletions

View File

@ -538,6 +538,7 @@ void WindowServer::on_mouse_scroll(LibInput::MouseScrollEvent event)
void WindowServer::set_focused_window(BAN::RefPtr<Window> window)
{
ASSERT(window->get_attributes().focusable);
if (m_focused_window == window)
return;
@ -1019,8 +1020,14 @@ void WindowServer::remove_client_fd(int fd)
if (window == m_focused_window)
{
m_focused_window = nullptr;
if (!m_client_windows.empty())
set_focused_window(m_client_windows.back());
for (size_t j = m_client_windows.size(); j > 0; j--)
{
auto& client_window = m_client_windows[j - 1];
if (!client_window->get_attributes().focusable)
continue;
set_focused_window(client_window);
break;
}
}
break;