Commit 98e5d269 authored by Martin Flöser's avatar Martin Flöser
Browse files

[server] Send keyboard leave when client destroys the focused surface

Summary:
This is a change inspired by https://bugreports.qt.io/browse/QTBUG-61930.
When Qt closes a window due to a key press event it starts to repeat the
event as KWayland does not send a keyboard leave event. Weston on the
other hand does send out the keyboard leave. In my opinion it doesn't
make much sense to send out the keyboard leave in this situation and in
my opinion that is a client bug, but if it makes clients happy we can
send them the keyboard leave. Similar this should be done for pointer,
touch, etc.

BUG: 382280

Test Plan: Run the example added to the Qt bug and it worked fine

Reviewers: #frameworks, #plasma

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D6683
parent 80bc6113
......@@ -1563,7 +1563,8 @@ void TestWaylandSeat::testKeyboard()
QSignalSpy serverSurfaceDestroyedSpy(serverSurface, &QObject::destroyed);
QVERIFY(serverSurfaceDestroyedSpy.isValid());
delete s;
QVERIFY(serverSurfaceDestroyedSpy.wait());
QVERIFY(leftSpy.wait());
QCOMPARE(serverSurfaceDestroyedSpy.count(), 1);
QVERIFY(!m_seatInterface->focusedKeyboardSurface());
QVERIFY(!m_seatInterface->focusedKeyboard());
QVERIFY(!serverKeyboard->focusedSurface());
......
......@@ -121,9 +121,12 @@ void KeyboardInterface::setFocusedSurface(SurfaceInterface *surface, quint32 ser
if (!d->focusedSurface) {
return;
}
d->destroyConnection = connect(d->focusedSurface, &QObject::destroyed, this,
d->destroyConnection = connect(d->focusedSurface, &Resource::aboutToBeUnbound, this,
[this] {
Q_D();
if (d->resource) {
wl_keyboard_send_leave(d->resource, d->global->display()->nextSerial(), d->focusedSurface->resource());
}
d->focusedSurface = nullptr;
d->focusedChildSurface.clear();
}
......
......@@ -63,6 +63,7 @@ void Resource::Private::create(ClientConnection *c, quint32 version, quint32 id)
void Resource::Private::unbind(wl_resource *r)
{
Private *p = cast<Private>(r);
emit p->q->aboutToBeUnbound();
p->resource = nullptr;
emit p->q->unbound();
p->q->deleteLater();
......
......@@ -81,6 +81,16 @@ Q_SIGNALS:
* @since 5.24
**/
void unbound();
/**
* This signal is emitted when the client is in the process of unbinding the Resource.
* In opposite to @link{unbound} the @link{resource} is still valid and allows to perform
* cleanup tasks. Example: send a keyboard leave for the Surface which is in the process of
* getting destroyed.
*
* @see unbound
* @since 5.37
**/
void aboutToBeUnbound();
protected:
class Private;
......
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