DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR Active]
Link: http://www.fltk.org/str.php?L2944
Version: 1.3.2
To fix #2, I'm thinking the attached patch, rasterpos_bugfix.patch,
might be a good way to implement the fix with code reuse in mind.
This adds a find_offset() method to Fl_Widget.. essentially the same code
you provided from Fl_mac.cxx, but made into a method so that
both Fl_mac.cxx + Fl_Gl_Window.cxx can use it.
Funny thing though, I *think* Fl_mac.cxx is completely unused code,
a left over from the de-carbonization of FLTK. (verifying this with
the other devs) In which case the code reuse issue might be moot.
Still, it's probably useful to have this as a method; awaiting info
from the other devs.
Anyway, leaving this alternate patch suggestion to fix just #2 here,
in case I get pulled off on other stuff and forget where I left off.
Link: http://www.fltk.org/str.php?L2944
Version: 1.3.2
Index: src/Fl_Gl_Window.cxx
===================================================================
--- src/Fl_Gl_Window.cxx (revision 9861)
+++ src/Fl_Gl_Window.cxx (working copy)
@@ -183,8 +183,10 @@
GLint xywh[4];
if (window()) {
- xywh[0] = x();
- xywh[1] = window()->h() - y() - h();
+ int xoff,yoff;
+ const Fl_Window *win = find_offset(xoff, yoff); // STR #2944
+ xywh[0] = xoff;
+ xywh[1] = win->h() - yoff - h();
} else {
xywh[0] = 0;
xywh[1] = 0;
Index: src/Fl_Window.cxx
===================================================================
--- src/Fl_Window.cxx (revision 9861)
+++ src/Fl_Window.cxx (working copy)
@@ -278,6 +278,21 @@
icon_ = ic;
}
+/**
+ Finds the x/y offset of the current window relative to the top-level window.
+ \param[out] xoff,yoff Returns the x/y offset
+ \returns the top-level window
+*/
+Fl_Window* Fl_Window::find_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
+ }
+ return (Fl_Window*)win;
+}
//
// End of "$Id$".
Index: FL/Fl_Window.H
===================================================================
--- FL/Fl_Window.H (revision 9861)
+++ FL/Fl_Window.H (working copy)
@@ -120,6 +120,7 @@
\see force_position(int)
*/
int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
+ Fl_Window* find_offset(int& xoff, int& yoff) const;
public:
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs