From 7ccf7c731cb00bc0d2043dbced2c4971b31dc2c1 Mon Sep 17 00:00:00 2001 From: Ilya Kulakov Date: Fri, 26 Apr 2013 19:46:38 +0700 Subject: [PATCH] Consistent approach to handle child windows. When added, level of child window is reset to level of the parent. A user may change it aftewards to the level that may even break specified relative position. E.g. if a child window is added below the parent (Normal) and its level is set to Floating it will be ordered above. Whenever you change level of the parent window, levels of the child windows are reset as well ignoring all your changes. According to the example, if you set level of the parent to Normal+1, child window' level will also be set to Normal+1 and its relative order to the parent (below) will be restored. --- AppKit/CPWindow/CPWindow.j | 2 ++ AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index ccac5bf02..637c29e55 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -985,6 +985,7 @@ CPTexturedBackgroundWindowMask [_platformWindow moveWindow:self fromLevel:_level toLevel:aLevel]; _level = aLevel; + [_childWindows makeObjectsPerformSelector:@selector(setLevel:) withObject:_level]; if ([self _sharesChromeWithPlatformWindow]) [_platformWindow setLevel:aLevel]; @@ -2530,6 +2531,7 @@ CPTexturedBackgroundWindowMask [childWindow setParentWindow:self]; [childWindow _setChildOrdering:orderingMode]; + [childWindow setLevel:[self level]]; if ([self isVisible] && ![childWindow isVisible]) [childWindow orderWindow:orderingMode relativeTo:_windowNumber]; diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index 546c05871..3f861b5ec 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -1490,7 +1490,8 @@ var resizeTimer = nil; // relative to it or the furthest parent. var children = [aWindow childWindows], count = [children count], - parent = aWindow; + parent = aWindow, + parentLevel = [parent level]; for (var i = 0; i < count; ++i) { @@ -1501,6 +1502,10 @@ var resizeTimer = nil; if (!childWasVisible && ![child _hasBeenOrderedIn]) continue; + // If a user moved level of the child window, we should respect that + if ([child level] !== parentLevel) + continue; + var ordering = [child _childOrdering]; if ((ordering === CPWindowAbove && furthestParent._index > parent._index) ||