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

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

Issue 2251123002: macviews: honor system control tint setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use luminance Created 4 years, 4 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 | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/cocoa/views_nswindow_delegate.h » ('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/bridged_native_widget.h" 5 #import "ui/views/cocoa/bridged_native_widget.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #import "base/mac/foundation_util.h" 12 #import "base/mac/foundation_util.h"
13 #include "base/mac/mac_util.h" 13 #include "base/mac/mac_util.h"
14 #import "base/mac/sdk_forward_declarations.h" 14 #import "base/mac/sdk_forward_declarations.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" 16 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
17 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" 17 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
18 #include "ui/base/hit_test.h" 18 #include "ui/base/hit_test.h"
19 #include "ui/base/ime/input_method.h" 19 #include "ui/base/ime/input_method.h"
20 #include "ui/base/ime/input_method_factory.h" 20 #include "ui/base/ime/input_method_factory.h"
21 #include "ui/display/display.h" 21 #include "ui/display/display.h"
22 #include "ui/display/screen.h" 22 #include "ui/display/screen.h"
23 #include "ui/gfx/geometry/dip_util.h" 23 #include "ui/gfx/geometry/dip_util.h"
24 #import "ui/gfx/mac/coordinate_conversion.h" 24 #import "ui/gfx/mac/coordinate_conversion.h"
25 #import "ui/gfx/mac/nswindow_frame_controls.h" 25 #import "ui/gfx/mac/nswindow_frame_controls.h"
26 #import "ui/native_theme/native_theme_mac.h"
26 #import "ui/views/cocoa/bridged_content_view.h" 27 #import "ui/views/cocoa/bridged_content_view.h"
27 #import "ui/views/cocoa/drag_drop_client_mac.h" 28 #import "ui/views/cocoa/drag_drop_client_mac.h"
28 #import "ui/views/cocoa/cocoa_mouse_capture.h" 29 #import "ui/views/cocoa/cocoa_mouse_capture.h"
29 #import "ui/views/cocoa/cocoa_window_move_loop.h" 30 #import "ui/views/cocoa/cocoa_window_move_loop.h"
30 #include "ui/views/cocoa/tooltip_manager_mac.h" 31 #include "ui/views/cocoa/tooltip_manager_mac.h"
31 #import "ui/views/cocoa/views_nswindow_delegate.h" 32 #import "ui/views/cocoa/views_nswindow_delegate.h"
32 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h" 33 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h"
33 #include "ui/views/view.h" 34 #include "ui/views/view.h"
34 #include "ui/views/views_delegate.h" 35 #include "ui/views/views_delegate.h"
35 #include "ui/views/widget/native_widget_mac.h" 36 #include "ui/views/widget/native_widget_mac.h"
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // tied to the C++ object, rather than the delegate (which may be reference 393 // tied to the C++ object, rather than the delegate (which may be reference
393 // counted). This is required since the application hides do not send an 394 // counted). This is required since the application hides do not send an
394 // orderOut: to individual windows. Unhide, however, does send an order 395 // orderOut: to individual windows. Unhide, however, does send an order
395 // message. 396 // message.
396 [[NSNotificationCenter defaultCenter] 397 [[NSNotificationCenter defaultCenter]
397 addObserver:window_delegate_ 398 addObserver:window_delegate_
398 selector:@selector(onWindowOrderChanged:) 399 selector:@selector(onWindowOrderChanged:)
399 name:NSApplicationDidHideNotification 400 name:NSApplicationDidHideNotification
400 object:nil]; 401 object:nil];
401 402
403 [[NSNotificationCenter defaultCenter]
404 addObserver:window_delegate_
405 selector:@selector(onSystemControlTintChanged:)
406 name:NSControlTintDidChangeNotification
407 object:nil];
408
402 // Validate the window's initial state, otherwise the bridge's initial 409 // Validate the window's initial state, otherwise the bridge's initial
403 // tracking state will be incorrect. 410 // tracking state will be incorrect.
404 DCHECK(![window_ isVisible]); 411 DCHECK(![window_ isVisible]);
405 DCHECK_EQ(0u, [window_ styleMask] & NSFullScreenWindowMask); 412 DCHECK_EQ(0u, [window_ styleMask] & NSFullScreenWindowMask);
406 413
407 if (params.parent) { 414 if (params.parent) {
408 // Disallow creating child windows of views not currently in an NSWindow. 415 // Disallow creating child windows of views not currently in an NSWindow.
409 CHECK([params.parent window]); 416 CHECK([params.parent window]);
410 BridgedNativeWidget* bridged_native_widget_parent = 417 BridgedNativeWidget* bridged_native_widget_parent =
411 NativeWidgetMac::GetBridgeForNativeWindow([params.parent window]); 418 NativeWidgetMac::GetBridgeForNativeWindow([params.parent window]);
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 native_widget_mac_->GetWidget()->OnNativeWidgetVisibilityChanged( 833 native_widget_mac_->GetWidget()->OnNativeWidgetVisibilityChanged(
827 window_visible_); 834 window_visible_);
828 835
829 // Toolkit-views suppresses redraws while not visible. To prevent Cocoa asking 836 // Toolkit-views suppresses redraws while not visible. To prevent Cocoa asking
830 // for an "empty" draw, disable auto-display while hidden. For example, this 837 // for an "empty" draw, disable auto-display while hidden. For example, this
831 // prevents Cocoa drawing just *after* a minimize, resulting in a blank window 838 // prevents Cocoa drawing just *after* a minimize, resulting in a blank window
832 // represented in the deminiaturize animation. 839 // represented in the deminiaturize animation.
833 [window_ setAutodisplay:window_visible_]; 840 [window_ setAutodisplay:window_visible_];
834 } 841 }
835 842
843 void BridgedNativeWidget::OnSystemControlTintChanged() {
844 ui::NativeThemeMac::instance()->NotifyObservers();
845 }
846
836 void BridgedNativeWidget::OnBackingPropertiesChanged() { 847 void BridgedNativeWidget::OnBackingPropertiesChanged() {
837 if (layer()) 848 if (layer())
838 UpdateLayerProperties(); 849 UpdateLayerProperties();
839 } 850 }
840 851
841 void BridgedNativeWidget::OnWindowKeyStatusChangedTo(bool is_key) { 852 void BridgedNativeWidget::OnWindowKeyStatusChangedTo(bool is_key) {
842 Widget* widget = native_widget_mac()->GetWidget(); 853 Widget* widget = native_widget_mac()->GetWidget();
843 widget->OnNativeWidgetActivationChanged(is_key); 854 widget->OnNativeWidgetActivationChanged(is_key);
844 // The contentView is the BridgedContentView hosting the views::RootView. The 855 // The contentView is the BridgedContentView hosting the views::RootView. The
845 // focus manager will already know if a native subview has focus. 856 // focus manager will already know if a native subview has focus.
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 [bridged_view_ setMouseDownCanMoveWindow:draggable]; 1365 [bridged_view_ setMouseDownCanMoveWindow:draggable];
1355 // AppKit will not update its cache of mouseDownCanMoveWindow unless something 1366 // AppKit will not update its cache of mouseDownCanMoveWindow unless something
1356 // changes. Previously we tried adding an NSView and removing it, but for some 1367 // changes. Previously we tried adding an NSView and removing it, but for some
1357 // reason it required reposting the mouse-down event, and didn't always work. 1368 // reason it required reposting the mouse-down event, and didn't always work.
1358 // Calling the below seems to be an effective solution. 1369 // Calling the below seems to be an effective solution.
1359 [window_ setMovableByWindowBackground:NO]; 1370 [window_ setMovableByWindowBackground:NO];
1360 [window_ setMovableByWindowBackground:YES]; 1371 [window_ setMovableByWindowBackground:YES];
1361 } 1372 }
1362 1373
1363 } // namespace views 1374 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/cocoa/views_nswindow_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698