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/native_widget_mac_nswindow.h" | 5 #import "ui/views/cocoa/native_widget_mac_nswindow.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #import "ui/views/cocoa/bridged_native_widget.h" | 8 #import "ui/views/cocoa/bridged_native_widget.h" |
9 #import "ui/base/cocoa/user_interface_item_command_handler.h" | 9 #import "ui/base/cocoa/user_interface_item_command_handler.h" |
10 #import "ui/views/cocoa/views_nswindow_delegate.h" | 10 #import "ui/views/cocoa/views_nswindow_delegate.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 116 } |
117 | 117 |
118 // Send to the menu, after converting the event into an action message using | 118 // Send to the menu, after converting the event into an action message using |
119 // the content view. | 119 // the content view. |
120 if (type == NSKeyDown) | 120 if (type == NSKeyDown) |
121 [[self contentView] keyDown:event]; | 121 [[self contentView] keyDown:event]; |
122 else | 122 else |
123 [[self contentView] keyUp:event]; | 123 [[self contentView] keyUp:event]; |
124 } | 124 } |
125 | 125 |
126 // Override display, since this is the first opportunity Cocoa gives to detect | |
127 // a visibility change in some cases. For example, restoring from the dock first | |
128 // calls -[NSWindow display] before any NSWindowDelegate functions and before | |
129 // ordering the window (and without actually calling -[NSWindow deminiaturize]). | |
130 // By notifying the delegate that a display is about to occur, it can apply a | |
131 // correct visibility state, before [super display] requests a draw of the | |
132 // contentView. -[NSWindow isVisible] can still report NO at this point, so this | |
133 // gives the delegate time to apply correct visibility before the draw occurs. | |
134 - (void)display { | |
135 [[self viewsNSWindowDelegate] onWindowWillDisplay]; | |
136 [super display]; | |
137 } | |
138 | |
139 // Override window order functions to intercept other visibility changes. This | 126 // Override window order functions to intercept other visibility changes. This |
140 // is needed in addition to the -[NSWindow display] override because Cocoa | 127 // is needed in addition to the -[NSWindow display] override because Cocoa |
141 // hardly ever calls display, and reports -[NSWindow isVisible] incorrectly | 128 // hardly ever calls display, and reports -[NSWindow isVisible] incorrectly |
142 // when ordering in a window for the first time. | 129 // when ordering in a window for the first time. |
143 - (void)orderWindow:(NSWindowOrderingMode)orderingMode | 130 - (void)orderWindow:(NSWindowOrderingMode)orderingMode |
144 relativeTo:(NSInteger)otherWindowNumber { | 131 relativeTo:(NSInteger)otherWindowNumber { |
145 [[self viewsNSWindowDelegate] onWindowOrderWillChange:orderingMode]; | |
146 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; | 132 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; |
147 [[self viewsNSWindowDelegate] onWindowOrderChanged:nil]; | 133 [[self viewsNSWindowDelegate] onWindowOrderChanged:nil]; |
148 } | 134 } |
149 | 135 |
150 // NSResponder implementation. | 136 // NSResponder implementation. |
151 | 137 |
152 - (BOOL)performKeyEquivalent:(NSEvent*)event { | 138 - (BOOL)performKeyEquivalent:(NSEvent*)event { |
153 return [commandDispatcher_ performKeyEquivalent:event]; | 139 return [commandDispatcher_ performKeyEquivalent:event]; |
154 } | 140 } |
155 | 141 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 id appController = [NSApp delegate]; | 195 id appController = [NSApp delegate]; |
210 DCHECK([appController | 196 DCHECK([appController |
211 conformsToProtocol:@protocol(NSUserInterfaceValidations)]); | 197 conformsToProtocol:@protocol(NSUserInterfaceValidations)]); |
212 return [appController validateUserInterfaceItem:item]; | 198 return [appController validateUserInterfaceItem:item]; |
213 } | 199 } |
214 | 200 |
215 return [super validateUserInterfaceItem:item]; | 201 return [super validateUserInterfaceItem:item]; |
216 } | 202 } |
217 | 203 |
218 @end | 204 @end |
OLD | NEW |