This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch wl/browser-all
in repository enlightenment.

View the commit online.

commit 8e81bc6137685005ff18e11468d645335709c5a6
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Aug 9 10:46:57 2026 -0600

    wl_desktop_shell - reject an xdg_toplevel parented to its own descendant
    
    xdg_toplevel.set_parent says:
    
      The parent toplevel must not be one of the child toplevel's
      descendants, and the parent must be different from the child
      toplevel, otherwise the invalid_parent protocol error is raised.
    
    E accepted both. Building a cycle that way leaves every later walk of
    the transient chain - restacking, focus, iconify - spinning forever, so
    this is not only a missing diagnostic.
    
    Walking up from the proposed parent covers both halves of the rule at
    once: arriving at the client means it is an ancestor of the parent, so
    the parent is one of its descendants, and the zero-step case of that is
    parent == self.
    
    Only xdg_shell stable. zxdg_toplevel_v6 has no error enum and states no
    rule about descendants, so there is nothing to raise there and xdg6.c is
    left alone.
    
    wlcs: XdgToplevelStableTest.when_parent_is_set_to_self_error_is_raised
    and .when_parent_is_set_to_child_descendant_error_is_raised now pass;
    parent_can_be_set and null_parent_can_be_set still do.
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
    Claude-Session: https://claude.ai/code/session_01FtoiXoSKUmZb6Aix6U3GZS
---
 src/modules/wl_desktop_shell/xdg.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/modules/wl_desktop_shell/xdg.c b/src/modules/wl_desktop_shell/xdg.c
index 2f36f5937..a7e38deb8 100644
--- a/src/modules/wl_desktop_shell/xdg.c
+++ b/src/modules/wl_desktop_shell/xdg.c
@@ -1017,7 +1017,7 @@ _e_xdg_toplevel_cb_destroy(struct wl_client *client EINA_UNUSED, struct wl_resou
 static void
 _e_xdg_toplevel_cb_parent_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource, struct wl_resource *parent_resource)
 {
-   E_Client *ec;
+   E_Client *ec, *pc;
 
    if (!(ec = wl_resource_get_user_data(resource)))
      {
@@ -1027,6 +1027,26 @@ _e_xdg_toplevel_cb_parent_set(struct wl_client *client EINA_UNUSED, struct wl_re
      }
    if (e_object_is_del(E_OBJECT(ec))) return;
 
+   /* "The parent toplevel must not be one of the child toplevel's
+    * descendants, and the parent must be different from the child toplevel,
+    * otherwise the invalid_parent protocol error is raised."
+    *   - xdg-shell.xml, xdg_toplevel.set_parent
+    *
+    * Walking up from the proposed parent covers both halves: arriving at ec
+    * means ec is an ancestor of the parent, so the parent is one of ec's
+    * descendants, and the zero-step case of that is parent == ec. Without
+    * this a client can build a cycle, and every later walk of the transient
+    * chain spins forever. */
+   for (pc = parent_resource ? wl_resource_get_user_data(parent_resource) : NULL;
+        pc; pc = pc->parent)
+     {
+        if (pc != ec) continue;
+        wl_resource_post_error(resource, XDG_TOPLEVEL_ERROR_INVALID_PARENT,
+                               "xdg_toplevel@%u cannot be its own descendant",
+                               wl_resource_get_id(resource));
+        return;
+     }
+
    /* set this client as a transient for parent */
    e_shell_surface_parent_set(ec, parent_resource);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to