From 2fcf40a6e1af4ed043b56d2a2d6450e3311afdd4 Mon Sep 17 00:00:00 2001 From: Brendan Shanks Date: Wed, 25 Oct 2023 12:51:26 -0500 Subject: [PATCH] winemac.drv: Fix minimizing windows when Stage Manager is enabled. --- dlls/winemac.drv/cocoa_window.m | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 5700bd3d531..820bb606769 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -161,6 +161,21 @@ static inline NSUInteger adjusted_modifiers_for_settings(NSUInteger modifiers) return new_modifiers; } +static inline BOOL stage_manager_enabled(void) +{ + /* There is no documented way to determine if Stage Manager is enabled, + * but this seems like the best option. + */ + if (floor(NSAppKitVersionNumber) >= 2299 /* NSAppKitVersionNumber13_0 */) + { + NSUserDefaults *defs = [[NSUserDefaults alloc] initWithSuiteName:@"com.apple.WindowManager.plist"]; + BOOL enabled = [defs boolForKey:@"GloballyEnabled"]; + [defs release]; + return enabled; + } + return FALSE; +} + @interface NSWindow (WineAccessPrivateMethods) - (id) _displayChanged; @@ -2576,6 +2591,16 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi - (void) miniaturize:(id)sender { + /* When Stage Manager is enabled, miniaturize: just moves the app/window to + * the background rather than minimizing the window. + * Don't start minimizing the window on the Win32 side. + */ + if (stage_manager_enabled()) + { + [super miniaturize:sender]; + return; + } + macdrv_event* event = macdrv_create_event(WINDOW_MINIMIZE_REQUESTED, self); [queue postEvent:event]; macdrv_release_event(event); -- 2.11.4.GIT