From d14f787192c66a5d339c60fb1bcdb849c1eefa67 Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Fri, 30 Aug 2013 00:00:35 -0500 Subject: [PATCH] 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). --- dlls/winemac.drv/cocoa_app.m | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m index 8de68bb1618..4cb09e71651 100644 --- a/dlls/winemac.drv/cocoa_app.m +++ b/dlls/winemac.drv/cocoa_app.m @@ -1480,8 +1480,28 @@ - (void) handleMouseButton:(NSEvent*)theEvent // respect to its siblings, but we want it to. We have to do it // manually. NSWindow* parent = [window parentWindow]; - [parent removeChildWindow:window]; - [parent addChildWindow:window ordered:NSWindowAbove]; + NSInteger level = [window level]; + __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]; + } } }