summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 22:31:45 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 22:31:45 +0000
commitfda8974e0a1daa704be0dc33fe04ae4564310c12 (patch)
tree73e04108913d6c346aa8c866a73a94a60e1b84d3 /chrome/common
parent804a44b4f3d42d486850e35ac1070acee5abf754 (diff)
downloadchromium_src-fda8974e0a1daa704be0dc33fe04ae4564310c12.zip
chromium_src-fda8974e0a1daa704be0dc33fe04ae4564310c12.tar.gz
chromium_src-fda8974e0a1daa704be0dc33fe04ae4564310c12.tar.bz2
Use the convenience function gdk_screen_get_window_stack to enumerate top-level gdk windows instead of querying Xlib directly, which doesn't work across many window managers.
BUG=none TEST=Exhaustive tab dragging in multiple window managers (Compiz, Metacity, KWM). Review URL: http://codereview.chromium.org/119345 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/gtk_util.cc17
-rw-r--r--chrome/common/gtk_util.h13
-rw-r--r--chrome/common/x11_util.cc24
-rw-r--r--chrome/common/x11_util.h12
4 files changed, 35 insertions, 31 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index c3369d9..95fe87b 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -5,6 +5,7 @@
#include "chrome/common/gtk_util.h"
#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
#include "base/linux_util.h"
#include "base/logging.h"
@@ -164,4 +165,20 @@ bool IsScreenComposited() {
return gdk_screen_is_composited(screen) == TRUE;
}
+void EnumerateChildWindows(EnumerateWindowsDelegate* delegate) {
+ GdkScreen* screen = gdk_screen_get_default();
+ GList* stack = gdk_screen_get_window_stack(screen);
+ DCHECK(stack);
+
+ for (GList* iter = g_list_last(stack); iter; iter = iter->prev) {
+ GdkWindow* window = static_cast<GdkWindow*>(iter->data);
+ XID xid = GDK_WINDOW_XID(window);
+ if (delegate->ShouldStopIterating(xid))
+ break;
+ }
+
+ g_list_foreach(stack, (GFunc)g_object_unref, NULL);
+ g_list_free(stack);
+}
+
} // namespace gtk_util
diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h
index 4f42380..52629d3 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -10,6 +10,7 @@
#include "base/gfx/point.h"
#include "base/gfx/rect.h"
+#include "chrome/common/x11_util.h"
#include "webkit/glue/window_open_disposition.h"
typedef struct _GtkWidget GtkWidget;
@@ -79,6 +80,18 @@ 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);
+
} // namespace gtk_util
#endif // CHROME_COMMON_GTK_UTIL_H_
diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc
index b1a24bf..522921f 100644
--- a/chrome/common/x11_util.cc
+++ b/chrome/common/x11_util.cc
@@ -144,34 +144,20 @@ bool IsWindowVisible(XID window) {
}
bool GetWindowRect(XID window, gfx::Rect* rect) {
- Window root_window;
+ Window root, child;
int x, y;
unsigned int width, height;
unsigned int border_width, depth;
- if (!XGetGeometry(GetXDisplay(), window, &root_window, &x, &y,
+ if (!XGetGeometry(GetXDisplay(), window, &root, &x, &y,
&width, &height, &border_width, &depth))
return false;
- *rect = gfx::Rect(x, y, width, height);
- return true;
-}
-
-bool EnumerateChildWindows(XID root, EnumerateWindowsDelegate* delegate) {
- XID parent;
- XID* children;
- unsigned int num_children;
- int status = XQueryTree(GetXDisplay(), root, &root, &parent,
- &children, &num_children);
- if (status == 0)
+ if (!XTranslateCoordinates(GetSecondaryDisplay(), window, root,
+ 0, 0, &x, &y, &child))
return false;
- for (unsigned int i = 0; i < num_children; i++) {
- if (delegate->ShouldStopIterating(children[i]))
- break;
- }
-
- XFree(children);
+ *rect = gfx::Rect(x, y, width, height);
return true;
}
diff --git a/chrome/common/x11_util.h b/chrome/common/x11_util.h
index d177800..012b020 100644
--- a/chrome/common/x11_util.h
+++ b/chrome/common/x11_util.h
@@ -60,18 +60,6 @@ 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 the child windows of |root|.
-bool EnumerateChildWindows(XID root, 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);