Module: wine Branch: master Commit: a5cf847aa45c38bae1500ef19a9bac38bbd8d5ba URL: https://source.winehq.org/git/wine.git/?a=commit;h=a5cf847aa45c38bae1500ef19...
Author: Chip Davis cdavis@codeweavers.com Date: Wed Sep 1 09:28:20 2021 -0500
winemac.drv: Enable layer-backed views.
Signed-off-by: Chip Davis cdavis@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winemac.drv/cocoa_window.m | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 29ac32d6be0..29a5abe6344 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi #endif
-@interface WineContentView : WineBaseView <NSTextInputClient> +@interface WineContentView : WineBaseView <NSTextInputClient, NSViewLayerContentScaleDelegate> { NSMutableArray* glContexts; NSMutableArray* pendingGlContexts; @@ -339,6 +349,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi NSMutableAttributedString* markedText; NSRange markedTextSelection;
+ BOOL _retinaMode; int backingSize[2];
#ifdef HAVE_METAL_METAL_H @@ -688,9 +699,15 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi [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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi 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];