summarylogtreecommitdiffstats
path: root/fix-tag-dragging-in-Mutter.patch
blob: 01f2da5782d0c228d4f804f18f070b34bfd0cb69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 3806f28918ea23291749ff4775339075a5f394e8 Mon Sep 17 00:00:00 2001
From: Tom Anderson <thomasanderson@chromium.org>
Date: Thu, 6 Jan 2022 00:59:40 +0000
Subject: [PATCH] [X11] Fix tag dragging in Mutter

We used to use a BFS to find the target window for tag dragging, but
this causes windows underneath (like the window for the desktop
wallpaper) to take precedence over nested windows.

This CL switches to a DFS.

R=sky

Bug: 1279532
Change-Id: Ib569e9270be60bcb4fff088517dfe295697608b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3355470
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/main@{#955976}
---
 ui/platform_window/x11/x11_topmost_window_finder.cc | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/ui/platform_window/x11/x11_topmost_window_finder.cc b/ui/platform_window/x11/x11_topmost_window_finder.cc
index 2e16393487b..e20bf0abf0e 100644
--- a/ui/platform_window/x11/x11_topmost_window_finder.cc
+++ b/ui/platform_window/x11/x11_topmost_window_finder.cc
@@ -44,15 +44,8 @@ bool EnumerateChildren(ShouldStopIteratingCallback should_stop_iterating,
   for (iter = windows.rbegin(); iter != windows.rend(); iter++) {
     if (IsWindowNamed(*iter) && should_stop_iterating.Run(*iter))
       return true;
-  }
-
-  // If we're at this point, we didn't find the window we're looking for at the
-  // current level, so we need to recurse to the next level.  We use a second
-  // loop because the recursion and call to XQueryTree are expensive and is only
-  // needed for a small number of cases.
-  if (++depth <= max_depth) {
-    for (iter = windows.rbegin(); iter != windows.rend(); iter++) {
-      if (EnumerateChildren(should_stop_iterating, *iter, max_depth, depth))
+    if (depth < max_depth) {
+      if (EnumerateChildren(should_stop_iterating, *iter, max_depth, depth + 1))
         return true;
     }
   }