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 <tclem@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Tim Clem 2022-01-19 11:13:45 -08:00 committed by Alexandre Julliard
parent e58b1a2b39
commit 8dae8ad8d8
4 changed files with 15 additions and 7 deletions

View File

@ -142,7 +142,7 @@ @interface WineApplicationController : NSObject <NSApplicationDelegate>
+ (WineApplicationController*) sharedController; + (WineApplicationController*) sharedController;
- (void) transformProcessToForeground; - (void) transformProcessToForeground:(BOOL)activateIfTransformed;
- (BOOL) registerEventQueue:(WineEventQueue*)queue; - (BOOL) registerEventQueue:(WineEventQueue*)queue;
- (void) unregisterEventQueue:(WineEventQueue*)queue; - (void) unregisterEventQueue:(WineEventQueue*)queue;

View File

@ -237,7 +237,7 @@ - (void) dealloc
[super dealloc]; [super dealloc];
} }
- (void) transformProcessToForeground - (void) transformProcessToForeground:(BOOL)activateIfTransformed
{ {
if ([NSApp activationPolicy] != NSApplicationActivationPolicyRegular) if ([NSApp activationPolicy] != NSApplicationActivationPolicyRegular)
{ {
@ -248,7 +248,10 @@ - (void) transformProcessToForeground
NSMenuItem* item; NSMenuItem* item;
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; [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 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:)]) if (!enable_app_nap && [NSProcessInfo instancesRespondToSelector:@selector(beginActivityWithOptions:reason:)])
{ {
@ -884,7 +887,7 @@ - (BOOL) setMode:(CGDisplayModeRef)mode forDisplay:(CGDirectDisplayID)displayID
if (!modes.count) if (!modes.count)
return FALSE; return FALSE;
[self transformProcessToForeground]; [self transformProcessToForeground:YES];
BOOL active = [NSApp isActive]; BOOL active = [NSApp isActive];

View File

@ -28,6 +28,7 @@ @interface WineWindow : NSPanel <NSWindowDelegate>
{ {
BOOL disabled; BOOL disabled;
BOOL noForeground; BOOL noForeground;
BOOL preventsAppActivation;
BOOL floating; BOOL floating;
BOOL resizable; BOOL resizable;
BOOL maximized; BOOL maximized;
@ -91,6 +92,7 @@ @interface WineWindow : NSPanel <NSWindowDelegate>
@property (retain, readonly, nonatomic) WineEventQueue* queue; @property (retain, readonly, nonatomic) WineEventQueue* queue;
@property (readonly, nonatomic) BOOL disabled; @property (readonly, nonatomic) BOOL disabled;
@property (readonly, nonatomic) BOOL noForeground; @property (readonly, nonatomic) BOOL noForeground;
@property (readonly, nonatomic) BOOL preventsAppActivation;
@property (readonly, nonatomic) BOOL floating; @property (readonly, nonatomic) BOOL floating;
@property (readonly, getter=isFullscreen, nonatomic) BOOL fullscreen; @property (readonly, getter=isFullscreen, nonatomic) BOOL fullscreen;
@property (readonly, getter=isFakingClose, nonatomic) BOOL fakingClose; @property (readonly, getter=isFakingClose, nonatomic) BOOL fakingClose;

View File

@ -391,6 +391,7 @@ @interface WineWindow ()
@property (readwrite, nonatomic) BOOL disabled; @property (readwrite, nonatomic) BOOL disabled;
@property (readwrite, nonatomic) BOOL noForeground; @property (readwrite, nonatomic) BOOL noForeground;
@property (readwrite, nonatomic) BOOL preventsAppActivation;
@property (readwrite, nonatomic) BOOL floating; @property (readwrite, nonatomic) BOOL floating;
@property (readwrite, nonatomic) BOOL drawnSinceShown; @property (readwrite, nonatomic) BOOL drawnSinceShown;
@property (readwrite, nonatomic) BOOL closing; @property (readwrite, nonatomic) BOOL closing;
@ -954,7 +955,7 @@ @implementation WineWindow
static WineWindow* causing_becomeKeyWindow; 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 drawnSinceShown;
@synthesize surface, surface_mutex; @synthesize surface, surface_mutex;
@synthesize shapeChangedSinceLastDraw; @synthesize shapeChangedSinceLastDraw;
@ -1143,6 +1144,8 @@ - (void) setWindowFeatures:(const struct macdrv_window_features*)wf
NSUInteger currentStyle = [self styleMask]; NSUInteger currentStyle = [self styleMask];
NSUInteger newStyle = style_mask_for_features(wf) | (currentStyle & ~usedStyles); NSUInteger newStyle = style_mask_for_features(wf) | (currentStyle & ~usedStyles);
self.preventsAppActivation = wf->prevents_app_activation;
if (newStyle != currentStyle) if (newStyle != currentStyle)
{ {
NSString* title = [[[self title] copy] autorelease]; NSString* title = [[[self title] copy] autorelease];
@ -1686,7 +1689,7 @@ - (void) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next activate:(BOOL)a
WineWindow* parent; WineWindow* parent;
WineWindow* child; WineWindow* child;
[controller transformProcessToForeground]; [controller transformProcessToForeground:!self.preventsAppActivation];
if ([NSApp isHidden]) if ([NSApp isHidden])
[NSApp unhide:nil]; [NSApp unhide:nil];
wasVisible = [self isVisible]; wasVisible = [self isVisible];
@ -2056,7 +2059,7 @@ - (void) makeFocused:(BOOL)activate
{ {
if (activate) if (activate)
{ {
[[WineApplicationController sharedController] transformProcessToForeground]; [[WineApplicationController sharedController] transformProcessToForeground:YES];
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
} }