Chromium Code Reviews| Index: chrome/common/gtk_util.cc |
| =================================================================== |
| --- chrome/common/gtk_util.cc (revision 23879) |
| +++ chrome/common/gtk_util.cc (working copy) |
| @@ -148,35 +148,14 @@ |
| } |
| gfx::Point GetWidgetScreenPosition(GtkWidget* widget) { |
| - int x = 0, y = 0; |
| + gint x, y; |
| + gdk_window_get_origin(widget->window, &x, &y); |
|
tony
2009/08/21 21:13:39
x & y still get filled in if there's no window? I
Evan Stade
2009/08/21 21:43:42
uh, there should always be a window, right? If the
tony
2009/08/21 21:48:51
If there's always a gdk window, can we add a DCHEC
|
| - if (GTK_IS_WINDOW(widget)) { |
| - gdk_window_get_origin(widget->window, &x, &y); |
| - return gfx::Point(x, y); |
| - } else { |
| - x = widget->allocation.x; |
| - y = widget->allocation.y; |
| + if (!GTK_IS_WINDOW(widget)) { |
| + x += widget->allocation.x; |
| + y += widget->allocation.y; |
| } |
| - GtkWidget* parent = gtk_widget_get_parent(widget); |
| - while (parent) { |
| - if (GTK_IS_WINDOW(parent)) { |
| - int window_x, window_y; |
| - // Returns the origin of the window, excluding the frame if one is exists. |
| - gdk_window_get_origin(parent->window, &window_x, &window_y); |
| - x += window_x; |
| - y += window_y; |
| - return gfx::Point(x, y); |
| - } |
| - |
| - if (!GTK_WIDGET_NO_WINDOW(parent)) { |
| - x += parent->allocation.x; |
| - y += parent->allocation.y; |
| - } |
| - |
| - parent = gtk_widget_get_parent(parent); |
| - } |
| - |
| return gfx::Point(x, y); |
| } |