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.
This commit is contained in:
Ken Thomases 2013-05-16 18:43:16 -05:00 committed by Alexandre Julliard
parent 94336f1aab
commit c3183fc007
3 changed files with 23 additions and 23 deletions

View File

@ -111,6 +111,7 @@ - (void) flipRect:(NSRect*)rect;
- (void) wineWindow:(WineWindow*)window
ordered:(NSWindowOrderingMode)order
relativeTo:(WineWindow*)otherWindow;
- (WineWindow*) frontWineWindow;
- (BOOL) handleEvent:(NSEvent*)anEvent;
- (void) didSendEvent:(NSEvent*)anEvent;

View File

@ -486,6 +486,19 @@ - (void) wineWindow:(WineWindow*)window
}
}
- (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 @@ - (BOOL) inputSourceIsInputMethod
*/
- (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 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification
[window setLevel:[window levelWhenActive]];
}];
firstMinimized = nil;
anyShowing = FALSE;
for (window in orderedWineWindows)
if (![self frontWineWindow])
{
if ([window isMiniaturized])
for (WineWindow* window in [NSApp windows])
{
if (!firstMinimized)
firstMinimized = window;
}
else if ([window isVisible])
{
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

View File

@ -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)