summaryrefslogtreecommitdiffstats
path: root/chrome/common/x11_util.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 23:31:11 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 23:31:11 +0000
commit5d365bd6cc0b12e8baa33cdb6055435ca80d1e7b (patch)
tree9c927e9ada5dabd27d3a8d0a5b810effff8b76f2 /chrome/common/x11_util.cc
parentb81bf79682de74928c3a5be68ed9802f9717c5a9 (diff)
downloadchromium_src-5d365bd6cc0b12e8baa33cdb6055435ca80d1e7b.zip
chromium_src-5d365bd6cc0b12e8baa33cdb6055435ca80d1e7b.tar.gz
chromium_src-5d365bd6cc0b12e8baa33cdb6055435ca80d1e7b.tar.bz2
gtk: Implement and use x11_util::GetXWindowStack, which is a less flaky and faster version of gdk_screen_get_window_stack. The latter was not consistently returning our browser windows in the window stack.
BUG=none TEST=Extensive tab dragging. Review URL: http://codereview.chromium.org/179056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25112 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/x11_util.cc')
-rw-r--r--chrome/common/x11_util.cc51
1 files changed, 45 insertions, 6 deletions
diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc
index 1305fe1..0921c6e 100644
--- a/chrome/common/x11_util.cc
+++ b/chrome/common/x11_util.cc
@@ -8,8 +8,6 @@
#include "chrome/common/x11_util.h"
-#include <string.h>
-
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
@@ -276,10 +274,11 @@ bool EnumerateChildren(EnumerateWindowsDelegate* delegate, XID window,
// 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.
- depth++;
- for (iter = windows.rbegin(); iter != windows.rend(); iter++) {
- if (EnumerateChildren(delegate, *iter, max_depth, depth))
- return true;
+ if (++depth <= max_depth) {
+ for (iter = windows.rbegin(); iter != windows.rend(); iter++) {
+ if (EnumerateChildren(delegate, *iter, max_depth, depth))
+ return true;
+ }
}
return false;
@@ -290,6 +289,46 @@ bool EnumerateAllWindows(EnumerateWindowsDelegate* delegate, int max_depth) {
return EnumerateChildren(delegate, root, max_depth, 0);
}
+bool GetXWindowStack(std::vector<XID>* windows) {
+ windows->clear();
+
+ static Atom atom = XInternAtom(GetXDisplay(),
+ "_NET_CLIENT_LIST_STACKING", False);
+
+ Atom type;
+ int format;
+ unsigned long count;
+ unsigned long bytes_after;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(GetXDisplay(),
+ GetX11RootWindow(),
+ atom,
+ 0, // offset
+ ~0L, // length
+ False, // delete
+ AnyPropertyType, // requested type
+ &type,
+ &format,
+ &count,
+ &bytes_after,
+ &data) != Success) {
+ return false;
+ }
+
+ bool result = false;
+ if (type == XA_WINDOW && format == 32 && data && count > 0) {
+ result = true;
+ XID* stack = reinterpret_cast<XID*>(data);
+ for (unsigned long i = 0; i < count; i++)
+ windows->insert(windows->begin(), stack[i]);
+ }
+
+ if (data)
+ XFree(data);
+
+ return result;
+}
+
XRenderPictFormat* GetRenderVisualFormat(Display* dpy, Visual* visual) {
static XRenderPictFormat* pictformat = NULL;
if (pictformat)