Commit d87273d8 authored by David Edmundson's avatar David Edmundson Committed by Andrey Butirsky
Browse files

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

(cherry picked from commit 566bfbff)
parent 5d0d55e9
...@@ -479,6 +479,9 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl ...@@ -479,6 +479,9 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl
disconnect(m_decorationGeometryConnection); disconnect(m_decorationGeometryConnection);
m_decorationGeometryConnection = QMetaObject::Connection(); m_decorationGeometryConnection = QMetaObject::Connection();
m_decorationDestroyedConnection = QMetaObject::Connection();
if (old) { if (old) {
// send leave event to old decoration // send leave event to old decoration
QHoverEvent event(QEvent::HoverLeave, QPointF(), QPointF()); QHoverEvent event(QEvent::HoverLeave, QPointF(), QPointF());
...@@ -512,6 +515,9 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl ...@@ -512,6 +515,9 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl
QCoreApplication::instance()->sendEvent(decoration()->decoration(), &event); QCoreApplication::instance()->sendEvent(decoration()->decoration(), &event);
} }
}, Qt::QueuedConnection); }, 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; static bool s_cursorUpdateBlocking = false;
...@@ -162,6 +162,7 @@ private: ...@@ -162,6 +162,7 @@ private:
QMetaObject::Connection m_confinedPointerRegionConnection; QMetaObject::Connection m_confinedPointerRegionConnection;
QMetaObject::Connection m_lockedPointerAboutToBeUnboundConnection; QMetaObject::Connection m_lockedPointerAboutToBeUnboundConnection;
QMetaObject::Connection m_decorationGeometryConnection; QMetaObject::Connection m_decorationGeometryConnection;
QMetaObject::Connection m_decorationDestroyedConnection;
bool m_confined = false; bool m_confined = false;
bool m_locked = false; bool m_locked = false;
bool m_enableConstraints = true; bool m_enableConstraints = true;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment