| 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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 } | 660 } |
| 661 | 661 |
| 662 void BridgedNativeWidget::OnSizeChanged() { | 662 void BridgedNativeWidget::OnSizeChanged() { |
| 663 gfx::Size new_size = GetClientAreaSize(); | 663 gfx::Size new_size = GetClientAreaSize(); |
| 664 native_widget_mac_->GetWidget()->OnNativeWidgetSizeChanged(new_size); | 664 native_widget_mac_->GetWidget()->OnNativeWidgetSizeChanged(new_size); |
| 665 if (layer()) { | 665 if (layer()) { |
| 666 UpdateLayerProperties(); | 666 UpdateLayerProperties(); |
| 667 if ([window_ inLiveResize]) | 667 if ([window_ inLiveResize]) |
| 668 MaybeWaitForFrame(new_size); | 668 MaybeWaitForFrame(new_size); |
| 669 } | 669 } |
| 670 |
| 671 // 10.9 is unable to generate a window shadow from the composited CALayer, so |
| 672 // use Quartz. |
| 673 // We don't update the window mask during a live resize, instead it is done |
| 674 // after the resize is completed in viewDidEndLiveResize: in |
| 675 // BridgedContentView. |
| 676 if (base::mac::IsOSMavericksOrEarlier() && ![window_ inLiveResize]) |
| 677 [bridged_view_ updateWindowMask]; |
| 670 } | 678 } |
| 671 | 679 |
| 672 void BridgedNativeWidget::OnVisibilityChanged() { | 680 void BridgedNativeWidget::OnVisibilityChanged() { |
| 673 OnVisibilityChangedTo([window_ isVisible]); | 681 OnVisibilityChangedTo([window_ isVisible]); |
| 674 } | 682 } |
| 675 | 683 |
| 676 void BridgedNativeWidget::OnVisibilityChangedTo(bool new_visibility) { | 684 void BridgedNativeWidget::OnVisibilityChangedTo(bool new_visibility) { |
| 677 if (window_visible_ == new_visibility) | 685 if (window_visible_ == new_visibility) |
| 678 return; | 686 return; |
| 679 | 687 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 layer()->SetFillsBoundsOpaquely(!translucent); | 851 layer()->SetFillsBoundsOpaquely(!translucent); |
| 844 | 852 |
| 845 // Use the regular window background for window modal sheets. The layer() will | 853 // Use the regular window background for window modal sheets. The layer() will |
| 846 // still paint over most of it, but the native -[NSApp beginSheet:] animation | 854 // still paint over most of it, but the native -[NSApp beginSheet:] animation |
| 847 // blocks the UI thread, so there's no way to invalidate the shadow to match | 855 // blocks the UI thread, so there's no way to invalidate the shadow to match |
| 848 // the composited layer. This assumes the native window shape is a good match | 856 // the composited layer. This assumes the native window shape is a good match |
| 849 // for the composited NonClientFrameView, which should be the case since the | 857 // for the composited NonClientFrameView, which should be the case since the |
| 850 // native shape is what's most appropriate for displaying sheets on Mac. | 858 // native shape is what's most appropriate for displaying sheets on Mac. |
| 851 if (translucent && !native_widget_mac_->IsWindowModalSheet()) { | 859 if (translucent && !native_widget_mac_->IsWindowModalSheet()) { |
| 852 [window_ setOpaque:NO]; | 860 [window_ setOpaque:NO]; |
| 853 [window_ setBackgroundColor:[NSColor clearColor]]; | 861 // For Mac OS versions earlier than Yosemite, the Window server isn't able |
| 862 // to generate a window shadow from the composited CALayer. To get around |
| 863 // this, set an opaque background on the window and clip the window boundary |
| 864 // in drawRect method of BridgedContentView. See crbug.com/543671. |
| 865 if (base::mac::IsOSYosemiteOrLater()) |
| 866 [window_ setBackgroundColor:[NSColor clearColor]]; |
| 867 else |
| 868 [window_ setBackgroundColor:[NSColor whiteColor]]; |
| 854 } | 869 } |
| 855 | 870 |
| 856 UpdateLayerProperties(); | 871 UpdateLayerProperties(); |
| 857 } | 872 } |
| 858 | 873 |
| 859 //////////////////////////////////////////////////////////////////////////////// | 874 //////////////////////////////////////////////////////////////////////////////// |
| 860 // BridgedNativeWidget, internal::InputMethodDelegate: | 875 // BridgedNativeWidget, internal::InputMethodDelegate: |
| 861 | 876 |
| 862 ui::EventDispatchDetails BridgedNativeWidget::DispatchKeyEventPostIME( | 877 ui::EventDispatchDetails BridgedNativeWidget::DispatchKeyEventPostIME( |
| 863 ui::KeyEvent* key) { | 878 ui::KeyEvent* key) { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1226 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
| 1212 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1227 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
| 1213 // changes. Previously we tried adding an NSView and removing it, but for some | 1228 // changes. Previously we tried adding an NSView and removing it, but for some |
| 1214 // reason it required reposting the mouse-down event, and didn't always work. | 1229 // reason it required reposting the mouse-down event, and didn't always work. |
| 1215 // Calling the below seems to be an effective solution. | 1230 // Calling the below seems to be an effective solution. |
| 1216 [window_ setMovableByWindowBackground:NO]; | 1231 [window_ setMovableByWindowBackground:NO]; |
| 1217 [window_ setMovableByWindowBackground:YES]; | 1232 [window_ setMovableByWindowBackground:YES]; |
| 1218 } | 1233 } |
| 1219 | 1234 |
| 1220 } // namespace views | 1235 } // namespace views |
| OLD | NEW |