From f04ff44f8c24a8ab6c774c811ee7a707ecca3552 Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Fri, 12 Apr 2013 16:46:35 +0000 Subject: 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 --- src/Fl_Window.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index a3e0200b6..b9860976a 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -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 */ -- cgit v1.2.3