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/base/cocoa/user_interface_item_command_handler.h" | 8 #import "ui/base/cocoa/user_interface_item_command_handler.h" |
9 #import "ui/views/cocoa/views_nswindow_delegate.h" | 9 #import "ui/views/cocoa/views_nswindow_delegate.h" |
10 #include "ui/views/controls/menu/menu_controller.h" | 10 #include "ui/views/controls/menu/menu_controller.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Note these can be called via -[NSWindow close] while the widget is being torn | 76 // Note these can be called via -[NSWindow close] while the widget is being torn |
77 // down, so check for a delegate. | 77 // down, so check for a delegate. |
78 - (BOOL)canBecomeKeyWindow { | 78 - (BOOL)canBecomeKeyWindow { |
79 return [self delegate] && [self viewsWidget]->CanActivate(); | 79 return [self delegate] && [self viewsWidget]->CanActivate(); |
80 } | 80 } |
81 | 81 |
82 - (BOOL)canBecomeMainWindow { | 82 - (BOOL)canBecomeMainWindow { |
83 if (![self delegate]) | 83 if (![self delegate]) |
84 return NO; | 84 return NO; |
85 | 85 |
86 // Dialogs shouldn't take large shadows away from their parent window. | 86 // Dialogs and bubbles shouldn't take large shadows away from their parent. |
87 views::Widget* widget = [self viewsWidget]; | 87 views::Widget* widget = [self viewsWidget]; |
88 return widget->CanActivate() && !widget->IsDialogBox(); | 88 return widget->CanActivate() && ![self parentWindow]; |
| 89 } |
| 90 |
| 91 // Lets the traffic light buttons on the parent window keep their active state. |
| 92 - (BOOL)_sharesParentKeyState { |
| 93 // Follow -canBecomeMainWindow unless the window provides its own buttons. |
| 94 return ([self styleMask] & NSClosableWindowMask) == 0 && |
| 95 ![self canBecomeMainWindow]; |
89 } | 96 } |
90 | 97 |
91 // Override sendEvent to allow key events to be forwarded to a toolkit-views | 98 // Override sendEvent to allow key events to be forwarded to a toolkit-views |
92 // menu while it is active, and while still allowing any native subview to | 99 // menu while it is active, and while still allowing any native subview to |
93 // retain firstResponder status. | 100 // retain firstResponder status. |
94 - (void)sendEvent:(NSEvent*)event { | 101 - (void)sendEvent:(NSEvent*)event { |
95 // Let CommandDispatcher check if this is a redispatched event. | 102 // Let CommandDispatcher check if this is a redispatched event. |
96 if ([commandDispatcher_ preSendEvent:event]) | 103 if ([commandDispatcher_ preSendEvent:event]) |
97 return; | 104 return; |
98 | 105 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 [item action] == @selector(commandDispatchUsingKeyModifiers:)) { | 199 [item action] == @selector(commandDispatchUsingKeyModifiers:)) { |
193 return commandHandler_ | 200 return commandHandler_ |
194 ? [commandHandler_ validateUserInterfaceItem:item window:self] | 201 ? [commandHandler_ validateUserInterfaceItem:item window:self] |
195 : [[NSApp delegate] validateUserInterfaceItem:item]; | 202 : [[NSApp delegate] validateUserInterfaceItem:item]; |
196 } | 203 } |
197 | 204 |
198 return [super validateUserInterfaceItem:item]; | 205 return [super validateUserInterfaceItem:item]; |
199 } | 206 } |
200 | 207 |
201 @end | 208 @end |
OLD | NEW |