winemac: Don't reorder clicked window relative to sibling owned windows if it's in the right place.

The right place may not be the end of the list of Cocoa child windows if some
of the siblings are at a higher window level (i.e. floating if the clicked
window is not).
This commit is contained in:
Ken Thomases 2013-08-30 00:00:35 -05:00 committed by Alexandre Julliard
parent 2c31fce106
commit d14f787192
1 changed files with 22 additions and 2 deletions

View File

@ -1480,8 +1480,28 @@ - (void) handleMouseButton:(NSEvent*)theEvent
// respect to its siblings, but we want it to. We have to do it // respect to its siblings, but we want it to. We have to do it
// manually. // manually.
NSWindow* parent = [window parentWindow]; NSWindow* parent = [window parentWindow];
[parent removeChildWindow:window]; NSInteger level = [window level];
[parent addChildWindow:window ordered:NSWindowAbove]; __block BOOL needReorder = FALSE;
// If the window is already the last child or if it's only below
// children with higher window level, then no need to reorder it.
[[parent childWindows] enumerateObjectsWithOptions:NSEnumerationReverse
usingBlock:^(id obj, NSUInteger idx, BOOL *stop){
WineWindow* child = obj;
if (child == window)
*stop = TRUE;
else if ([child level] <= level)
{
needReorder = TRUE;
*stop = TRUE;
}
}];
if (needReorder)
{
[parent removeChildWindow:window];
[parent addChildWindow:window ordered:NSWindowAbove];
}
} }
} }