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