Mac OS X: added checks that subwindows do not leak out of

enclosing window when they are programmatically resized or moved.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10899 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2015-11-10 06:39:37 +00:00
parent f00901534a
commit 68f3cc6d88

View File

@ -724,10 +724,13 @@ void Fl::remove_timeout(Fl_Timeout_Handler cb, void* data)
if (!parent) return; if (!parent) return;
FLWindow *pxid = fl_xid(parent); FLWindow *pxid = fl_xid(parent);
if (!pxid) return; if (!pxid) return;
NSRect rp = [pxid frame]; int bx = w->x(); int by = w->y();
// subwindow coordinates are in screen units from bottom just like all windows while (parent) {
rp.origin = NSMakePoint(rp.origin.x + w->x(), rp.origin.y + parent->h() - w->y() - w->h()); bx += parent->x();
rp.size = NSMakeSize(w->w(), w->h()); by += parent->y();
parent = parent->window();
}
NSRect rp = NSMakeRect(bx, main_screen_height - (by + w->h()), w->w(), w->h());
if (!NSEqualRects(rp, [self frame])) { if (!NSEqualRects(rp, [self frame])) {
[self setFrame:rp display:YES]; [self setFrame:rp display:YES];
} }
@ -3231,6 +3234,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
} }
NSRect r = NSMakeRect(bx, main_screen_height - (by + H), W, H + (border()?bt:0)); NSRect r = NSMakeRect(bx, main_screen_height - (by + H), W, H + (border()?bt:0));
[fl_xid(this) setFrame:r display:YES]; [fl_xid(this) setFrame:r display:YES];
[fl_xid(this) recursivelySendToSubwindows:@selector(checkSubwindowFrame)];
} else { } else {
bx = X; by = Y; bx = X; by = Y;
parent = window(); parent = window();
@ -3241,6 +3245,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
} }
NSPoint pt = NSMakePoint(bx, main_screen_height - (by + H)); NSPoint pt = NSMakePoint(bx, main_screen_height - (by + H));
[fl_xid(this) setFrameOrigin:pt]; // set cocoa coords to FLTK position [fl_xid(this) setFrameOrigin:pt]; // set cocoa coords to FLTK position
[fl_xid(this) recursivelySendToSubwindows:@selector(checkSubwindowFrame)];
} }
} }
else { else {