Fix focus loss on decoration destruction

InputDeviceHandler keeps track of which client has focus, and whether
the decoration or main window has focus.

Should the decoration get destroyed whilst the decoration has focus we
don't update correctly. This can happen when
"BorderlessMaximizedWindows" is set, or if you use key presses whilst
above the decoration.

cleanupDecoration (which is an odd name) is called whenever a decoration
gains or loses focus. Here we can connect for the decoration destruction
and force a focus change.

BUG: 411884
This commit is contained in:
David Edmundson 2021-07-15 13:35:51 +01:00 committed by Andrey Butirsky
parent e4e920d895
commit 566bfbff5b
2 changed files with 7 additions and 0 deletions

View file

@ -495,6 +495,9 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl
disconnect(m_decorationGeometryConnection);
m_decorationGeometryConnection = QMetaObject::Connection();
disconnect(m_decorationDestroyedConnection);
m_decorationDestroyedConnection = QMetaObject::Connection();
if (old) {
// send leave event to old decoration
QHoverEvent event(QEvent::HoverLeave, QPointF(), QPointF());
@ -528,6 +531,9 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl
QCoreApplication::instance()->sendEvent(decoration()->decoration(), &event);
}
}, Qt::QueuedConnection);
// if our decoration gets destroyed whilst it has focus, we pass focus on to the same client
m_decorationDestroyedConnection = connect(now, &QObject::destroyed, this, &PointerInputRedirection::update, Qt::QueuedConnection);
}
static bool s_cursorUpdateBlocking = false;

View file

@ -163,6 +163,7 @@ private:
QMetaObject::Connection m_confinedPointerRegionConnection;
QMetaObject::Connection m_lockedPointerAboutToBeUnboundConnection;
QMetaObject::Connection m_decorationGeometryConnection;
QMetaObject::Connection m_decorationDestroyedConnection;
bool m_confined = false;
bool m_locked = false;
bool m_enableConstraints = true;