Chip Davis : winemac.drv: Enable layer-backed views.
Alexandre Julliard
julliard at winehq.org
Wed Sep 1 15:45:10 CDT 2021
Module: wine
Branch: master
Commit: a5cf847aa45c38bae1500ef19a9bac38bbd8d5ba
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a5cf847aa45c38bae1500ef19a9bac38bbd8d5ba
Author: Chip Davis <cdavis at codeweavers.com>
Date: Wed Sep 1 09:28:20 2021 -0500
winemac.drv: Enable layer-backed views.
Signed-off-by: Chip Davis <cdavis at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at 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
+ at protocol NSViewLayerContentScaleDelegate <NSObject>
+ at optional
+
+ - (BOOL) layer:(CALayer*)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow*)window;
+
+ at end
+#endif
+
+
@interface WineBaseView : NSView
@end
@@ -327,7 +337,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
#endif
- at interface WineContentView : WineBaseView <NSTextInputClient>
+ at 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];
More information about the wine-cvs
mailing list