summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 20:34:35 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 20:34:35 +0000
commit5a639de2090282a219922cc5799116919320cb18 (patch)
tree214ba732b21b34cda0b62bffec556d39dfb73ca6
parent8d1523ab7ad36c8a4f5c9bffd110caeffcdc04be (diff)
downloadchromium_src-5a639de2090282a219922cc5799116919320cb18.zip
chromium_src-5a639de2090282a219922cc5799116919320cb18.tar.gz
chromium_src-5a639de2090282a219922cc5799116919320cb18.tar.bz2
Revert to enumerating all X windows if the Window Manager doesn't support _NET_CLIENT_LIST_STACKING.
BUG=14004 TEST=Drag tabs in and out of tabstrip in xmonad window manager. Review URL: http://codereview.chromium.org/141061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18949 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dock_info_gtk.cc6
-rw-r--r--chrome/common/gtk_util.cc9
-rw-r--r--chrome/common/gtk_util.h11
-rw-r--r--chrome/common/x11_util.cc19
-rw-r--r--chrome/common/x11_util.h12
5 files changed, 42 insertions, 15 deletions
diff --git a/chrome/browser/dock_info_gtk.cc b/chrome/browser/dock_info_gtk.cc
index c54e4ba..403b65d 100644
--- a/chrome/browser/dock_info_gtk.cc
+++ b/chrome/browser/dock_info_gtk.cc
@@ -19,7 +19,7 @@
//
// Base class used to locate a window. A subclass need only override
// ShouldStopIterating to determine when iteration should stop.
-class BaseWindowFinder : public gtk_util::EnumerateWindowsDelegate {
+class BaseWindowFinder : public x11_util::EnumerateWindowsDelegate {
public:
explicit BaseWindowFinder(const std::set<GtkWidget*>& ignore) {
std::set<GtkWidget*>::iterator iter;
@@ -100,7 +100,7 @@ class TopMostFinder : public BaseWindowFinder {
target_(window),
screen_loc_(screen_loc),
is_top_most_(false) {
- gtk_util::EnumerateChildWindows(this);
+ gtk_util::EnumerateTopLevelWindows(this);
}
// The window we're looking for.
@@ -163,7 +163,7 @@ class LocalProcessWindowFinder : public BaseWindowFinder {
: BaseWindowFinder(ignore),
screen_loc_(screen_loc),
result_(0) {
- gtk_util::EnumerateChildWindows(this);
+ gtk_util::EnumerateTopLevelWindows(this);
}
// Position of the mouse.
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index 4c9f052..f89d5a8 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -216,10 +216,15 @@ bool IsScreenComposited() {
return gdk_screen_is_composited(screen) == TRUE;
}
-void EnumerateChildWindows(EnumerateWindowsDelegate* delegate) {
+void EnumerateTopLevelWindows(x11_util::EnumerateWindowsDelegate* delegate) {
GdkScreen* screen = gdk_screen_get_default();
GList* stack = gdk_screen_get_window_stack(screen);
- DCHECK(stack);
+ if (!stack) {
+ // Window Manager doesn't support _NET_CLIENT_LIST_STACKING, so fall back
+ // to old school enumeration of all X windows.
+ x11_util::EnumerateAllWindows(delegate);
+ return;
+ }
for (GList* iter = g_list_last(stack); iter; iter = iter->prev) {
GdkWindow* window = static_cast<GdkWindow*>(iter->data);
diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h
index b996c07..2f38092 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -88,17 +88,8 @@ std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label);
// Returns true if the screen is composited, false otherwise.
bool IsScreenComposited();
-// Implementers of this interface receive a notification for every top-level
-// gdk window of the current display.
-class EnumerateWindowsDelegate {
- public:
- // |xid| is the X Window ID of the enumerated window. Return true to stop
- // further iteration.
- virtual bool ShouldStopIterating(XID xid) = 0;
-};
-
// Enumerates the top-level gdk windows of the current display.
-void EnumerateChildWindows(EnumerateWindowsDelegate* delegate);
+void EnumerateTopLevelWindows(x11_util::EnumerateWindowsDelegate* delegate);
// Set that a button causes a page navigation. In particular, it will accept
// middle clicks. Warning: only call this *after* you have connected your
diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc
index 522921f..da3eb7d 100644
--- a/chrome/common/x11_util.cc
+++ b/chrome/common/x11_util.cc
@@ -161,6 +161,25 @@ bool GetWindowRect(XID window, gfx::Rect* rect) {
return true;
}
+bool EnumerateAllWindows(EnumerateWindowsDelegate* delegate) {
+ XID root = GetX11RootWindow();
+ XID parent;
+ XID* children;
+ unsigned int num_children;
+ int status = XQueryTree(GetXDisplay(), root, &root, &parent,
+ &children, &num_children);
+ if (status == 0)
+ return false;
+
+ for (unsigned int i = 0; i < num_children; i++) {
+ if (delegate->ShouldStopIterating(children[i]))
+ break;
+ }
+
+ XFree(children);
+ return true;
+}
+
XRenderPictFormat* GetRenderVisualFormat(Display* dpy, Visual* visual) {
static XRenderPictFormat* pictformat = NULL;
if (pictformat)
diff --git a/chrome/common/x11_util.h b/chrome/common/x11_util.h
index 012b020..bcf0d0a 100644
--- a/chrome/common/x11_util.h
+++ b/chrome/common/x11_util.h
@@ -60,6 +60,18 @@ bool IsWindowVisible(XID window);
// Returns the bounds of |window|.
bool GetWindowRect(XID window, gfx::Rect* rect);
+// Implementers of this interface receive a notification for every X window of
+// the main display.
+class EnumerateWindowsDelegate {
+ public:
+ // |xid| is the X Window ID of the enumerated window. Return true to stop
+ // further iteration.
+ virtual bool ShouldStopIterating(XID xid) = 0;
+};
+
+// Enumerates all windows in the current display
+bool EnumerateAllWindows(EnumerateWindowsDelegate* delegate);
+
// Return a handle to a server side pixmap. |shared_memory_key| is a SysV
// IPC key. The shared memory region must contain 32-bit pixels.
XID AttachSharedMemory(Display* display, int shared_memory_support);