Post an error if the client attempts to create input panel surface for surface that already has role

If a client attempts to create an input panel surface for a wl_surface
that already has a role assigned, we must post a protocol error or else
the behavior of the input panel surface will be undefined.

Posting an error of 0 is not really correct, but on the other hand the
spec has no any error enums.
This commit is contained in:
Vlad Zahorodnii 2020-08-21 10:48:49 +03:00
parent 11524da289
commit 7f7a46563b

View file

@ -243,6 +243,13 @@ public:
void zwp_input_panel_v1_get_input_panel_surface(Resource *resource, uint32_t id, struct ::wl_resource *surfaceResource) override
{
auto surface = SurfaceInterface::get(surfaceResource);
SurfaceRole *surfaceRole = SurfaceRole::get(surface);
if (surfaceRole) {
wl_resource_post_error(resource->handle, 0, "the surface already has a role assigned");
return;
}
auto interface = new InputPanelSurfaceV1Interface(surface, id, nullptr);
interface->d->init(resource->client(), id, resource->version());