OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ui/views/cocoa/views_nswindow_delegate.h" | 5 #import "ui/views/cocoa/views_nswindow_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "ui/views/cocoa/bridged_content_view.h" | 8 #import "ui/views/cocoa/bridged_content_view.h" |
9 #import "ui/views/cocoa/bridged_native_widget.h" | 9 #import "ui/views/cocoa/bridged_native_widget.h" |
10 #include "ui/views/widget/native_widget_mac.h" | 10 #include "ui/views/widget/native_widget_mac.h" |
11 | 11 |
12 @implementation ViewsNSWindowDelegate | 12 @implementation ViewsNSWindowDelegate |
13 | 13 |
| 14 @synthesize transientChild = transientChild_; |
| 15 |
14 - (id)initWithBridgedNativeWidget:(views::BridgedNativeWidget*)parent { | 16 - (id)initWithBridgedNativeWidget:(views::BridgedNativeWidget*)parent { |
15 DCHECK(parent); | 17 DCHECK(parent); |
16 if ((self = [super init])) { | 18 if ((self = [super init])) { |
17 parent_ = parent; | 19 parent_ = parent; |
18 } | 20 } |
19 return self; | 21 return self; |
20 } | 22 } |
21 | 23 |
22 - (views::NativeWidgetMac*)nativeWidgetMac { | 24 - (views::NativeWidgetMac*)nativeWidgetMac { |
23 return parent_->native_widget_mac(); | 25 return parent_->native_widget_mac(); |
24 } | 26 } |
25 | 27 |
26 - (void)onWindowOrderWillChange:(NSWindowOrderingMode)orderingMode { | 28 - (void)onWindowOrderWillChange:(NSWindowOrderingMode)orderingMode { |
27 if (orderingMode != NSWindowOut) | 29 if (orderingMode != NSWindowOut) |
28 [parent_->ns_view() setWillShow:YES]; | 30 [parent_->ns_view() setWillShow:YES]; |
29 } | 31 } |
30 | 32 |
31 - (void)onWindowOrderChanged { | 33 - (void)onWindowOrderChanged:(NSNotification*)notification { |
32 [parent_->ns_view() setWillShow:NO]; | 34 [parent_->ns_view() setWillShow:NO]; |
| 35 parent_->OnVisibilityChanged(); |
33 } | 36 } |
34 | 37 |
35 // NSWindowDelegate implementation. | 38 // NSWindowDelegate implementation. |
36 | 39 |
37 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window { | 40 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window { |
38 // Cocoa should already have sent an (unexpected) windowDidExitFullScreen: | 41 // Cocoa should already have sent an (unexpected) windowDidExitFullScreen: |
39 // notification, and the attempt to get back into fullscreen should fail. | 42 // notification, and the attempt to get back into fullscreen should fail. |
40 // Nothing to do except verify |parent_| is no longer trying to fullscreen. | 43 // Nothing to do except verify |parent_| is no longer trying to fullscreen. |
41 DCHECK(!parent_->target_fullscreen_state()); | 44 DCHECK(!parent_->target_fullscreen_state()); |
42 } | 45 } |
43 | 46 |
44 - (void)windowDidFailToExitFullScreen:(NSWindow*)window { | 47 - (void)windowDidFailToExitFullScreen:(NSWindow*)window { |
45 // Unlike entering fullscreen, windowDidFailToExitFullScreen: is sent *before* | 48 // Unlike entering fullscreen, windowDidFailToExitFullScreen: is sent *before* |
46 // windowDidExitFullScreen:. Also, failing to exit fullscreen just dumps the | 49 // windowDidExitFullScreen:. Also, failing to exit fullscreen just dumps the |
47 // window out of fullscreen without an animation; still sending the expected, | 50 // window out of fullscreen without an animation; still sending the expected, |
48 // windowDidExitFullScreen: notification. So, again, nothing to do here. | 51 // windowDidExitFullScreen: notification. So, again, nothing to do here. |
49 DCHECK(!parent_->target_fullscreen_state()); | 52 DCHECK(!parent_->target_fullscreen_state()); |
50 } | 53 } |
51 | 54 |
| 55 - (void)windowDidResize:(NSNotification*)notification { |
| 56 parent_->OnSizeChanged(); |
| 57 } |
| 58 |
| 59 - (void)windowDidMove:(NSNotification*)notification { |
| 60 parent_->native_widget_mac()->GetWidget()->OnNativeWidgetMove(); |
| 61 } |
| 62 |
52 - (void)windowDidBecomeKey:(NSNotification*)notification { | 63 - (void)windowDidBecomeKey:(NSNotification*)notification { |
53 parent_->native_widget_mac()->GetWidget()->OnNativeWidgetActivationChanged( | 64 parent_->native_widget_mac()->GetWidget()->OnNativeWidgetActivationChanged( |
54 true); | 65 true); |
55 } | 66 } |
56 | 67 |
57 - (void)windowDidResignKey:(NSNotification*)notification { | 68 - (void)windowDidResignKey:(NSNotification*)notification { |
58 parent_->native_widget_mac()->GetWidget()->OnNativeWidgetActivationChanged( | 69 parent_->native_widget_mac()->GetWidget()->OnNativeWidgetActivationChanged( |
59 false); | 70 false); |
60 } | 71 } |
61 | 72 |
62 - (void)windowWillClose:(NSNotification*)notification { | 73 - (void)windowWillClose:(NSNotification*)notification { |
63 DCHECK([parent_->ns_window() isEqual:[notification object]]); | 74 DCHECK([parent_->ns_window() isEqual:[notification object]]); |
64 parent_->OnWindowWillClose(); | 75 parent_->OnWindowWillClose(); |
65 } | 76 } |
66 | 77 |
| 78 - (void)windowDidMiniaturize:(NSNotification*)notification { |
| 79 parent_->OnVisibilityChanged(); |
| 80 } |
| 81 |
| 82 - (void)windowDidDeminiaturize:(NSNotification*)notification { |
| 83 parent_->OnVisibilityChanged(); |
| 84 } |
| 85 |
67 - (void)windowWillEnterFullScreen:(NSNotification*)notification { | 86 - (void)windowWillEnterFullScreen:(NSNotification*)notification { |
68 parent_->OnFullscreenTransitionStart(true); | 87 parent_->OnFullscreenTransitionStart(true); |
69 } | 88 } |
70 | 89 |
71 - (void)windowDidEnterFullScreen:(NSNotification*)notification { | 90 - (void)windowDidEnterFullScreen:(NSNotification*)notification { |
72 parent_->OnFullscreenTransitionComplete(true); | 91 parent_->OnFullscreenTransitionComplete(true); |
73 } | 92 } |
74 | 93 |
75 - (void)windowWillExitFullScreen:(NSNotification*)notification { | 94 - (void)windowWillExitFullScreen:(NSNotification*)notification { |
76 parent_->OnFullscreenTransitionStart(false); | 95 parent_->OnFullscreenTransitionStart(false); |
77 } | 96 } |
78 | 97 |
79 - (void)windowDidExitFullScreen:(NSNotification*)notification { | 98 - (void)windowDidExitFullScreen:(NSNotification*)notification { |
80 parent_->OnFullscreenTransitionComplete(false); | 99 parent_->OnFullscreenTransitionComplete(false); |
81 } | 100 } |
82 | 101 |
| 102 - (void)windowDidChangeScreen:(NSNotification*)notification { |
| 103 parent_->OnDisplayChanged(); |
| 104 } |
| 105 |
| 106 - (void)windowDidChangeScreenProfile:(NSNotification*)notification { |
| 107 parent_->OnDisplayChanged(); |
| 108 } |
| 109 |
| 110 - (void)windowDidChangeBackingProperties:(NSNotification*)notification { |
| 111 parent_->OnDisplayChanged(); |
| 112 } |
| 113 |
| 114 - (void)windowWillStartLiveResize:(NSNotification*)notification { |
| 115 parent_->native_widget_mac() |
| 116 ->GetWidget() |
| 117 ->OnNativeWidgetBeginUserBoundsChange(); |
| 118 } |
| 119 |
| 120 - (void)windowDidEndLiveResize:(NSNotification*)notification { |
| 121 parent_->native_widget_mac() |
| 122 ->GetWidget() |
| 123 ->OnNativeWidgetEndUserBoundsChange(); |
| 124 } |
| 125 |
83 @end | 126 @end |
OLD | NEW |