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

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

Issue 630363003: More NativeWidget -> Widget notifications: visibility, minimize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20140704-Mac-VIEWS-ActivationChanges
Patch Set: rebase on crrev/654393002 Created 6 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
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/cocoa/views_nswindow_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_native_widget.mm
diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
index 560f533009df6cd8efb4132130a2ed2640e7074a..91d4ff642d656e65f71afe42a652113c3a5fb6cb 100644
--- a/ui/views/cocoa/bridged_native_widget.mm
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -25,7 +25,8 @@ BridgedNativeWidget::BridgedNativeWidget(NativeWidgetMac* parent)
: native_widget_mac_(parent),
focus_manager_(NULL),
target_fullscreen_state_(false),
- in_fullscreen_transition_(false) {
+ in_fullscreen_transition_(false),
+ window_visible_(false) {
DCHECK(parent);
window_delegate_.reset(
[[ViewsNSWindowDelegate alloc] initWithBridgedNativeWidget:this]);
@@ -50,6 +51,18 @@ void BridgedNativeWidget::Init(base::scoped_nsobject<NSWindow> window,
window_.swap(window);
[window_ setDelegate:window_delegate_];
+ // Register for application hide notifications so that visibility can be
+ // properly tracked. This is not done in the delegate so that the lifetime is
+ // tied to the C++ object, rather than the delegate (which may be reference
+ // counted). This is required since the application hides do not send an
+ // orderOut: to individual windows. Unhide, however, does send an order
+ // message.
+ [[NSNotificationCenter defaultCenter]
+ addObserver:window_delegate_
+ selector:@selector(onWindowOrderChanged:)
+ name:NSApplicationDidHideNotification
+ object:nil];
+
// Validate the window's initial state, otherwise the bridge's initial
// tracking state will be incorrect.
DCHECK(![window_ isVisible]);
@@ -97,6 +110,7 @@ void BridgedNativeWidget::SetRootView(views::View* view) {
void BridgedNativeWidget::OnWindowWillClose() {
[[window_ parentWindow] removeChildWindow:window_];
[window_ setDelegate:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:window_delegate_];
native_widget_mac_->OnWindowWillClose();
}
@@ -155,6 +169,15 @@ void BridgedNativeWidget::ToggleDesiredFullscreenState() {
[window_ setCollectionBehavior:behavior];
}
+void BridgedNativeWidget::OnVisibilityChanged() {
+ if (window_visible_ == [window_ isVisible])
+ return;
+
+ window_visible_ = [window_ isVisible];
+ native_widget_mac_->GetWidget()->OnNativeWidgetVisibilityChanged(
+ window_visible_);
+}
+
InputMethod* BridgedNativeWidget::CreateInputMethod() {
if (switches::IsTextInputFocusManagerEnabled())
return new NullInputMethod();
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/cocoa/views_nswindow_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698