[PATCH 1/3] winemac: Extract a new class, WineBaseView, to be the superclass of WineContentView and future view classes.
Andrew Eikum
aeikum at codeweavers.com
Fri Jul 13 09:27:00 CDT 2018
From: Ken Thomases <ken at codeweavers.com>
Signed-off-by: Ken Thomases <ken at codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
dlls/winemac.drv/cocoa_window.m | 96 +++++++++++++++++++--------------
1 file changed, 55 insertions(+), 41 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
index e37e071ea4..1e10c27ce8 100644
--- a/dlls/winemac.drv/cocoa_window.m
+++ b/dlls/winemac.drv/cocoa_window.m
@@ -299,7 +299,11 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi
@end
- at interface WineContentView : NSView <NSTextInputClient>
+ at interface WineBaseView : NSView
+ at end
+
+
+ at interface WineContentView : WineBaseView <NSTextInputClient>
{
NSMutableArray* glContexts;
NSMutableArray* pendingGlContexts;
@@ -366,6 +370,52 @@ - (void) windowDidDrawContent;
@end
+ at implementation WineBaseView
+
+ - (void) setRetinaMode:(int)mode
+ {
+ for (WineBaseView* subview in [self subviews])
+ {
+ if ([subview isKindOfClass:[WineBaseView class]])
+ [subview setRetinaMode:mode];
+ }
+ }
+
+ - (BOOL) acceptsFirstMouse:(NSEvent*)theEvent
+ {
+ return YES;
+ }
+
+ - (BOOL) preservesContentDuringLiveResize
+ {
+ // Returning YES from this tells Cocoa to keep our view's content during
+ // a Cocoa-driven resize. In theory, we're also supposed to override
+ // -setFrameSize: to mark exposed sections as needing redisplay, but
+ // user32 will take care of that in a roundabout way. This way, we don't
+ // redraw until the window surface is flushed.
+ //
+ // This doesn't do anything when we resize the window ourselves.
+ return YES;
+ }
+
+ - (BOOL)acceptsFirstResponder
+ {
+ return [[self window] contentView] == self;
+ }
+
+ - (BOOL) mouseDownCanMoveWindow
+ {
+ return NO;
+ }
+
+ - (NSFocusRingType) focusRingType
+ {
+ return NSFocusRingTypeNone;
+ }
+
+ at end
+
+
@implementation WineContentView
@synthesize everHadGLContext = _everHadGLContext;
@@ -537,7 +587,7 @@ - (BOOL) _hasGLDescendant
return YES;
for (WineContentView* view in [self subviews])
{
- if ([view hasGLDescendant])
+ if ([view isKindOfClass:[WineContentView class]] && [view hasGLDescendant])
return YES;
}
return NO;
@@ -589,38 +639,7 @@ - (void) setRetinaMode:(int)mode
[self setFrame:frame];
[self updateGLContexts];
- for (WineContentView* subview in [self subviews])
- {
- if ([subview isKindOfClass:[WineContentView class]])
- [subview setRetinaMode:mode];
- }
- }
-
- - (BOOL) acceptsFirstMouse:(NSEvent*)theEvent
- {
- return YES;
- }
-
- - (BOOL) preservesContentDuringLiveResize
- {
- // Returning YES from this tells Cocoa to keep our view's content during
- // a Cocoa-driven resize. In theory, we're also supposed to override
- // -setFrameSize: to mark exposed sections as needing redisplay, but
- // user32 will take care of that in a roundabout way. This way, we don't
- // redraw until the window surface is flushed.
- //
- // This doesn't do anything when we resize the window ourselves.
- return YES;
- }
-
- - (BOOL)acceptsFirstResponder
- {
- return [[self window] contentView] == self;
- }
-
- - (BOOL) mouseDownCanMoveWindow
- {
- return NO;
+ [super setRetinaMode:mode];
}
- (void) viewDidHide
@@ -655,11 +674,6 @@ - (void) completeText:(NSString*)text
[[self inputContext] discardMarkedText];
}
- - (NSFocusRingType) focusRingType
- {
- return NSFocusRingTypeNone;
- }
-
- (void) didAddSubview:(NSView*)subview
{
if ([subview isKindOfClass:[WineContentView class]])
@@ -2537,9 +2551,9 @@ - (void) setRetinaMode:(int)mode
if (shape)
[shape transformUsingAffineTransform:transform];
- for (WineContentView* subview in [self.contentView subviews])
+ for (WineBaseView* subview in [self.contentView subviews])
{
- if ([subview isKindOfClass:[WineContentView class]])
+ if ([subview isKindOfClass:[WineBaseView class]])
[subview setRetinaMode:mode];
}
--
2.18.0
More information about the wine-devel
mailing list