desktop-shell: Require a popup parent to be a shell surface

Currently, the shell crashes if the parent is not a shell surface. Instead,
send an error to the client.

Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
dev
Dima Ryazanov 10 years ago committed by Pekka Paalanen
parent 6d11679843
commit 497f25de57
  1. 12
      desktop-shell/shell.c

@ -3393,7 +3393,8 @@ add_popup_grab(struct shell_surface *shsurf,
parent = get_shell_surface(shsurf->parent); parent = get_shell_surface(shsurf->parent);
top_surface = get_top_popup(shseat); top_surface = get_top_popup(shseat);
if (shell_surface_is_xdg_popup(shsurf) && if (shell_surface_is_xdg_popup(shsurf) &&
((top_surface == NULL && !shell_surface_is_xdg_surface(parent)) || (!parent ||
(top_surface == NULL && !shell_surface_is_xdg_surface(parent)) ||
(top_surface != NULL && parent != top_surface))) { (top_surface != NULL && parent != top_surface))) {
wl_resource_post_error(shsurf->owner->resource, wl_resource_post_error(shsurf->owner->resource,
XDG_POPUP_ERROR_NOT_THE_TOPMOST_POPUP, XDG_POPUP_ERROR_NOT_THE_TOPMOST_POPUP,
@ -4098,13 +4099,14 @@ create_xdg_popup(struct shell_client *owner, void *shell,
{ {
struct shell_surface *shsurf, *parent_shsurf; struct shell_surface *shsurf, *parent_shsurf;
/* Verify that we are creating the top most popup when mapping, /* Verify that we are creating the topmost popup when mapping,
* as its not until then we know whether it was mapped as most * as it's not until then we know whether it was mapped as most
* top level or not. */ * top level or not. */
parent_shsurf = get_shell_surface(parent); parent_shsurf = get_shell_surface(parent);
if (!shell_surface_is_xdg_popup(parent_shsurf) && if (!parent_shsurf ||
!shell_surface_is_xdg_surface(parent_shsurf)) { (!shell_surface_is_xdg_popup(parent_shsurf) &&
!shell_surface_is_xdg_surface(parent_shsurf))) {
wl_resource_post_error(owner->resource, wl_resource_post_error(owner->resource,
XDG_POPUP_ERROR_INVALID_PARENT, XDG_POPUP_ERROR_INVALID_PARENT,
"xdg_popup parent was invalid"); "xdg_popup parent was invalid");

Loading…
Cancel
Save