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 |
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/memory/ptr_util.h" |
15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
16 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" | 17 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" |
17 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" | 18 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" |
18 #include "ui/base/hit_test.h" | 19 #include "ui/base/hit_test.h" |
19 #include "ui/base/ime/input_method.h" | 20 #include "ui/base/ime/input_method.h" |
20 #include "ui/base/ime/input_method_factory.h" | 21 #include "ui/base/ime/input_method_factory.h" |
21 #include "ui/display/display.h" | 22 #include "ui/display/display.h" |
22 #include "ui/display/screen.h" | 23 #include "ui/display/screen.h" |
23 #include "ui/gfx/geometry/dip_util.h" | 24 #include "ui/gfx/geometry/dip_util.h" |
24 #import "ui/gfx/mac/coordinate_conversion.h" | 25 #import "ui/gfx/mac/coordinate_conversion.h" |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 } | 956 } |
956 | 957 |
957 void BridgedNativeWidget::CreateLayer(ui::LayerType layer_type, | 958 void BridgedNativeWidget::CreateLayer(ui::LayerType layer_type, |
958 bool translucent) { | 959 bool translucent) { |
959 DCHECK(bridged_view_); | 960 DCHECK(bridged_view_); |
960 DCHECK(!layer()); | 961 DCHECK(!layer()); |
961 | 962 |
962 CreateCompositor(); | 963 CreateCompositor(); |
963 DCHECK(compositor_); | 964 DCHECK(compositor_); |
964 | 965 |
965 SetLayer(new ui::Layer(layer_type)); | 966 SetLayer(base::MakeUnique<ui::Layer>(layer_type)); |
966 // Note, except for controls, this will set the layer to be hidden, since it | 967 // Note, except for controls, this will set the layer to be hidden, since it |
967 // is only called during Init(). | 968 // is only called during Init(). |
968 layer()->SetVisible(window_visible_); | 969 layer()->SetVisible(window_visible_); |
969 layer()->set_delegate(this); | 970 layer()->set_delegate(this); |
970 | 971 |
971 InitCompositor(); | 972 InitCompositor(); |
972 | 973 |
973 // Transparent window support. | 974 // Transparent window support. |
974 layer()->GetCompositor()->SetHostHasTransparentBackground(translucent); | 975 layer()->GetCompositor()->SetHostHasTransparentBackground(translucent); |
975 layer()->SetFillsBoundsOpaquely(!translucent); | 976 layer()->SetFillsBoundsOpaquely(!translucent); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1378 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
1378 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1379 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
1379 // changes. Previously we tried adding an NSView and removing it, but for some | 1380 // changes. Previously we tried adding an NSView and removing it, but for some |
1380 // reason it required reposting the mouse-down event, and didn't always work. | 1381 // reason it required reposting the mouse-down event, and didn't always work. |
1381 // Calling the below seems to be an effective solution. | 1382 // Calling the below seems to be an effective solution. |
1382 [window_ setMovableByWindowBackground:NO]; | 1383 [window_ setMovableByWindowBackground:NO]; |
1383 [window_ setMovableByWindowBackground:YES]; | 1384 [window_ setMovableByWindowBackground:YES]; |
1384 } | 1385 } |
1385 | 1386 |
1386 } // namespace views | 1387 } // namespace views |
OLD | NEW |