summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/gtk_util.cc9
-rw-r--r--chrome/common/gtk_util.h4
2 files changed, 13 insertions, 0 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index 842b99a..fac62f4 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -568,4 +568,13 @@ void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel) {
}
}
+gfx::Rect GetWidgetRectRelativeToToplevel(GtkWidget* widget) {
+ gint x = 0, y = 0;
+ DCHECK(gtk_widget_translate_coordinates(widget,
+ gtk_widget_get_toplevel(widget),
+ 0, 0,
+ &x, &y));
+ return gfx::Rect(x, y, widget->allocation.width, widget->allocation.height);
+}
+
} // namespace gtk_util
diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h
index 749aade..4f0278a 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -184,6 +184,10 @@ GdkCursor* GetCursor(GdkCursorType type);
// Stacks a |popup| window directly on top of a |toplevel| window.
void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel);
+// Get a rectangle corresponding to a widget's allocation relative to its
+// toplevel window's origin.
+gfx::Rect GetWidgetRectRelativeToToplevel(GtkWidget* widget);
+
} // namespace gtk_util
#endif // CHROME_COMMON_GTK_UTIL_H_