Author: greg.ercolano
Date: 2013-04-12 09:46:35 -0700 (Fri, 12 Apr 2013)
New Revision: 9875
Log:
Small fixes to new top_window_offset() method as per discussion in STR #2948.
Modified:
branches/branch-1.3/src/Fl_Window.cxx
Modified: branches/branch-1.3/src/Fl_Window.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Window.cxx 2013-04-12 09:52:31 UTC (rev
9874)
+++ branches/branch-1.3/src/Fl_Window.cxx 2013-04-12 16:46:35 UTC (rev
9875)
@@ -107,19 +107,19 @@
}
/**
- 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 */
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit