mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: all children showing when showing child window (#40107)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -186,6 +186,9 @@ class NativeWindowMac : public NativeWindow,
|
||||
has_deferred_window_close_ = defer_close;
|
||||
}
|
||||
|
||||
void set_wants_to_be_visible(bool visible) { wants_to_be_visible_ = visible; }
|
||||
bool wants_to_be_visible() const { return wants_to_be_visible_; }
|
||||
|
||||
enum class VisualEffectState {
|
||||
kFollowWindow,
|
||||
kActive,
|
||||
@@ -252,6 +255,10 @@ class NativeWindowMac : public NativeWindow,
|
||||
// transition is complete.
|
||||
bool has_deferred_window_close_ = false;
|
||||
|
||||
// If true, the window is either visible, or wants to be visible but is
|
||||
// currently hidden due to having a hidden parent.
|
||||
bool wants_to_be_visible_ = false;
|
||||
|
||||
NSInteger attention_request_id_ = 0; // identifier from requestUserAttention
|
||||
|
||||
// The presentation options before entering kiosk mode.
|
||||
|
||||
@@ -498,6 +498,8 @@ void NativeWindowMac::Show() {
|
||||
return;
|
||||
}
|
||||
|
||||
set_wants_to_be_visible(true);
|
||||
|
||||
// Reattach the window to the parent to actually show it.
|
||||
if (parent())
|
||||
InternalSetParentWindow(parent(), true);
|
||||
@@ -530,6 +532,10 @@ void NativeWindowMac::Hide() {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the window wants to be visible and has a parent, then the parent may
|
||||
// order it back in (in the period between orderOut: and close).
|
||||
set_wants_to_be_visible(false);
|
||||
|
||||
DetachChildren();
|
||||
|
||||
// Detach the window from the parent before.
|
||||
@@ -665,6 +671,9 @@ void NativeWindowMac::RemoveChildFromParentWindow() {
|
||||
|
||||
void NativeWindowMac::AttachChildren() {
|
||||
for (auto* child : child_windows_) {
|
||||
if (!static_cast<NativeWindowMac*>(child)->wants_to_be_visible())
|
||||
continue;
|
||||
|
||||
auto* child_nswindow = child->GetNativeWindow().GetNativeNSWindow();
|
||||
if ([child_nswindow parentWindow] == window_)
|
||||
continue;
|
||||
@@ -678,8 +687,6 @@ void NativeWindowMac::AttachChildren() {
|
||||
}
|
||||
|
||||
void NativeWindowMac::DetachChildren() {
|
||||
DCHECK(child_windows_.size() == [[window_ childWindows] count]);
|
||||
|
||||
// Hide all children before hiding/minimizing the window.
|
||||
// NativeWidgetNSWindowBridge::NotifyVisibilityChangeDown()
|
||||
// will DCHECK otherwise.
|
||||
|
||||
@@ -258,6 +258,7 @@ using FullScreenTransitionState =
|
||||
[super windowDidMiniaturize:notification];
|
||||
is_minimized_ = true;
|
||||
|
||||
shell_->set_wants_to_be_visible(false);
|
||||
shell_->NotifyWindowMinimize();
|
||||
}
|
||||
|
||||
@@ -265,6 +266,7 @@ using FullScreenTransitionState =
|
||||
[super windowDidDeminiaturize:notification];
|
||||
is_minimized_ = false;
|
||||
|
||||
shell_->set_wants_to_be_visible(true);
|
||||
shell_->AttachChildren();
|
||||
shell_->SetWindowLevel(level_);
|
||||
shell_->NotifyWindowRestore();
|
||||
|
||||
Reference in New Issue
Block a user