Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1648)

Unified Diff: ui/views/cocoa/widget_owner_nswindow_adapter.mm

Issue 2448243003: MacViews: Reattach children of native windows when they are exposed. (Closed)
Patch Set: +test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/cocoa/widget_owner_nswindow_adapter.mm
diff --git a/ui/views/cocoa/widget_owner_nswindow_adapter.mm b/ui/views/cocoa/widget_owner_nswindow_adapter.mm
index 63cc4468d95449b86bbb6a2a2a8ab06cf9dd2c54..523453591a6be0e0b060321a25ce5fed27a37df4 100644
--- a/ui/views/cocoa/widget_owner_nswindow_adapter.mm
+++ b/ui/views/cocoa/widget_owner_nswindow_adapter.mm
@@ -21,6 +21,7 @@
}
- (instancetype)initWithAdapter:(views::WidgetOwnerNSWindowAdapter*)adapter;
- (void)windowWillClose:(NSNotification*)notification;
+- (void)windowDidChangeOcclusionState:(NSNotification*)notification;
@end
@implementation WidgetOwnerNSWindowAdapterBridge
@@ -35,6 +36,10 @@
adapter_->OnWindowWillClose();
}
+- (void)windowDidChangeOcclusionState:(NSNotification*)notification {
+ adapter_->OnWindowDidChangeOcclusionState();
+}
+
@end
namespace views {
@@ -59,6 +64,12 @@ WidgetOwnerNSWindowAdapter::WidgetOwnerNSWindowAdapter(
selector:@selector(windowWillClose:)
name:NSWindowWillCloseNotification
object:anchor_window_];
+
+ [[NSNotificationCenter defaultCenter]
karandeepb 2016/10/27 03:21:17 Maybe add a comment explaining why we need to obse
tapted 2016/10/27 04:06:48 Done.
+ addObserver:observer_bridge_
+ selector:@selector(windowDidChangeOcclusionState:)
+ name:NSWindowDidChangeOcclusionStateNotification
+ object:anchor_window_];
}
void WidgetOwnerNSWindowAdapter::OnWindowWillClose() {
@@ -80,6 +91,30 @@ void WidgetOwnerNSWindowAdapter::OnWindowWillClose() {
DCHECK(![child_window delegate]);
}
+void WidgetOwnerNSWindowAdapter::OnWindowDidChangeOcclusionState() {
+ // The adapter only needs to handle a parent "show", since the only way it
+ // should be hidden is via -[NSApp hide], and all BridgedNativeWidgets
+ // subscribe to NSApplicationDidHideNotification already.
+ if (![anchor_window_ isVisible])
karandeepb 2016/10/27 03:21:17 Just to clarify, the parent-child relationship bre
tapted 2016/10/27 04:06:48 Yup. AppKit fails to update zorder/position for ch
+ return;
+
+ if (child_->window_visible()) {
+ DCHECK(child_->wants_to_be_visible());
karandeepb 2016/10/27 03:21:17 Should we DCHECK([child->ns_window() parentWindow]
tapted 2016/10/27 04:06:48 Done.
+ return;
+ }
+
+ if (!child_->wants_to_be_visible())
+ return;
+
karandeepb 2016/10/27 03:21:17 So now the parent is visible, and the child is hid
tapted 2016/10/27 04:06:48 I don't think this is the same. The parent window
+ // The parent relationship should have been removed when the child was hidden.
+ DCHECK(![child_->ns_window() parentWindow]);
karandeepb 2016/10/27 03:21:17 Can this DCHECK move before the preceding if condi
tapted 2016/10/27 04:06:48 Done.
+ [child_->ns_window() orderWindow:NSWindowAbove
+ relativeTo:[anchor_window_ windowNumber]];
+
+ // Ordering the window should add back the relationship.
+ DCHECK([child_->ns_window() parentWindow]);
karandeepb 2016/10/27 03:21:17 DCHECK(child_->window_visible())?
tapted 2016/10/27 04:06:48 Done.
+}
+
NSWindow* WidgetOwnerNSWindowAdapter::GetNSWindow() {
return anchor_window_;
}

Powered by Google App Engine
This is Rietveld 408576698