Small fixes to new top_window_offset() method as per discussion in STR #2948.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9875 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Greg Ercolano 2013-04-12 16:46:35 +00:00
parent 55af432c2c
commit f04ff44f8c

View File

@ -107,19 +107,19 @@ Fl_Window *Fl_Widget::top_window() const {
}
/**
Finds the x/y offset of the current window relative to the top-level window.
Finds the x/y offset of the current widget relative to the top-level window.
\param[out] xoff,yoff Returns the x/y offset
\returns the top-level window
\returns the top-level window (or NULL for a widget that's not in any window)
*/
Fl_Window* Fl_Widget::top_window_offset(int& xoff, int& yoff) const {
xoff = yoff = 0;
const Fl_Window *win = (const Fl_Window*)this;
while (win && win->window()) {
xoff += win->x(); // accumulate offsets
yoff += win->y();
win = win->window(); // walk up window hierarchy
const Fl_Widget *w = this;
while (w && w->window()) {
xoff += w->x(); // accumulate offsets
yoff += w->y();
w = w->window(); // walk up window hierarchy
}
return (Fl_Window*)win;
return ((Fl_Widget*)w)->as_window();
}
/** Gets the x position of the window on the screen */