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

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

Issue 1955343002: Mac: Use a "less" private API for keeping traffic lights lit while bubbles are showing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20160509-MacViews-HasActiveAppearance-upstream
Patch Set: Add a comment Created 4 years, 7 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
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/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"
11 #include "ui/views/controls/menu/menu_controller.h" 11 #include "ui/views/controls/menu/menu_controller.h"
12 #include "ui/views/widget/native_widget_mac.h" 12 #include "ui/views/widget/native_widget_mac.h"
13 #include "ui/views/widget/widget_delegate.h" 13 #include "ui/views/widget/widget_delegate.h"
14 14
15 @interface NSWindow (Private)
16 - (BOOL)hasKeyAppearance;
17 @end
18
15 @interface NativeWidgetMacNSWindow () 19 @interface NativeWidgetMacNSWindow ()
16 - (ViewsNSWindowDelegate*)viewsNSWindowDelegate; 20 - (ViewsNSWindowDelegate*)viewsNSWindowDelegate;
17 - (views::Widget*)viewsWidget; 21 - (views::Widget*)viewsWidget;
18 - (BOOL)hasViewsMenuActive; 22 - (BOOL)hasViewsMenuActive;
19 23
20 // Private API on NSWindow, determines whether the title is drawn on the title 24 // Private API on NSWindow, determines whether the title is drawn on the title
21 // bar. The title is still visible in menus, Expose, etc. 25 // bar. The title is still visible in menus, Expose, etc.
22 - (BOOL)_isTitleHidden; 26 - (BOOL)_isTitleHidden;
23 @end 27 @end
24 28
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (![self delegate]) 88 if (![self delegate])
85 return NO; 89 return NO;
86 90
87 // Dialogs and bubbles shouldn't take large shadows away from their parent. 91 // Dialogs and bubbles shouldn't take large shadows away from their parent.
88 views::Widget* widget = [self viewsWidget]; 92 views::Widget* widget = [self viewsWidget];
89 return widget->CanActivate() && 93 return widget->CanActivate() &&
90 !views::NativeWidgetMac::GetBridgeForNativeWindow(self)->parent(); 94 !views::NativeWidgetMac::GetBridgeForNativeWindow(self)->parent();
91 } 95 }
92 96
93 // Lets the traffic light buttons on the parent window keep their active state. 97 // Lets the traffic light buttons on the parent window keep their active state.
94 - (BOOL)_sharesParentKeyState { 98 - (BOOL)hasKeyAppearance {
95 // Follow -canBecomeMainWindow unless the window provides its own buttons. 99 if ([self delegate] && [self viewsWidget]->IsAlwaysRenderAsActive())
96 return ([self styleMask] & NSClosableWindowMask) == 0 && 100 return YES;
97 ![self canBecomeMainWindow]; 101 return [super hasKeyAppearance];
98 } 102 }
99 103
100 // Override sendEvent to allow key events to be forwarded to a toolkit-views 104 // Override sendEvent to allow key events to be forwarded to a toolkit-views
101 // menu while it is active, and while still allowing any native subview to 105 // menu while it is active, and while still allowing any native subview to
102 // retain firstResponder status. 106 // retain firstResponder status.
103 - (void)sendEvent:(NSEvent*)event { 107 - (void)sendEvent:(NSEvent*)event {
104 // Let CommandDispatcher check if this is a redispatched event. 108 // Let CommandDispatcher check if this is a redispatched event.
105 if ([commandDispatcher_ preSendEvent:event]) 109 if ([commandDispatcher_ preSendEvent:event])
106 return; 110 return;
107 111
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 id appController = [NSApp delegate]; 209 id appController = [NSApp delegate];
206 DCHECK([appController 210 DCHECK([appController
207 conformsToProtocol:@protocol(NSUserInterfaceValidations)]); 211 conformsToProtocol:@protocol(NSUserInterfaceValidations)]);
208 return [appController validateUserInterfaceItem:item]; 212 return [appController validateUserInterfaceItem:item];
209 } 213 }
210 214
211 return [super validateUserInterfaceItem:item]; 215 return [super validateUserInterfaceItem:item];
212 } 216 }
213 217
214 @end 218 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/chrome_browser_window.mm ('k') | ui/views/widget/native_widget_mac_interactive_uitest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698