From 7f7a46563bbf3c7ab0e41897a4f6bc38b82b7c6e Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 21 Aug 2020 10:48:49 +0300 Subject: [PATCH] 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. --- src/wayland/inputmethod_v1_interface.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wayland/inputmethod_v1_interface.cpp b/src/wayland/inputmethod_v1_interface.cpp index 98132b0b75..63575d3caa 100644 --- a/src/wayland/inputmethod_v1_interface.cpp +++ b/src/wayland/inputmethod_v1_interface.cpp @@ -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());