summaryrefslogtreecommitdiffstats
path: root/src/compositor/compositor_api/qwaylandseat.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2017-10-27 10:37:21 +0200
committerPaul Olav Tvete <paul.tvete@qt.io>2017-10-27 10:37:21 +0200
commit62293cefae129bbfebb0317b39d059b0abb1a16a (patch)
tree159080c98a85baa02e34776cf2618642ae55d456 /src/compositor/compositor_api/qwaylandseat.cpp
parentc2b272ac73617a8d5ff25151534feda95ace63ee (diff)
parent523cf490b4c46916c6f5253c666a492f5cce2aad (diff)
Merge remote-tracking branch 'qt/5.10' into dev
Diffstat (limited to 'src/compositor/compositor_api/qwaylandseat.cpp')
-rw-r--r--src/compositor/compositor_api/qwaylandseat.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/compositor/compositor_api/qwaylandseat.cpp b/src/compositor/compositor_api/qwaylandseat.cpp
index 474ebc0e5..4b506bcda 100644
--- a/src/compositor/compositor_api/qwaylandseat.cpp
+++ b/src/compositor/compositor_api/qwaylandseat.cpp
@@ -548,6 +548,12 @@ void QWaylandSeat::setMouseFocus(QWaylandView *view)
QWaylandView *oldFocus = d->mouseFocus;
d->mouseFocus = view;
+
+ if (oldFocus)
+ disconnect(oldFocus, &QObject::destroyed, this, &QWaylandSeat::handleMouseFocusDestroyed);
+ if (d->mouseFocus)
+ connect(d->mouseFocus, &QObject::destroyed, this, &QWaylandSeat::handleMouseFocusDestroyed);
+
emit mouseFocusChanged(d->mouseFocus, oldFocus);
}
@@ -604,4 +610,15 @@ QWaylandSeat *QWaylandSeat::fromSeatResource(struct ::wl_resource *resource)
* This signal is emitted when the mouse focus has changed from \a oldFocus to \a newFocus.
*/
+void QWaylandSeat::handleMouseFocusDestroyed()
+{
+ // This is triggered when the QWaylandView is destroyed, NOT the surface.
+ // ... so this is for the rare case when the view that currently holds the mouse focus is
+ // destroyed before its surface
+ Q_D(QWaylandSeat);
+ d->mouseFocus = nullptr;
+ QWaylandView *oldFocus = nullptr; // we have to send nullptr because the old focus is already destroyed at this point
+ emit mouseFocusChanged(d->mouseFocus, oldFocus);
+}
+
QT_END_NAMESPACE