283d9cd
From b5c62ae463101712a2ed91e976b28af5d1e73064 Mon Sep 17 00:00:00 2001
283d9cd
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <mdaenzer@redhat.com>
283d9cd
Date: Fri, 6 Nov 2020 10:14:19 +0100
283d9cd
Subject: [PATCH xserver 25/25] xwayland: Make window_get_client_toplevel
283d9cd
 non-recursive
283d9cd
283d9cd
Noticed while reading the code.
283d9cd
283d9cd
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
283d9cd
(cherry picked from commit df3aa4922fd7e256169e541188b724f67ca948e1)
283d9cd
---
283d9cd
 hw/xwayland/xwayland.c | 8 ++++----
283d9cd
 1 file changed, 4 insertions(+), 4 deletions(-)
283d9cd
283d9cd
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
283d9cd
index 1600c00cd..a5756ea14 100644
283d9cd
--- a/hw/xwayland/xwayland.c
283d9cd
+++ b/hw/xwayland/xwayland.c
283d9cd
@@ -578,11 +578,11 @@ window_get_client_toplevel(WindowPtr window)
283d9cd
      * decoration/wrapper windows. In that case recurse by checking the client
283d9cd
      * of the first *and only* child of the decoration/wrapper window.
283d9cd
      */
283d9cd
-    if (window_is_wm_window(window)) {
283d9cd
-        if (window->firstChild && window->firstChild == window->lastChild)
283d9cd
-            return window_get_client_toplevel(window->firstChild);
283d9cd
-        else
283d9cd
+    while (window_is_wm_window(window)) {
283d9cd
+        if (!window->firstChild || window->firstChild != window->lastChild)
283d9cd
             return NULL; /* Should never happen, skip resolution emulation */
283d9cd
+
283d9cd
+        window = window->firstChild;
283d9cd
     }
283d9cd
 
283d9cd
     return window;
283d9cd
-- 
283d9cd
2.28.0
283d9cd