fixed logic

This commit is contained in:
daboe01 committed 2025-06-22 21:28:37 +02:00
1 parent 170d6ac2e7
commit c28a05e968
1 file changed
+14 -15
+14 -15
View File
@@ -602,7 +602,8 @@ var CPViewHighDPIDrawingEnabled = YES;
// We will have to adjust the z-index of all views starting at this index.
var count = _subviews.length,
lastWindow;
lastWindow,
isNewAddOrMove = aSubview._superview !== self;
// Dirty the key view loop, in case the window wants to auto recalculate it
[[self window] _dirtyKeyViewLoop];
@@ -637,15 +638,6 @@ var CPViewHighDPIDrawingEnabled = YES;
// Remove the view from its previous superview.
[aSubview _removeFromSuperview];
// Set the subview's window to our own.
// This must happen before _setSuperview so that the window is available
// in notifications like viewDidAppear.
if (_window)
[aSubview _setWindow:_window];
if (!_window && lastWindow)
[aSubview _setWindow:nil];
[aSubview _postViewWillAppearNotification];
// Set ourselves as the superview.
[aSubview _setSuperview:self];
@@ -675,6 +667,16 @@ var CPViewHighDPIDrawingEnabled = YES;
[aSubview viewDidMoveToSuperview];
// Set the subview's window to our own.
if (_window)
[aSubview _setWindow:_window];
if (!_window && lastWindow)
[aSubview _setWindow:nil];
if (isNewAddOrMove)
[aSubview _postViewDidAppearNotification];
// This method might be called before we are fully unarchived, in which case the theme state isn't set up yet
// and none of the below matters anyhow.
if (_themeState)
@@ -737,6 +739,7 @@ var CPViewHighDPIDrawingEnabled = YES;
// If the view is not hidden and one of its ancestors is hidden,
// notify the view that it is now unhidden.
[self _setSuperview:nil];
[self _postViewDidDisappearNotification];
[self _notifyWindowDidResignKey];
[self _notifyViewDidResignFirstResponder];
@@ -1721,11 +1724,7 @@ var CPViewHighDPIDrawingEnabled = YES;
_superview = aSuperview;
if (hasOldSuperview)
[self _postViewDidDisappearNotification];
if (hasNewSuperview)
[self _postViewDidAppearNotification];
// Notifications are now posted manually from _insertSubview and _removeFromSuperview
}
- (void)_recursiveLostHiddenAncestor