void GetWidgetScreenPos (Gtk.Widget widget, ref int x, ref int y)
{
int widget_x;
int widget_y;
if (widget is Gtk.Window) {
((Gtk.Window) widget).GetPosition (out widget_x, out widget_y);
} else {
GetWidgetScreenPos (widget.Parent, ref x, ref y);
// Special case the TreeView because it adds
// too much since it's in a scrolled window.
if (widget == tree) {
widget_x = 2;
widget_y = 2;
} else {
Gdk.Rectangle widget_rect = widget.Allocation;
widget_x = widget_rect.X;
widget_y = widget_rect.Y;
}
}
x += widget_x;
y += widget_y;
}