forked from Mirrors/wine-wine
winemac: When ordering sibling child windows, don't remove and re-add ones already in the right order.
parent
987309e528
commit
675b052572
|
@ -875,7 +875,8 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
|
|||
{
|
||||
NSMutableArray* windowNumbers;
|
||||
NSNumber* childWindowNumber;
|
||||
NSUInteger otherIndex;
|
||||
NSUInteger otherIndex, limit;
|
||||
NSArray* origChildren;
|
||||
NSMutableArray* children;
|
||||
|
||||
// Get the z-order from the window server and modify it to reflect the
|
||||
|
@ -888,7 +889,8 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
|
|||
|
||||
// Get our child windows and sort them in the reverse of the desired
|
||||
// z-order (back-to-front).
|
||||
children = [[[self childWindows] mutableCopy] autorelease];
|
||||
origChildren = [self childWindows];
|
||||
children = [[origChildren mutableCopy] autorelease];
|
||||
[children sortWithOptions:NSSortStable
|
||||
usingComparator:^NSComparisonResult(id obj1, id obj2){
|
||||
NSNumber* window1Number = [NSNumber numberWithInteger:[obj1 windowNumber]];
|
||||
|
@ -912,6 +914,16 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
|
|||
return NSOrderedSame;
|
||||
}];
|
||||
|
||||
// If the current and desired children arrays match up to a point, leave
|
||||
// those matching children alone.
|
||||
limit = MIN([origChildren count], [children count]);
|
||||
for (otherIndex = 0; otherIndex < limit; otherIndex++)
|
||||
{
|
||||
if ([origChildren objectAtIndex:otherIndex] != [children objectAtIndex:otherIndex])
|
||||
break;
|
||||
}
|
||||
[children removeObjectsInRange:NSMakeRange(0, otherIndex)];
|
||||
|
||||
// Remove all of the child windows and re-add them back-to-front so they
|
||||
// are in the desired order.
|
||||
for (other in children)
|
||||
|
|
Loading…
Reference in New Issue