Commit 987309e5 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Don't use Cocoa parent-child relationship when topmost state is enough…

winemac: Don't use Cocoa parent-child relationship when topmost state is enough to keep owned in front of owner. The Cocoa parent-child relationship has undesirable side effects and bugs. In the general case, it's the only way to maintain the z-order of owned windows relative to their owner. But when the owner is non-topmost and an owned window is topmost, the Cocoa window level will enforce that and we don't need it.
parent 11b21f70
...@@ -160,6 +160,9 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) ...@@ -160,6 +160,9 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
- (void) updateColorSpace; - (void) updateColorSpace;
- (BOOL) becameEligibleParentOrChild;
- (void) becameIneligibleChild;
@end @end
...@@ -626,6 +629,31 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) ...@@ -626,6 +629,31 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
if (self.floating != state->floating) if (self.floating != state->floating)
{ {
self.floating = state->floating; self.floating = state->floating;
if (state->floating)
{
// Became floating. If child of non-floating window, make that
// relationship latent.
WineWindow* parent = (WineWindow*)[self parentWindow];
if (parent && !parent.floating)
[self becameIneligibleChild];
}
else
{
// Became non-floating. If parent of floating children, make that
// relationship latent.
WineWindow* child;
for (child in [[[self childWindows] copy] autorelease])
{
if (child.floating)
[child becameIneligibleChild];
}
}
// Check our latent relationships. If floating status was the only
// reason they were latent, then make them active.
if ([self isVisible])
[self becameEligibleParentOrChild];
[[WineApplicationController sharedController] adjustWindowLevels]; [[WineApplicationController sharedController] adjustWindowLevels];
} }
...@@ -675,7 +703,7 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) ...@@ -675,7 +703,7 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
{ {
BOOL reordered = FALSE; BOOL reordered = FALSE;
if ([self isVisible] && (assumeVisible || [child isVisible])) if ([self isVisible] && (assumeVisible || [child isVisible]) && (self.floating || !child.floating))
{ {
if ([self level] > [child level]) if ([self level] > [child level])
[child setLevel:[self level]]; [child setLevel:[self level]];
...@@ -714,12 +742,15 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) ...@@ -714,12 +742,15 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
BOOL reordered = FALSE; BOOL reordered = FALSE;
NSUInteger count; NSUInteger count;
// If we aren't visible currently, we assume that we should be and soon if (latentParentWindow.floating || !self.floating)
// will be. So, if the latent parent is visible that's enough to assume {
// we can establish the parent-child relationship in Cocoa. That will // If we aren't visible currently, we assume that we should be and soon
// actually make us visible, which is fine. // will be. So, if the latent parent is visible that's enough to assume
if ([latentParentWindow addChildWineWindow:self assumeVisible:TRUE]) // we can establish the parent-child relationship in Cocoa. That will
reordered = TRUE; // actually make us visible, which is fine.
if ([latentParentWindow addChildWineWindow:self assumeVisible:TRUE])
reordered = TRUE;
}
// Here, though, we may not actually be visible yet and adding a child // Here, though, we may not actually be visible yet and adding a child
// won't make us visible. The caller will have to call this method // won't make us visible. The caller will have to call this method
...@@ -732,7 +763,7 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) ...@@ -732,7 +763,7 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
WineWindow* child = [latentChildWindows objectAtIndex:i]; WineWindow* child = [latentChildWindows objectAtIndex:i];
if ([child isVisible]) if ([child isVisible] && (self.floating || !child.floating))
{ {
if (child.latentParentWindow == self) if (child.latentParentWindow == self)
{ {
...@@ -754,11 +785,9 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) ...@@ -754,11 +785,9 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
return reordered; return reordered;
} }
- (void) becameIneligibleParentOrChild - (void) becameIneligibleChild
{ {
WineWindow* parent = (WineWindow*)[self parentWindow]; WineWindow* parent = (WineWindow*)[self parentWindow];
NSArray* childWindows = [self childWindows];
if (parent) if (parent)
{ {
if (!parent->latentChildWindows) if (!parent->latentChildWindows)
...@@ -767,6 +796,13 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers) ...@@ -767,6 +796,13 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
self.latentParentWindow = parent; self.latentParentWindow = parent;
[parent removeChildWindow:self]; [parent removeChildWindow:self];
} }
}
- (void) becameIneligibleParentOrChild
{
NSArray* childWindows = [self childWindows];
[self becameIneligibleChild];
if ([childWindows count]) if ([childWindows count])
{ {
......
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