From c3183fc00783a3e7ff1ad0eb937150b66f1f016b Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Thu, 16 May 2013 18:43:16 -0500 Subject: [PATCH] winemac: Implement simpler way to find front Wine window. This uses Cocoa and the window server to track windows and their z-order, which is more reliable than our own tracking. --- dlls/winemac.drv/cocoa_app.h | 1 + dlls/winemac.drv/cocoa_app.m | 37 ++++++++++++++++++++----------------- dlls/winemac.drv/cocoa_window.m | 8 ++------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h index 8ed97636a21..551635d708b 100644 --- a/dlls/winemac.drv/cocoa_app.h +++ b/dlls/winemac.drv/cocoa_app.h @@ -111,6 +111,7 @@ enum { - (void) wineWindow:(WineWindow*)window ordered:(NSWindowOrderingMode)order relativeTo:(WineWindow*)otherWindow; + - (WineWindow*) frontWineWindow; - (BOOL) handleEvent:(NSEvent*)anEvent; - (void) didSendEvent:(NSEvent*)anEvent; diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index f9363c12852..67984cde6e6 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -486,6 +486,19 @@ int macdrv_err_on; } } + - (WineWindow*) frontWineWindow + { + NSNumber* windowNumber; + for (windowNumber in [NSWindow windowNumbersWithOptions:NSWindowNumberListAllSpaces]) + { + NSWindow* window = [NSApp windowWithWindowNumber:[windowNumber integerValue]]; + if ([window isKindOfClass:[WineWindow class]] && [window screen]) + return (WineWindow*)window; + } + + return nil; + } + - (void) sendDisplaysChanged:(BOOL)activating { macdrv_event* event; @@ -1613,10 +1626,6 @@ int macdrv_err_on; */ - (void)applicationDidBecomeActive:(NSNotification *)notification { - WineWindow* window; - WineWindow* firstMinimized; - BOOL anyShowing; - [self activateCursorClipping]; [orderedWineWindows enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop){ @@ -1625,23 +1634,17 @@ int macdrv_err_on; [window setLevel:[window levelWhenActive]]; }]; - firstMinimized = nil; - anyShowing = FALSE; - for (window in orderedWineWindows) + if (![self frontWineWindow]) { - if ([window isMiniaturized]) - { - if (!firstMinimized) - firstMinimized = window; - } - else if ([window isVisible]) + for (WineWindow* window in [NSApp windows]) { - anyShowing = TRUE; - break; + if ([window isKindOfClass:[WineWindow class]] && [window isMiniaturized]) + { + [window deminiaturize:self]; + break; + } } } - if (!anyShowing && firstMinimized) - [firstMinimized deminiaturize:self]; // If a Wine process terminates abruptly while it has the display captured // and switched to a different resolution, Mac OS X will uncapture the diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 3e60c84e8b6..6bc61831c84 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -1920,12 +1920,8 @@ int macdrv_send_text_input_event(int pressed, unsigned int flags, int repeat, in if (![window isKindOfClass:[WineWindow class]]) { window = (WineWindow*)[NSApp mainWindow]; - if (![window isKindOfClass:[WineWindow class]] && [[NSApp orderedWineWindows] count]) - { - window = [[NSApp orderedWineWindows] objectAtIndex:0]; - if (![window isKindOfClass:[WineWindow class]]) - window = nil; - } + if (![window isKindOfClass:[WineWindow class]]) + window = [[WineApplicationController sharedController] frontWineWindow]; } if (window) -- 2.11.4.GIT