From 71ed0752fb0a6454226370a3ad2ed70637cfc290 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sat, 12 Mar 2016 05:35:40 +0000 Subject: [PATCH] Fix minor default in Fl_Window::wait_for_expose() under Mac OS. If the exposed window contains a sub-window the sub-window can disappear after having been drawn. This can be seen with the device demo completed with a wait_for_expose() call just after the main window show(). The fix applies wait_for_expose() recursively for all subwindows. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@11352 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 42476a526..a4f27db88 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -649,6 +649,7 @@ void Fl::remove_timeout(Fl_Timeout_Handler cb, void* data) - (void)recursivelySendToSubwindows:(SEL)sel; - (void)setSubwindowFrame; - (void)checkSubwindowFrame; +- (void)waitForExpose; - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - (NSPoint)convertBaseToScreen:(NSPoint)aPoint; @@ -769,6 +770,16 @@ void Fl::remove_timeout(Fl_Timeout_Handler cb, void* data) } } +-(void)waitForExpose +{ + if ([self getFl_Window]->shown()) { + // this makes freshly created windows appear on the screen, if they are not there already + NSModalSession session = [NSApp beginModalSessionForWindow:self]; + [NSApp runModalSession:session]; + [NSApp endModalSession:session]; + } +} + /* With Mac OS 10.11 the green window button makes window fullscreen (covers system menu bar and dock). When there are subwindows, they are by default constrained not to cover the menu bar (this is arguably a Mac OS bug). @@ -3130,12 +3141,7 @@ void Fl_Window::size_range_() { void Fl_Window::wait_for_expose() { - if (shown()) { - // this makes freshly created windows appear on the screen, if they are not there already - NSModalSession session = [NSApp beginModalSessionForWindow:i->xid]; - [NSApp runModalSession:session]; - [NSApp endModalSession:session]; - } + [fl_xid(this) recursivelySendToSubwindows:@selector(waitForExpose)]; } /*