Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: ui/views/cocoa/native_widget_mac_nswindow.mm

Issue 1614663002: MacViews: Bubbles and dialogs behave more like sheets wrt main status (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A test!@ Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/widget/native_widget_mac_interactive_uitest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | ui/views/widget/native_widget_mac_interactive_uitest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698