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 @@ ...@@ -25,12 +25,14 @@
{ {
NSView* latentView; NSView* latentView;
BOOL needsUpdate; BOOL needsUpdate;
BOOL needsReattach;
BOOL shouldClearToBlack; BOOL shouldClearToBlack;
GLint backing_size[2]; GLint backing_size[2];
} }
@property BOOL needsUpdate; @property BOOL needsUpdate;
@property BOOL needsReattach;
@property BOOL shouldClearToBlack; @property BOOL shouldClearToBlack;
@end @end
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
@implementation WineOpenGLContext @implementation WineOpenGLContext
@synthesize latentView, needsUpdate, shouldClearToBlack; @synthesize latentView, needsUpdate, needsReattach, shouldClearToBlack;
- (void) dealloc - (void) dealloc
{ {
...@@ -215,6 +215,7 @@ ...@@ -215,6 +215,7 @@
[self setLatentView:nil]; [self setLatentView:nil];
} }
needsUpdate = FALSE; needsUpdate = FALSE;
needsReattach = FALSE;
} }
@end @end
...@@ -279,6 +280,7 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect ...@@ -279,6 +280,7 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect
if (context.needsUpdate) if (context.needsUpdate)
{ {
context.needsUpdate = FALSE; context.needsUpdate = FALSE;
context.needsReattach = FALSE;
if (context.view) if (context.view)
[context setView:[[context class] dummyView]]; [context setView:[[context class] dummyView]];
[context wine_updateBackingSize:&r.size]; [context wine_updateBackingSize:&r.size];
...@@ -328,7 +330,9 @@ void macdrv_update_opengl_context(macdrv_opengl_context c) ...@@ -328,7 +330,9 @@ void macdrv_update_opengl_context(macdrv_opengl_context c)
if (context.needsUpdate) if (context.needsUpdate)
{ {
BOOL reattach = context.needsReattach;
context.needsUpdate = FALSE; context.needsUpdate = FALSE;
context.needsReattach = FALSE;
if (context.latentView) if (context.latentView)
{ {
[context setView:context.latentView]; [context setView:context.latentView];
...@@ -339,7 +343,14 @@ void macdrv_update_opengl_context(macdrv_opengl_context c) ...@@ -339,7 +343,14 @@ void macdrv_update_opengl_context(macdrv_opengl_context c)
} }
else else
{ {
[context update]; if (reattach)
{
NSView* view = [[context.view retain] autorelease];
[context clearDrawableLeavingSurfaceOnScreen];
context.view = view;
}
else
[context update];
[context resetSurfaceIfBackingSizeChanged]; [context resetSurfaceIfBackingSizeChanged];
} }
} }
......
...@@ -500,10 +500,19 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -500,10 +500,19 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
[(WineWindow*)[self window] updateForGLSubviews]; [(WineWindow*)[self window] updateForGLSubviews];
} }
- (void) updateGLContexts - (void) updateGLContexts:(BOOL)reattach
{ {
for (WineOpenGLContext* context in glContexts) for (WineOpenGLContext* context in glContexts)
{
context.needsUpdate = TRUE; context.needsUpdate = TRUE;
if (reattach)
context.needsReattach = TRUE;
}
}
- (void) updateGLContexts
{
[self updateGLContexts:NO];
} }
- (BOOL) hasGLContext - (BOOL) hasGLContext
...@@ -605,6 +614,23 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -605,6 +614,23 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
return NO; 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 - (void) completeText:(NSString*)text
{ {
macdrv_event* event; macdrv_event* event;
...@@ -651,12 +677,6 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi ...@@ -651,12 +677,6 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
[super willRemoveSubview:subview]; [super willRemoveSubview:subview];
} }
- (void) setHidden:(BOOL)hidden
{
[super setHidden:hidden];
[self invalidateHasGLDescendant];
}
/* /*
* ---------- NSTextInputClient methods ---------- * ---------- NSTextInputClient methods ----------
*/ */
...@@ -3432,6 +3452,7 @@ void macdrv_set_view_hidden(macdrv_view v, int hidden) ...@@ -3432,6 +3452,7 @@ void macdrv_set_view_hidden(macdrv_view v, int hidden)
OnMainThreadAsync(^{ OnMainThreadAsync(^{
[view setHidden:hidden]; [view setHidden:hidden];
[(WineWindow*)view.window updateForGLSubviews];
}); });
[pool release]; [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