winemac: Don't reorder windows if they're already ordered as requested.
This avoids adjusting window levels. It also avoid unnecessarily deinterleaving the windows of this and other processes.
This commit is contained in:
parent
7a047af640
commit
ef874a8eaa
|
@ -657,6 +657,55 @@ - (void) setMacDrvState:(const struct macdrv_window_state*)state
|
||||||
forWindow:self];
|
forWindow:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine if, among Wine windows, this window is directly above or below
|
||||||
|
// a given other Wine window with no other Wine window intervening.
|
||||||
|
// Intervening non-Wine windows are ignored.
|
||||||
|
- (BOOL) isOrdered:(NSWindowOrderingMode)orderingMode relativeTo:(WineWindow*)otherWindow
|
||||||
|
{
|
||||||
|
NSNumber* windowNumber;
|
||||||
|
NSNumber* otherWindowNumber;
|
||||||
|
NSArray* windowNumbers;
|
||||||
|
NSUInteger windowIndex, otherWindowIndex, lowIndex, highIndex, i;
|
||||||
|
|
||||||
|
if (![self isVisible] || ![otherWindow isVisible])
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
windowNumber = [NSNumber numberWithInteger:[self windowNumber]];
|
||||||
|
otherWindowNumber = [NSNumber numberWithInteger:[otherWindow windowNumber]];
|
||||||
|
windowNumbers = [[self class] windowNumbersWithOptions:0];
|
||||||
|
windowIndex = [windowNumbers indexOfObject:windowNumber];
|
||||||
|
otherWindowIndex = [windowNumbers indexOfObject:otherWindowNumber];
|
||||||
|
|
||||||
|
if (windowIndex == NSNotFound || otherWindowIndex == NSNotFound)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (orderingMode == NSWindowAbove)
|
||||||
|
{
|
||||||
|
lowIndex = windowIndex;
|
||||||
|
highIndex = otherWindowIndex;
|
||||||
|
}
|
||||||
|
else if (orderingMode == NSWindowBelow)
|
||||||
|
{
|
||||||
|
lowIndex = otherWindowIndex;
|
||||||
|
highIndex = windowIndex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (highIndex <= lowIndex)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
for (i = lowIndex + 1; i < highIndex; i++)
|
||||||
|
{
|
||||||
|
NSInteger interveningWindowNumber = [[windowNumbers objectAtIndex:i] integerValue];
|
||||||
|
NSWindow* interveningWindow = [NSApp windowWithWindowNumber:interveningWindowNumber];
|
||||||
|
if ([interveningWindow isKindOfClass:[WineWindow class]])
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns whether or not the window was ordered in, which depends on if
|
/* Returns whether or not the window was ordered in, which depends on if
|
||||||
its frame intersects any screen. */
|
its frame intersects any screen. */
|
||||||
- (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
|
- (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
|
||||||
|
@ -665,6 +714,8 @@ - (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
|
||||||
BOOL on_screen = frame_intersects_screens([self frame], [NSScreen screens]);
|
BOOL on_screen = frame_intersects_screens([self frame], [NSScreen screens]);
|
||||||
if (on_screen)
|
if (on_screen)
|
||||||
{
|
{
|
||||||
|
BOOL needAdjustWindowLevels = FALSE;
|
||||||
|
|
||||||
[controller transformProcessToForeground];
|
[controller transformProcessToForeground];
|
||||||
|
|
||||||
NSDisableScreenUpdates();
|
NSDisableScreenUpdates();
|
||||||
|
@ -675,12 +726,15 @@ - (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
|
||||||
[self setLevel:[latentParentWindow level]];
|
[self setLevel:[latentParentWindow level]];
|
||||||
[latentParentWindow addChildWindow:self ordered:NSWindowAbove];
|
[latentParentWindow addChildWindow:self ordered:NSWindowAbove];
|
||||||
self.latentParentWindow = nil;
|
self.latentParentWindow = nil;
|
||||||
|
needAdjustWindowLevels = TRUE;
|
||||||
}
|
}
|
||||||
if (prev || next)
|
if (prev || next)
|
||||||
{
|
{
|
||||||
WineWindow* other = [prev isVisible] ? prev : next;
|
WineWindow* other = [prev isVisible] ? prev : next;
|
||||||
NSWindowOrderingMode orderingMode = [prev isVisible] ? NSWindowBelow : NSWindowAbove;
|
NSWindowOrderingMode orderingMode = [prev isVisible] ? NSWindowBelow : NSWindowAbove;
|
||||||
|
|
||||||
|
if (![self isOrdered:orderingMode relativeTo:other])
|
||||||
|
{
|
||||||
// This window level may not be right for this window based
|
// This window level may not be right for this window based
|
||||||
// on floating-ness, fullscreen-ness, etc. But we set it
|
// on floating-ness, fullscreen-ness, etc. But we set it
|
||||||
// temporarily to allow us to order the windows properly.
|
// temporarily to allow us to order the windows properly.
|
||||||
|
@ -688,6 +742,8 @@ - (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
|
||||||
if ([self level] != [other level])
|
if ([self level] != [other level])
|
||||||
[self setLevel:[other level]];
|
[self setLevel:[other level]];
|
||||||
[self orderWindow:orderingMode relativeTo:[other windowNumber]];
|
[self orderWindow:orderingMode relativeTo:[other windowNumber]];
|
||||||
|
needAdjustWindowLevels = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -697,7 +753,9 @@ - (BOOL) orderBelow:(WineWindow*)prev orAbove:(WineWindow*)next
|
||||||
if (next && [self level] < [next level])
|
if (next && [self level] < [next level])
|
||||||
[self setLevel:[next level]];
|
[self setLevel:[next level]];
|
||||||
[self orderFront:nil];
|
[self orderFront:nil];
|
||||||
|
needAdjustWindowLevels = TRUE;
|
||||||
}
|
}
|
||||||
|
if (needAdjustWindowLevels)
|
||||||
[controller adjustWindowLevels];
|
[controller adjustWindowLevels];
|
||||||
|
|
||||||
NSEnableScreenUpdates();
|
NSEnableScreenUpdates();
|
||||||
|
|
Loading…
Reference in New Issue