winemac: Override -[NSOpenGLContext clearDrawable] to not hide the GL surface.

This fixes a problem with flickering when repeatedly attaching and detaching
a GL context from a window, such as for each WM_PAINT.
This commit is contained in:
Ken Thomases 2013-03-10 17:38:30 -05:00 committed by Alexandre Julliard
parent 89a4e5a6d1
commit 4d51a688e3
1 changed files with 25 additions and 0 deletions

View File

@ -38,6 +38,31 @@ - (void) dealloc
[super dealloc];
}
/* On at least some versions of Mac OS X, -[NSOpenGLContext clearDrawable] has the
undesirable side effect of ordering the view's GL surface off-screen. This isn't
done when just changing the context's view to a different view (which I would
think would be analogous, since the old view and surface end up without a
context attached). So, we finesse things by first setting the context's view to
a different view (the content view of an off-screen window) and then letting the
original implementation proceed. */
- (void) clearDrawable
{
static NSWindow* dummyWindow;
static dispatch_once_t once;
dispatch_once(&once, ^{
OnMainThread(^{
dummyWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100)
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO];
});
});
[self setView:[dummyWindow contentView]];
[super clearDrawable];
}
@end