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: Ken Thomases <ken@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c95d2de3dd
commit
2128125cbf
|
@ -25,12 +25,14 @@ @interface WineOpenGLContext : NSOpenGLContext
|
|||
{
|
||||
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 @@ - (void) wine_updateBackingSize:(const CGSize*)size;
|
|||
|
||||
|
||||
@implementation WineOpenGLContext
|
||||
@synthesize latentView, needsUpdate, shouldClearToBlack;
|
||||
@synthesize latentView, needsUpdate, needsReattach, shouldClearToBlack;
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
|
@ -215,6 +215,7 @@ - (void) removeFromViews:(BOOL)removeViews
|
|||
[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 @@ - (void) removeGLContext:(WineOpenGLContext*)context
|
|||
[(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 @@ - (BOOL) mouseDownCanMoveWindow
|
|||
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 @@ - (void) willRemoveSubview:(NSView*)subview
|
|||
[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];
|
||||
|
|
Loading…
Reference in New Issue