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

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

Issue 1633403002: MacViews: Add native drop shadow to dialogs on OSX < 10.10. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 4 years, 10 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_content_view.mm ('k') | ui/views/window/dialog_delegate.cc » ('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
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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, let the window background remain opaque and clip the window
879 // boundary in drawRect method of BridgedContentView. See crbug.com/543671.
880 if (base::mac::IsOSYosemiteOrLater())
881 [window_ setBackgroundColor:[NSColor clearColor]];
869 } 882 }
870 883
871 UpdateLayerProperties(); 884 UpdateLayerProperties();
872 } 885 }
873 886
874 //////////////////////////////////////////////////////////////////////////////// 887 ////////////////////////////////////////////////////////////////////////////////
875 // BridgedNativeWidget, internal::InputMethodDelegate: 888 // BridgedNativeWidget, internal::InputMethodDelegate:
876 889
877 ui::EventDispatchDetails BridgedNativeWidget::DispatchKeyEventPostIME( 890 ui::EventDispatchDetails BridgedNativeWidget::DispatchKeyEventPostIME(
878 ui::KeyEvent* key) { 891 ui::KeyEvent* key) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 [bridged_view_ setMouseDownCanMoveWindow:draggable]; 1238 [bridged_view_ setMouseDownCanMoveWindow:draggable];
1226 // AppKit will not update its cache of mouseDownCanMoveWindow unless something 1239 // AppKit will not update its cache of mouseDownCanMoveWindow unless something
1227 // changes. Previously we tried adding an NSView and removing it, but for some 1240 // 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. 1241 // reason it required reposting the mouse-down event, and didn't always work.
1229 // Calling the below seems to be an effective solution. 1242 // Calling the below seems to be an effective solution.
1230 [window_ setMovableByWindowBackground:NO]; 1243 [window_ setMovableByWindowBackground:NO];
1231 [window_ setMovableByWindowBackground:YES]; 1244 [window_ setMovableByWindowBackground:YES];
1232 } 1245 }
1233 1246
1234 } // namespace views 1247 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | ui/views/window/dialog_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698