Update pointer and tablet focus when focused window is closed

Prior to dropping Deleted, we implicitly relied on the fact that the
QPointer storing the focused window will be reset to null when the
window is closed so we didn't include any cleanup logic.

After dropping Deleted and extending the lifetime of the original
window, it's no longer the case and we have to explicitly handle closing
the window otherwise kwin can encounter unexpected cases.
This commit is contained in:
Vlad Zahorodnii 2023-03-31 13:20:52 +03:00
parent 75c7689f67
commit 2233190e67

View file

@ -3337,11 +3337,21 @@ bool InputDeviceHandler::setHover(Window *window)
void InputDeviceHandler::setFocus(Window *window) void InputDeviceHandler::setFocus(Window *window)
{ {
if (m_focus.window != window) { if (m_focus.window == window) {
Window *oldFocus = m_focus.window; return;
m_focus.window = window;
focusUpdate(oldFocus, m_focus.window);
} }
Window *oldFocus = m_focus.window;
if (oldFocus) {
disconnect(oldFocus, &Window::closed, this, &InputDeviceHandler::update);
}
m_focus.window = window;
if (window) {
connect(window, &Window::closed, this, &InputDeviceHandler::update);
}
focusUpdate(oldFocus, window);
} }
void InputDeviceHandler::setDecoration(Decoration::DecoratedClientImpl *decoration) void InputDeviceHandler::setDecoration(Decoration::DecoratedClientImpl *decoration)