| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Send to the menu, after converting the event into an action message using | 124 // Send to the menu, after converting the event into an action message using |
| 125 // the content view. | 125 // the content view. |
| 126 if (type == NSKeyDown) | 126 if (type == NSKeyDown) |
| 127 [[self contentView] keyDown:event]; | 127 [[self contentView] keyDown:event]; |
| 128 else | 128 else |
| 129 [[self contentView] keyUp:event]; | 129 [[self contentView] keyUp:event]; |
| 130 } | 130 } |
| 131 | 131 |
| 132 // Override display, since this is the first opportunity Cocoa gives to detect | |
| 133 // a visibility change in some cases. For example, restoring from the dock first | |
| 134 // calls -[NSWindow display] before any NSWindowDelegate functions and before | |
| 135 // ordering the window (and without actually calling -[NSWindow deminiaturize]). | |
| 136 // By notifying the delegate that a display is about to occur, it can apply a | |
| 137 // correct visibility state, before [super display] requests a draw of the | |
| 138 // contentView. -[NSWindow isVisible] can still report NO at this point, so this | |
| 139 // gives the delegate time to apply correct visibility before the draw occurs. | |
| 140 - (void)display { | |
| 141 [[self viewsNSWindowDelegate] onWindowWillDisplay]; | |
| 142 [super display]; | |
| 143 } | |
| 144 | |
| 145 // Override window order functions to intercept other visibility changes. This | 132 // Override window order functions to intercept other visibility changes. This |
| 146 // is needed in addition to the -[NSWindow display] override because Cocoa | 133 // is needed in addition to the -[NSWindow display] override because Cocoa |
| 147 // hardly ever calls display, and reports -[NSWindow isVisible] incorrectly | 134 // hardly ever calls display, and reports -[NSWindow isVisible] incorrectly |
| 148 // when ordering in a window for the first time. | 135 // when ordering in a window for the first time. |
| 149 - (void)orderWindow:(NSWindowOrderingMode)orderingMode | 136 - (void)orderWindow:(NSWindowOrderingMode)orderingMode |
| 150 relativeTo:(NSInteger)otherWindowNumber { | 137 relativeTo:(NSInteger)otherWindowNumber { |
| 151 [[self viewsNSWindowDelegate] onWindowOrderWillChange:orderingMode]; | |
| 152 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; | 138 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; |
| 153 [[self viewsNSWindowDelegate] onWindowOrderChanged:nil]; | 139 [[self viewsNSWindowDelegate] onWindowOrderChanged:nil]; |
| 154 } | 140 } |
| 155 | 141 |
| 156 // NSResponder implementation. | 142 // NSResponder implementation. |
| 157 | 143 |
| 158 - (BOOL)performKeyEquivalent:(NSEvent*)event { | 144 - (BOOL)performKeyEquivalent:(NSEvent*)event { |
| 159 return [commandDispatcher_ performKeyEquivalent:event]; | 145 return [commandDispatcher_ performKeyEquivalent:event]; |
| 160 } | 146 } |
| 161 | 147 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 id appController = [NSApp delegate]; | 201 id appController = [NSApp delegate]; |
| 216 DCHECK([appController | 202 DCHECK([appController |
| 217 conformsToProtocol:@protocol(NSUserInterfaceValidations)]); | 203 conformsToProtocol:@protocol(NSUserInterfaceValidations)]); |
| 218 return [appController validateUserInterfaceItem:item]; | 204 return [appController validateUserInterfaceItem:item]; |
| 219 } | 205 } |
| 220 | 206 |
| 221 return [super validateUserInterfaceItem:item]; | 207 return [super validateUserInterfaceItem:item]; |
| 222 } | 208 } |
| 223 | 209 |
| 224 @end | 210 @end |
| OLD | NEW |