From e27abb0a3a3a5d43a12622fb99452f40c8b340ff Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Fri, 13 Jul 2018 09:27:00 -0500 Subject: [PATCH] winemac: Extract a new class, WineBaseView, to be the superclass of WineContentView and future view classes. Signed-off-by: Ken Thomases Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- 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 e37e071ea42..1e10c27ce81 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 -@interface WineContentView : NSView +@interface WineBaseView : NSView +@end + + +@interface WineContentView : WineBaseView { NSMutableArray* glContexts; NSMutableArray* pendingGlContexts; @@ -366,6 +370,52 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi @end +@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; + } + +@end + + @implementation WineContentView @synthesize everHadGLContext = _everHadGLContext; @@ -537,7 +587,7 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi 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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi [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 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi [[self inputContext] discardMarkedText]; } - - (NSFocusRingType) focusRingType - { - return NSFocusRingTypeNone; - } - - (void) didAddSubview:(NSView*)subview { if ([subview isKindOfClass:[WineContentView class]]) @@ -2537,9 +2551,9 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi 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.11.4.GIT