wayland: Fix focus follows mouse policy

We want to update the input focus only if the pointer is moved. Due to
that, AbstractClient::enterEvent() checks the last seen pointer position
to decide whether the window needs to be focused.

The issue is that when the pointer moves from a decoration to a surface,
the cached pointer position will be updated to the current pointer
position, and thus the check in AbstractClient::enterEvent() will fail.

We need to update the cached pointer position only if there is a focused
decoration.
This commit is contained in:
Vlad Zahorodnii 2021-05-03 11:24:22 +03:00
parent b4987a9100
commit 073b6efc14
2 changed files with 13 additions and 15 deletions

View file

@ -2846,6 +2846,7 @@ void InputDeviceHandler::update()
setAt(toplevel); setAt(toplevel);
if (focusUpdatesBlocked()) { if (focusUpdatesBlocked()) {
workspace()->updateFocusMousePosition(position().toPoint());
return; return;
} }
@ -2860,21 +2861,20 @@ void InputDeviceHandler::update()
// went onto or off from decoration, update focus // went onto or off from decoration, update focus
updateFocus(); updateFocus();
} }
return; } else {
} updateInternalWindow(nullptr);
updateInternalWindow(nullptr);
if (m_focus.focus != m_at.at) { if (m_focus.focus != m_at.at) {
// focus change // focus change
updateDecoration(); updateDecoration();
updateFocus(); updateFocus();
return; } else if (updateDecoration()) {
} // went onto or off from decoration, update focus
// check if switched to/from decoration while staying on the same Toplevel updateFocus();
if (updateDecoration()) { }
// went onto or off from decoration, update focus
updateFocus();
} }
workspace()->updateFocusMousePosition(position().toPoint());
} }
Toplevel *InputDeviceHandler::at() const Toplevel *InputDeviceHandler::at() const

View file

@ -473,7 +473,6 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl
{ {
disconnect(m_decorationGeometryConnection); disconnect(m_decorationGeometryConnection);
m_decorationGeometryConnection = QMetaObject::Connection(); m_decorationGeometryConnection = QMetaObject::Connection();
workspace()->updateFocusMousePosition(position().toPoint());
if (old) { if (old) {
// send leave event to old decoration // send leave event to old decoration
@ -524,7 +523,6 @@ void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow
if (AbstractClient *ac = qobject_cast<AbstractClient*>(focusNow)) { if (AbstractClient *ac = qobject_cast<AbstractClient*>(focusNow)) {
ac->enterEvent(m_pos.toPoint()); ac->enterEvent(m_pos.toPoint());
workspace()->updateFocusMousePosition(m_pos.toPoint());
} }
if (internalWindow()) { if (internalWindow()) {