Chromium Code Reviews| 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 } | 675 } |
| 676 | 676 |
| 677 void BridgedNativeWidget::OnSizeChanged() { | 677 void BridgedNativeWidget::OnSizeChanged() { |
| 678 gfx::Size new_size = GetClientAreaSize(); | 678 gfx::Size new_size = GetClientAreaSize(); |
| 679 native_widget_mac_->GetWidget()->OnNativeWidgetSizeChanged(new_size); | 679 native_widget_mac_->GetWidget()->OnNativeWidgetSizeChanged(new_size); |
| 680 if (layer()) { | 680 if (layer()) { |
| 681 UpdateLayerProperties(); | 681 UpdateLayerProperties(); |
| 682 if ([window_ inLiveResize]) | 682 if ([window_ inLiveResize]) |
| 683 MaybeWaitForFrame(new_size); | 683 MaybeWaitForFrame(new_size); |
| 684 } | 684 } |
| 685 | |
| 686 // 10.9 is unable to generate a window shadow from the composited CALayer, so | |
| 687 // use Quartz. | |
| 688 // We don't update the window mask during a live resize, instead it is done | |
| 689 // after the resize is completed in viewDidEndLiveResize: in | |
| 690 // BridgedContentView. | |
| 691 if (base::mac::IsOSMavericksOrEarlier() && ![window_ inLiveResize]) | |
| 692 [bridged_view_ updateWindowMask]; | |
| 685 } | 693 } |
| 686 | 694 |
| 687 void BridgedNativeWidget::OnVisibilityChanged() { | 695 void BridgedNativeWidget::OnVisibilityChanged() { |
| 688 OnVisibilityChangedTo([window_ isVisible]); | 696 OnVisibilityChangedTo([window_ isVisible]); |
| 689 } | 697 } |
| 690 | 698 |
| 691 void BridgedNativeWidget::OnVisibilityChangedTo(bool new_visibility) { | 699 void BridgedNativeWidget::OnVisibilityChangedTo(bool new_visibility) { |
| 692 if (window_visible_ == new_visibility) | 700 if (window_visible_ == new_visibility) |
| 693 return; | 701 return; |
| 694 | 702 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 layer()->SetFillsBoundsOpaquely(!translucent); | 866 layer()->SetFillsBoundsOpaquely(!translucent); |
| 859 | 867 |
| 860 // Use the regular window background for window modal sheets. The layer() will | 868 // Use the regular window background for window modal sheets. The layer() will |
| 861 // still paint over most of it, but the native -[NSApp beginSheet:] animation | 869 // still paint over most of it, but the native -[NSApp beginSheet:] animation |
| 862 // blocks the UI thread, so there's no way to invalidate the shadow to match | 870 // blocks the UI thread, so there's no way to invalidate the shadow to match |
| 863 // the composited layer. This assumes the native window shape is a good match | 871 // the composited layer. This assumes the native window shape is a good match |
| 864 // for the composited NonClientFrameView, which should be the case since the | 872 // for the composited NonClientFrameView, which should be the case since the |
| 865 // native shape is what's most appropriate for displaying sheets on Mac. | 873 // native shape is what's most appropriate for displaying sheets on Mac. |
| 866 if (translucent && !native_widget_mac_->IsWindowModalSheet()) { | 874 if (translucent && !native_widget_mac_->IsWindowModalSheet()) { |
| 867 [window_ setOpaque:NO]; | 875 [window_ setOpaque:NO]; |
| 868 [window_ setBackgroundColor:[NSColor clearColor]]; | 876 // For Mac OS versions earlier than Yosemite, the Window server isn't able |
| 877 // to generate a window shadow from the composited CALayer. To get around | |
| 878 // this, set an opaque background on the window and clip the window boundary | |
| 879 // in drawRect method of BridgedContentView. See crbug.com/543671. | |
| 880 if (base::mac::IsOSYosemiteOrLater()) | |
| 881 [window_ setBackgroundColor:[NSColor clearColor]]; | |
| 882 else | |
| 883 [window_ setBackgroundColor:[NSColor whiteColor]]; | |
|
tapted
2016/02/11 01:47:23
I just realised.. this `else` might not be needed.
karandeepb
2016/02/11 04:16:04
Done.
| |
| 869 } | 884 } |
| 870 | 885 |
| 871 UpdateLayerProperties(); | 886 UpdateLayerProperties(); |
| 872 } | 887 } |
| 873 | 888 |
| 874 //////////////////////////////////////////////////////////////////////////////// | 889 //////////////////////////////////////////////////////////////////////////////// |
| 875 // BridgedNativeWidget, internal::InputMethodDelegate: | 890 // BridgedNativeWidget, internal::InputMethodDelegate: |
| 876 | 891 |
| 877 ui::EventDispatchDetails BridgedNativeWidget::DispatchKeyEventPostIME( | 892 ui::EventDispatchDetails BridgedNativeWidget::DispatchKeyEventPostIME( |
| 878 ui::KeyEvent* key) { | 893 ui::KeyEvent* key) { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1225 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1240 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
| 1226 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1241 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
| 1227 // changes. Previously we tried adding an NSView and removing it, but for some | 1242 // changes. Previously we tried adding an NSView and removing it, but for some |
| 1228 // reason it required reposting the mouse-down event, and didn't always work. | 1243 // reason it required reposting the mouse-down event, and didn't always work. |
| 1229 // Calling the below seems to be an effective solution. | 1244 // Calling the below seems to be an effective solution. |
| 1230 [window_ setMovableByWindowBackground:NO]; | 1245 [window_ setMovableByWindowBackground:NO]; |
| 1231 [window_ setMovableByWindowBackground:YES]; | 1246 [window_ setMovableByWindowBackground:YES]; |
| 1232 } | 1247 } |
| 1233 | 1248 |
| 1234 } // namespace views | 1249 } // namespace views |
| OLD | NEW |