Commit 9266a944 authored by Martin Flöser's avatar Martin Flöser
Browse files

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

This is a change inspired by
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:
parent 464ba183
......@@ -1563,7 +1563,8 @@ void TestWaylandSeat::testKeyboard()
QSignalSpy serverSurfaceDestroyedSpy(serverSurface, &QObject::destroyed);
delete s;
QCOMPARE(serverSurfaceDestroyedSpy.count(), 1);
......@@ -121,9 +121,12 @@ void KeyboardInterface::setFocusedSurface(SurfaceInterface *surface, quint32 ser
if (!d->focusedSurface) {
d->destroyConnection = connect(d->focusedSurface, &QObject::destroyed, this,
d->destroyConnection = connect(d->focusedSurface, &Resource::aboutToBeUnbound, this,
[this] {
if (d->resource) {
wl_keyboard_send_leave(d->resource, d->global->display()->nextSerial(), d->focusedSurface->resource());
d->focusedSurface = nullptr;
......@@ -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();
......@@ -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();
class Private;
Supports Markdown
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