winemac.drv: Enable layer-backed views.

Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Chip Davis 2021-09-01 09:28:20 -05:00 committed by Alexandre Julliard
parent 7284348985
commit a5cf847aa4
1 changed files with 20 additions and 1 deletions

View File

@ -311,6 +311,16 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
@end
#ifndef MAC_OS_X_VERSION_10_14
@protocol NSViewLayerContentScaleDelegate <NSObject>
@optional
- (BOOL) layer:(CALayer*)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow*)window;
@end
#endif
@interface WineBaseView : NSView
@end
@ -327,7 +337,7 @@ - (id) initWithFrame:(NSRect)frame device:(id<MTLDevice>)device;
#endif
@interface WineContentView : WineBaseView <NSTextInputClient>
@interface WineContentView : WineBaseView <NSTextInputClient, NSViewLayerContentScaleDelegate>
{
NSMutableArray* glContexts;
NSMutableArray* pendingGlContexts;
@ -339,6 +349,7 @@ @interface WineContentView : WineBaseView <NSTextInputClient>
NSMutableAttributedString* markedText;
NSRange markedTextSelection;
BOOL _retinaMode;
int backingSize[2];
#ifdef HAVE_METAL_METAL_H
@ -688,9 +699,15 @@ - (void) setRetinaMode:(int)mode
[self setWantsBestResolutionOpenGLSurface:mode];
[self updateGLContexts];
_retinaMode = !!mode;
[super setRetinaMode:mode];
}
- (BOOL) layer:(CALayer*)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow*)window
{
return (_retinaMode || newScale == 1.0);
}
- (void) viewDidHide
{
[super viewDidHide];
@ -1002,6 +1019,7 @@ + (WineWindow*) createWindowWithFeatures:(const struct macdrv_window_features*)w
contentView = [[[WineContentView alloc] initWithFrame:NSZeroRect] autorelease];
if (!contentView)
return nil;
[contentView setWantsLayer:YES];
[contentView setAutoresizesSubviews:NO];
/* We use tracking areas in addition to setAcceptsMouseMovedEvents:YES
@ -3573,6 +3591,7 @@ macdrv_view macdrv_create_view(CGRect rect)
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
view = [[WineContentView alloc] initWithFrame:NSRectFromCGRect(cgrect_mac_from_win(rect))];
[view setWantsLayer:YES];
[view setAutoresizesSubviews:NO];
[view setAutoresizingMask:NSViewNotSizable];
[view setHidden:YES];