mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-20 06:28:51 +00:00
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:
parent
94336f1aab
commit
c3183fc007
|
@ -111,6 +111,7 @@ - (void) flipRect:(NSRect*)rect;
|
||||||
- (void) wineWindow:(WineWindow*)window
|
- (void) wineWindow:(WineWindow*)window
|
||||||
ordered:(NSWindowOrderingMode)order
|
ordered:(NSWindowOrderingMode)order
|
||||||
relativeTo:(WineWindow*)otherWindow;
|
relativeTo:(WineWindow*)otherWindow;
|
||||||
|
- (WineWindow*) frontWineWindow;
|
||||||
|
|
||||||
- (BOOL) handleEvent:(NSEvent*)anEvent;
|
- (BOOL) handleEvent:(NSEvent*)anEvent;
|
||||||
- (void) didSendEvent:(NSEvent*)anEvent;
|
- (void) didSendEvent:(NSEvent*)anEvent;
|
||||||
|
|
|
@ -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
|
- (void) sendDisplaysChanged:(BOOL)activating
|
||||||
{
|
{
|
||||||
macdrv_event* event;
|
macdrv_event* event;
|
||||||
|
@ -1613,10 +1626,6 @@ - (BOOL) inputSourceIsInputMethod
|
||||||
*/
|
*/
|
||||||
- (void)applicationDidBecomeActive:(NSNotification *)notification
|
- (void)applicationDidBecomeActive:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
WineWindow* window;
|
|
||||||
WineWindow* firstMinimized;
|
|
||||||
BOOL anyShowing;
|
|
||||||
|
|
||||||
[self activateCursorClipping];
|
[self activateCursorClipping];
|
||||||
|
|
||||||
[orderedWineWindows enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop){
|
[orderedWineWindows enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id obj, NSUInteger idx, BOOL *stop){
|
||||||
|
@ -1625,23 +1634,17 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification
|
||||||
[window setLevel:[window levelWhenActive]];
|
[window setLevel:[window levelWhenActive]];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
firstMinimized = nil;
|
if (![self frontWineWindow])
|
||||||
anyShowing = FALSE;
|
|
||||||
for (window in orderedWineWindows)
|
|
||||||
{
|
{
|
||||||
if ([window isMiniaturized])
|
for (WineWindow* window in [NSApp windows])
|
||||||
{
|
{
|
||||||
if (!firstMinimized)
|
if ([window isKindOfClass:[WineWindow class]] && [window isMiniaturized])
|
||||||
firstMinimized = window;
|
|
||||||
}
|
|
||||||
else if ([window isVisible])
|
|
||||||
{
|
{
|
||||||
anyShowing = TRUE;
|
[window deminiaturize:self];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!anyShowing && firstMinimized)
|
}
|
||||||
[firstMinimized deminiaturize:self];
|
|
||||||
|
|
||||||
// If a Wine process terminates abruptly while it has the display captured
|
// If a Wine process terminates abruptly while it has the display captured
|
||||||
// and switched to a different resolution, Mac OS X will uncapture the
|
// and switched to a different resolution, Mac OS X will uncapture the
|
||||||
|
|
|
@ -1920,12 +1920,8 @@ int macdrv_send_text_input_event(int pressed, unsigned int flags, int repeat, in
|
||||||
if (![window isKindOfClass:[WineWindow class]])
|
if (![window isKindOfClass:[WineWindow class]])
|
||||||
{
|
{
|
||||||
window = (WineWindow*)[NSApp mainWindow];
|
window = (WineWindow*)[NSApp mainWindow];
|
||||||
if (![window isKindOfClass:[WineWindow class]] && [[NSApp orderedWineWindows] count])
|
|
||||||
{
|
|
||||||
window = [[NSApp orderedWineWindows] objectAtIndex:0];
|
|
||||||
if (![window isKindOfClass:[WineWindow class]])
|
if (![window isKindOfClass:[WineWindow class]])
|
||||||
window = nil;
|
window = [[WineApplicationController sharedController] frontWineWindow];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
|
|
Loading…
Reference in a new issue