Fix testError

testError expects that the compositor will post a protocol error if the
client tries to create several plasma shell surfaces for the same wayland
surface.
This commit is contained in:
Vlad Zahorodnii 2021-03-15 10:47:47 +02:00
parent 8c32edcd12
commit a60ed431f1

View file

@ -21,6 +21,7 @@ class PlasmaShellInterfacePrivate : public QtWaylandServer::org_kde_plasma_shell
public:
PlasmaShellInterfacePrivate(PlasmaShellInterface *q, Display *display);
QList<PlasmaShellSurfaceInterface *> shellSurfaces;
private:
void org_kde_plasma_shell_get_surface(Resource * resource, uint32_t id, struct ::wl_resource *surface) override;
@ -77,9 +78,24 @@ void PlasmaShellInterfacePrivate::org_kde_plasma_shell_get_surface(QtWaylandServ
wl_resource_post_error(resource->handle, 0, "Invalid surface");
return;
}
auto it = std::find_if(shellSurfaces.constBegin(), shellSurfaces.constEnd(), [&s](PlasmaShellSurfaceInterface *shellSurface) {
return shellSurface->surface() == s;
});
if (it != shellSurfaces.constEnd()) {
wl_resource_post_error(resource->handle, 0, "org_kde_plasma_shell_surface already exists");
return;
}
wl_resource *shell_resource = wl_resource_create(resource->client(), &org_kde_plasma_surface_interface, resource->version(), id);
auto shellSurface = new PlasmaShellSurfaceInterface(s, shell_resource);
shellSurfaces.append(shellSurface);
QObject::connect(shellSurface, &QObject::destroyed, q, [this, shellSurface]() {
shellSurfaces.removeOne(shellSurface);
});
emit q->surfaceCreated(shellSurface);
}