Author: greg.ercolano
Date: 2013-04-08 11:24:17 -0700 (Mon, 08 Apr 2013)
New Revision: 9866
Log:
Fix for STR #2944 [2]: Fix Apple-specifc nested window problem for 
Fl_Gl_Window's.

                       Added new method Fl_Widget::window_offset(x,y)
                       to access the top-level window offset of the current 
widget.

                       Open to alternative names for the new method.



Modified:
   branches/branch-1.3/FL/Fl_Window.H
   branches/branch-1.3/src/Fl_Gl_Window.cxx
   branches/branch-1.3/src/Fl_Window.cxx

Modified: branches/branch-1.3/FL/Fl_Window.H
===================================================================
--- branches/branch-1.3/FL/Fl_Window.H  2013-04-08 16:49:55 UTC (rev 9865)
+++ branches/branch-1.3/FL/Fl_Window.H  2013-04-08 18:24:17 UTC (rev 9866)
@@ -120,6 +120,7 @@
     \see force_position(int)
   */
   int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
+  Fl_Window* window_offset(int& xoff, int& yoff) const;
 
 public:
 

Modified: branches/branch-1.3/src/Fl_Gl_Window.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Gl_Window.cxx    2013-04-08 16:49:55 UTC (rev 
9865)
+++ branches/branch-1.3/src/Fl_Gl_Window.cxx    2013-04-08 18:24:17 UTC (rev 
9866)
@@ -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 = window_offset(xoff, yoff);  // STR #2944 [2]
+    xywh[0] = xoff;
+    xywh[1] = win->h() - yoff - h();
   } else {
     xywh[0] = 0;
     xywh[1] = 0;

Modified: branches/branch-1.3/src/Fl_Window.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Window.cxx       2013-04-08 16:49:55 UTC (rev 
9865)
+++ branches/branch-1.3/src/Fl_Window.cxx       2013-04-08 18:24:17 UTC (rev 
9866)
@@ -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::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
+  }
+  return (Fl_Window*)win;
+}
 
 //
 // End of "$Id$".

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to