Commit 2128125c authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Reattach OpenGL contexts to a view after it has been hidden and unhidden.

Hiding a view seems to semi-detach any attached OpenGL contexts such that rendering no longer works. There's no GL surface for the view. Calling -[NSOpenGLContext update] is not sufficient to reattach the context. So, fully detach the contexts and reattach them. Signed-off-by: 's avatarKen Thomases <ken@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent c95d2de3
......@@ -25,12 +25,14 @@
{
NSView* latentView;
BOOL needsUpdate;
BOOL needsReattach;
BOOL shouldClearToBlack;
GLint backing_size[2];
}
@property BOOL needsUpdate;
@property BOOL needsReattach;
@property BOOL shouldClearToBlack;
@end
......@@ -35,7 +35,7 @@
@implementation WineOpenGLContext
@synthesize latentView, needsUpdate, shouldClearToBlack;
@synthesize latentView, needsUpdate, needsReattach, shouldClearToBlack;
- (void) dealloc
{
......@@ -215,6 +215,7 @@
[self setLatentView:nil];
}
needsUpdate = FALSE;
needsReattach = FALSE;
}
@end
......@@ -279,6 +280,7 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect
if (context.needsUpdate)
{
context.needsUpdate = FALSE;
context.needsReattach = FALSE;
if (context.view)
[context setView:[[context class] dummyView]];
[context wine_updateBackingSize:&r.size];
......@@ -328,7 +330,9 @@ void macdrv_update_opengl_context(macdrv_opengl_context c)
if (context.needsUpdate)
{
BOOL reattach = context.needsReattach;
context.needsUpdate = FALSE;
context.needsReattach = FALSE;
if (context.latentView)
{
[context setView:context.latentView];
......@@ -339,7 +343,14 @@ void macdrv_update_opengl_context(macdrv_opengl_context c)
}
else
{
[context update];
if (reattach)
{
NSView* view = [[context.view retain] autorelease];
[context clearDrawableLeavingSurfaceOnScreen];
context.view = view;
}
else
[context update];
[context resetSurfaceIfBackingSizeChanged];
}
}
......
......@@ -500,10 +500,19 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
[(WineWindow*)[self window] updateForGLSubviews];
}
- (void) updateGLContexts
- (void) updateGLContexts:(BOOL)reattach
{
for (WineOpenGLContext* context in glContexts)
{
context.needsUpdate = TRUE;
if (reattach)
context.needsReattach = TRUE;
}
}
- (void) updateGLContexts
{
[self updateGLContexts:NO];
}
- (BOOL) hasGLContext
......@@ -605,6 +614,23 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
return NO;
}
- (void) viewDidHide
{
[super viewDidHide];
if ([self hasGLContext])
[self invalidateHasGLDescendant];
}
- (void) viewDidUnhide
{
[super viewDidUnhide];
if ([self hasGLContext])
{
[self updateGLContexts:YES];
[self invalidateHasGLDescendant];
}
}
- (void) completeText:(NSString*)text
{
macdrv_event* event;
......@@ -651,12 +677,6 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
[super willRemoveSubview:subview];
}
- (void) setHidden:(BOOL)hidden
{
[super setHidden:hidden];
[self invalidateHasGLDescendant];
}
/*
* ---------- NSTextInputClient methods ----------
*/
......@@ -3432,6 +3452,7 @@ void macdrv_set_view_hidden(macdrv_view v, int hidden)
OnMainThreadAsync(^{
[view setHidden:hidden];
[(WineWindow*)view.window updateForGLSubviews];
});
[pool release];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment