summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2013-04-08 18:24:17 +0000
committerGreg Ercolano <erco@seriss.com>2013-04-08 18:24:17 +0000
commitd5404dea25123567e9645d3e88a6cd0c14b2073f (patch)
treef0d369b978f9781b7ff52d5507116c091340359a /src
parent2a5d5aab3000c5bc326b314bda144b98d5549633 (diff)
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. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9866 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Gl_Window.cxx6
-rw-r--r--src/Fl_Window.cxx15
2 files changed, 19 insertions, 2 deletions
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index 355865ab1..441dea78a 100644
--- a/src/Fl_Gl_Window.cxx
+++ b/src/Fl_Gl_Window.cxx
@@ -183,8 +183,10 @@ void Fl_Gl_Window::make_current() {
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;
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index 20bb520fd..b6e5985bc 100644
--- a/src/Fl_Window.cxx
+++ b/src/Fl_Window.cxx
@@ -278,6 +278,21 @@ void Fl_Window::icon(const void * ic) {
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$".