mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-27 14:00:14 +01:00
desktop-shell: Fail if get_xdg_surface is called on an xdg_surface
If a client calls xdg_shell.get_xdg_surface on a surface that is already an xdg_surface would, prior to this patch, succeed, but cause weston to crash later when trying to configure. This patch instead sends a role error to the client complaining that it already is an xdg_surface. Note that .._set_role() only fails when changing roles, not when setting the same role twice. The same is done for xdg_popup. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
This commit is contained in:
parent
f10e06c77a
commit
bf48e21fa1
1 changed files with 16 additions and 0 deletions
|
|
@ -3978,6 +3978,14 @@ xdg_get_xdg_surface(struct wl_client *client,
|
||||||
struct desktop_shell *shell = sc->shell;
|
struct desktop_shell *shell = sc->shell;
|
||||||
struct shell_surface *shsurf;
|
struct shell_surface *shsurf;
|
||||||
|
|
||||||
|
shsurf = get_shell_surface(surface);
|
||||||
|
if (shsurf && shell_surface_is_xdg_surface(shsurf)) {
|
||||||
|
wl_resource_post_error(resource, XDG_SHELL_ERROR_ROLE,
|
||||||
|
"This wl_surface is already an "
|
||||||
|
"xdg_surface");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (weston_surface_set_role(surface, "xdg_surface",
|
if (weston_surface_set_role(surface, "xdg_surface",
|
||||||
resource, XDG_SHELL_ERROR_ROLE) < 0)
|
resource, XDG_SHELL_ERROR_ROLE) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
@ -4071,6 +4079,14 @@ xdg_get_xdg_popup(struct wl_client *client,
|
||||||
struct weston_surface *parent;
|
struct weston_surface *parent;
|
||||||
struct shell_seat *seat;
|
struct shell_seat *seat;
|
||||||
|
|
||||||
|
shsurf = get_shell_surface(surface);
|
||||||
|
if (shsurf && shell_surface_is_xdg_popup(shsurf)) {
|
||||||
|
wl_resource_post_error(resource, XDG_SHELL_ERROR_ROLE,
|
||||||
|
"This wl_surface is already an "
|
||||||
|
"xdg_popup");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (weston_surface_set_role(surface, "xdg_popup",
|
if (weston_surface_set_role(surface, "xdg_popup",
|
||||||
resource, XDG_SHELL_ERROR_ROLE) < 0)
|
resource, XDG_SHELL_ERROR_ROLE) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue