diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:08:48 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-18 21:08:48 +0000 |
commit | 43b7725b6686228f86ef1306703e6dade09dcc27 (patch) | |
tree | 638b550d39cc864af5c470f0259c7fe99671435c /chrome/common/gtk_util.cc | |
parent | 606d7469d6da2cc63a7188b75059bd6e5fe1f82f (diff) | |
download | chromium_src-43b7725b6686228f86ef1306703e6dade09dcc27.zip chromium_src-43b7725b6686228f86ef1306703e6dade09dcc27.tar.gz chromium_src-43b7725b6686228f86ef1306703e6dade09dcc27.tar.bz2 |
Implement DraggedTabGtk, the object that handles rendering either a dragged tab or tab contents during a tab drag.
Review URL: http://codereview.chromium.org/113532
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16310 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/gtk_util.cc')
-rw-r--r-- | chrome/common/gtk_util.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc index f0d5ea1..ef5d689 100644 --- a/chrome/common/gtk_util.cc +++ b/chrome/common/gtk_util.cc @@ -54,4 +54,31 @@ void RemoveAllChildren(GtkWidget* container) { gtk_container_foreach(GTK_CONTAINER(container), RemoveWidget, container); } +gfx::Point GetWidgetScreenPosition(GtkWidget* widget) { + int x = 0, y = 0; + + GtkWidget* parent = widget; + while (parent) { + if (GTK_IS_WINDOW(parent)) { + int window_x, window_y; + gtk_window_get_position(GTK_WINDOW(parent), &window_x, &window_y); + x += window_x; + y += window_y; + return gfx::Point(x, y); + } + + x += parent->allocation.x; + y += parent->allocation.y; + parent = gtk_widget_get_parent(parent); + } + + return gfx::Point(x, y); +} + +gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) { + gfx::Point position = GetWidgetScreenPosition(widget); + return gfx::Rect(position.x(), position.y(), + widget->allocation.width, widget->allocation.height); +} + } // namespace gtk_util |