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/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 |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 UpdateLayerProperties(); | 775 UpdateLayerProperties(); |
776 if ([window_ inLiveResize]) | 776 if ([window_ inLiveResize]) |
777 MaybeWaitForFrame(new_size); | 777 MaybeWaitForFrame(new_size); |
778 } | 778 } |
779 | 779 |
780 // 10.9 is unable to generate a window shadow from the composited CALayer, so | 780 // 10.9 is unable to generate a window shadow from the composited CALayer, so |
781 // use Quartz. | 781 // use Quartz. |
782 // We don't update the window mask during a live resize, instead it is done | 782 // We don't update the window mask during a live resize, instead it is done |
783 // after the resize is completed in viewDidEndLiveResize: in | 783 // after the resize is completed in viewDidEndLiveResize: in |
784 // BridgedContentView. | 784 // BridgedContentView. |
785 if (base::mac::IsOSMavericks() && ![window_ inLiveResize]) | 785 if (base::mac::IsOS10_9() && ![window_ inLiveResize]) |
786 [bridged_view_ updateWindowMask]; | 786 [bridged_view_ updateWindowMask]; |
787 } | 787 } |
788 | 788 |
789 void BridgedNativeWidget::OnPositionChanged() { | 789 void BridgedNativeWidget::OnPositionChanged() { |
790 native_widget_mac_->GetWidget()->OnNativeWidgetMove(); | 790 native_widget_mac_->GetWidget()->OnNativeWidgetMove(); |
791 } | 791 } |
792 | 792 |
793 void BridgedNativeWidget::OnVisibilityChanged() { | 793 void BridgedNativeWidget::OnVisibilityChanged() { |
794 const bool window_visible = [window_ isVisible]; | 794 const bool window_visible = [window_ isVisible]; |
795 if (window_visible_ == window_visible) | 795 if (window_visible_ == window_visible) |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 // blocks the UI thread, so there's no way to invalidate the shadow to match | 972 // blocks the UI thread, so there's no way to invalidate the shadow to match |
973 // the composited layer. This assumes the native window shape is a good match | 973 // the composited layer. This assumes the native window shape is a good match |
974 // for the composited NonClientFrameView, which should be the case since the | 974 // for the composited NonClientFrameView, which should be the case since the |
975 // native shape is what's most appropriate for displaying sheets on Mac. | 975 // native shape is what's most appropriate for displaying sheets on Mac. |
976 if (translucent && !native_widget_mac_->IsWindowModalSheet()) { | 976 if (translucent && !native_widget_mac_->IsWindowModalSheet()) { |
977 [window_ setOpaque:NO]; | 977 [window_ setOpaque:NO]; |
978 // For Mac OS versions earlier than Yosemite, the Window server isn't able | 978 // For Mac OS versions earlier than Yosemite, the Window server isn't able |
979 // to generate a window shadow from the composited CALayer. To get around | 979 // to generate a window shadow from the composited CALayer. To get around |
980 // this, let the window background remain opaque and clip the window | 980 // this, let the window background remain opaque and clip the window |
981 // boundary in drawRect method of BridgedContentView. See crbug.com/543671. | 981 // boundary in drawRect method of BridgedContentView. See crbug.com/543671. |
982 if (base::mac::IsOSYosemiteOrLater()) | 982 if (base::mac::IsAtLeastOS10_10()) |
983 [window_ setBackgroundColor:[NSColor clearColor]]; | 983 [window_ setBackgroundColor:[NSColor clearColor]]; |
984 } | 984 } |
985 | 985 |
986 UpdateLayerProperties(); | 986 UpdateLayerProperties(); |
987 } | 987 } |
988 | 988 |
989 void BridgedNativeWidget::SetAssociationForView(const views::View* view, | 989 void BridgedNativeWidget::SetAssociationForView(const views::View* view, |
990 NSView* native_view) { | 990 NSView* native_view) { |
991 DCHECK_EQ(0u, associated_views_.count(view)); | 991 DCHECK_EQ(0u, associated_views_.count(view)); |
992 associated_views_[view] = native_view; | 992 associated_views_[view] = native_view; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 [compositor_superview_ setWantsBestResolutionOpenGLSurface:YES]; | 1263 [compositor_superview_ setWantsBestResolutionOpenGLSurface:YES]; |
1264 } | 1264 } |
1265 | 1265 |
1266 base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]); | 1266 base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]); |
1267 [background_layer | 1267 [background_layer |
1268 setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; | 1268 setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; |
1269 | 1269 |
1270 if (widget_type_ == Widget::InitParams::TYPE_MENU) { | 1270 if (widget_type_ == Widget::InitParams::TYPE_MENU) { |
1271 // Giving the canvas opacity messes up subpixel font rendering, so use a | 1271 // Giving the canvas opacity messes up subpixel font rendering, so use a |
1272 // solid background, but make the CALayer transparent. | 1272 // solid background, but make the CALayer transparent. |
1273 if (base::mac::IsOSYosemiteOrLater()) { | 1273 if (base::mac::IsAtLeastOS10_10()) { |
1274 [background_layer setOpacity:kYosemiteMenuOpacity]; | 1274 [background_layer setOpacity:kYosemiteMenuOpacity]; |
1275 CGSSetWindowBackgroundBlurRadius( | 1275 CGSSetWindowBackgroundBlurRadius( |
1276 _CGSDefaultConnection(), [window_ windowNumber], kYosemiteMenuBlur); | 1276 _CGSDefaultConnection(), [window_ windowNumber], kYosemiteMenuBlur); |
1277 // The blur effect does not occur with a fully transparent (or fully | 1277 // The blur effect does not occur with a fully transparent (or fully |
1278 // layer-backed) window. Setting a window background will use square | 1278 // layer-backed) window. Setting a window background will use square |
1279 // corners, so ask the contentView to draw one instead. | 1279 // corners, so ask the contentView to draw one instead. |
1280 [bridged_view_ setDrawMenuBackgroundForBlur:YES]; | 1280 [bridged_view_ setDrawMenuBackgroundForBlur:YES]; |
1281 } else { | 1281 } else { |
1282 [background_layer setOpacity:kMavericksMenuOpacity]; | 1282 [background_layer setOpacity:kMavericksMenuOpacity]; |
1283 } | 1283 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1365 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
1366 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1366 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
1367 // 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 |
1368 // 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. |
1369 // Calling the below seems to be an effective solution. | 1369 // Calling the below seems to be an effective solution. |
1370 [window_ setMovableByWindowBackground:NO]; | 1370 [window_ setMovableByWindowBackground:NO]; |
1371 [window_ setMovableByWindowBackground:YES]; | 1371 [window_ setMovableByWindowBackground:YES]; |
1372 } | 1372 } |
1373 | 1373 |
1374 } // namespace views | 1374 } // namespace views |
OLD | NEW |