From 8dae8ad8d8801fe6eceec0eff16239aed24b7f7d Mon Sep 17 00:00:00 2001 From: Tim Clem Date: Wed, 19 Jan 2022 11:13:45 -0800 Subject: [PATCH] winemac.drv: Don't activate the app if its first window is WS_EX_NOACTIVATE. This matches the behavior on Windows. Signed-off-by: Tim Clem Signed-off-by: Alexandre Julliard --- dlls/winemac.drv/cocoa_app.h | 2 +- dlls/winemac.drv/cocoa_app.m | 9 ++++++--- dlls/winemac.drv/cocoa_window.h | 2 ++ dlls/winemac.drv/cocoa_window.m | 9 ++++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h index 0b70a2fd55b..0689c22ec32 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -142,7 +142,7 @@ @interface WineApplicationController : NSObject + (WineApplicationController*) sharedController; - - (void) transformProcessToForeground; + - (void) transformProcessToForeground:(BOOL)activateIfTransformed; - (BOOL) registerEventQueue:(WineEventQueue*)queue; - (void) unregisterEventQueue:(WineEventQueue*)queue; diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 16a773e1470..8b6a1779b84 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -237,7 +237,7 @@ - (void) dealloc [super dealloc]; } - - (void) transformProcessToForeground + - (void) transformProcessToForeground:(BOOL)activateIfTransformed { if ([NSApp activationPolicy] != NSApplicationActivationPolicyRegular) { @@ -248,7 +248,10 @@ - (void) transformProcessToForeground NSMenuItem* item; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - [NSApp activateIgnoringOtherApps:YES]; + + if (activateIfTransformed) + [NSApp activateIgnoringOtherApps:YES]; + #if defined(MAC_OS_X_VERSION_10_9) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 if (!enable_app_nap && [NSProcessInfo instancesRespondToSelector:@selector(beginActivityWithOptions:reason:)]) { @@ -884,7 +887,7 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID if (!modes.count) return FALSE; - [self transformProcessToForeground]; + [self transformProcessToForeground:YES]; BOOL active = [NSApp isActive]; diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h index c7bcaedfd97..a83f2aa803b 100644 --- a/dlls/winemac.drv/cocoa_window.h +++ b/dlls/winemac.drv/cocoa_window.h @@ -28,6 +28,7 @@ @interface WineWindow : NSPanel { BOOL disabled; BOOL noForeground; + BOOL preventsAppActivation; BOOL floating; BOOL resizable; BOOL maximized; @@ -91,6 +92,7 @@ @interface WineWindow : NSPanel @property (retain, readonly, nonatomic) WineEventQueue* queue; @property (readonly, nonatomic) BOOL disabled; @property (readonly, nonatomic) BOOL noForeground; +@property (readonly, nonatomic) BOOL preventsAppActivation; @property (readonly, nonatomic) BOOL floating; @property (readonly, getter=isFullscreen, nonatomic) BOOL fullscreen; @property (readonly, getter=isFakingClose, nonatomic) BOOL fakingClose; diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 6301b47143e..bfa7e2fe8cc 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -391,6 +391,7 @@ @interface WineWindow () @property (readwrite, nonatomic) BOOL disabled; @property (readwrite, nonatomic) BOOL noForeground; +@property (readwrite, nonatomic) BOOL preventsAppActivation; @property (readwrite, nonatomic) BOOL floating; @property (readwrite, nonatomic) BOOL drawnSinceShown; @property (readwrite, nonatomic) BOOL closing; @@ -954,7 +955,7 @@ @implementation WineWindow static WineWindow* causing_becomeKeyWindow; - @synthesize disabled, noForeground, floating, fullscreen, fakingClose, closing, latentParentWindow, hwnd, queue; + @synthesize disabled, noForeground, preventsAppActivation, floating, fullscreen, fakingClose, closing, latentParentWindow, hwnd, queue; @synthesize drawnSinceShown; @synthesize surface, surface_mutex; @synthesize shapeChangedSinceLastDraw; @@ -1143,6 +1144,8 @@ - (void) setWindowFeatures:(const struct macdrv_window_features*)wf NSUInteger currentStyle = [self styleMask]; NSUInteger newStyle = style_mask_for_features(wf) | (currentStyle & ~usedStyles); + self.preventsAppActivation = wf->prevents_app_activation; + if (newStyle != currentStyle) { NSString* title = [[[self title] copy] autorelease]; @@ -1686,7 +1689,7 @@ - (void) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next activate:(BOOL)a WineWindow* parent; WineWindow* child; - [controller transformProcessToForeground]; + [controller transformProcessToForeground:!self.preventsAppActivation]; if ([NSApp isHidden]) [NSApp unhide:nil]; wasVisible = [self isVisible]; @@ -2056,7 +2059,7 @@ - (void) makeFocused:(BOOL)activate { if (activate) { - [[WineApplicationController sharedController] transformProcessToForeground]; + [[WineApplicationController sharedController] transformProcessToForeground:YES]; [NSApp activateIgnoringOtherApps:YES]; }