Commit ae473236 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Track whether our windows would be visible if the process weren't hidden.

The -[NSWindow isVisible] method returns FALSE when the process is hidden, but that's not what we need to know in some cases. This fixes full-screen games which minimize their window when they lose focus. Command-Tabbing away hides the process. Because the window was not visible, the code didn't actually minimize it. When switching back to the process, no event was sent to the Wine back-end telling it the window had been restored, so it never resumed drawing to it.
parent 6447e8e7
......@@ -33,6 +33,7 @@
BOOL maximized;
BOOL fullscreen;
BOOL pendingMinimize;
BOOL savedVisibleState;
WineWindow* latentParentWindow;
NSMutableArray* latentChildWindows;
......
......@@ -543,6 +543,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
WineWindow* window;
WineContentView* contentView;
NSTrackingArea* trackingArea;
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
[[WineApplicationController sharedController] flipRect:&window_frame];
......@@ -595,12 +596,21 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
[window setContentView:contentView];
[window setInitialFirstResponder:contentView];
[[NSNotificationCenter defaultCenter] addObserver:window
selector:@selector(updateFullscreen)
name:NSApplicationDidChangeScreenParametersNotification
object:NSApp];
[nc addObserver:window
selector:@selector(updateFullscreen)
name:NSApplicationDidChangeScreenParametersNotification
object:NSApp];
[window updateFullscreen];
[nc addObserver:window
selector:@selector(applicationWillHide)
name:NSApplicationWillHideNotification
object:NSApp];
[nc addObserver:window
selector:@selector(applicationDidUnhide)
name:NSApplicationDidUnhideNotification
object:NSApp];
return window;
}
......@@ -714,9 +724,15 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
[self setHasShadow:wf->shadow];
}
// Indicates if the window would be visible if the app were not hidden.
- (BOOL) wouldBeVisible
{
return [NSApp isHidden] ? savedVisibleState : [self isVisible];
}
- (BOOL) isOrderedIn
{
return [self isVisible] || [self isMiniaturized];
return [self wouldBeVisible] || [self isMiniaturized];
}
- (NSInteger) minimumLevelForActive:(BOOL)active
......@@ -827,7 +843,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
pendingMinimize = FALSE;
if (state->minimized && ![self isMiniaturized])
{
if ([self isVisible])
if ([self wouldBeVisible])
{
if ([self styleMask] & NSFullScreenWindowMask)
{
......@@ -1198,6 +1214,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
}
else
[self orderOut:nil];
savedVisibleState = FALSE;
if (wasVisible && wasOnActiveSpace && fullscreen)
[controller updateFullscreenWindows];
[controller adjustWindowLevels];
......@@ -1637,6 +1654,17 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
}
}
- (void) applicationWillHide
{
savedVisibleState = [self isVisible];
}
- (void) applicationDidUnhide
{
if ([self isVisible])
[self becameEligibleParentOrChild];
}
/*
* ---------- NSWindowDelegate methods ----------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment