OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "ui/views/mus/window_tree_host_mus.h" | 5 #include "ui/views/mus/window_tree_host_mus.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "components/bitmap_uploader/bitmap_uploader.h" | |
9 #include "components/mus/public/cpp/window.h" | 8 #include "components/mus/public/cpp/window.h" |
10 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
11 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
12 #include "ui/base/view_prop.h" | |
13 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
14 #include "ui/platform_window/stub/stub_window.h" | 12 #include "ui/platform_window/stub/stub_window.h" |
15 #include "ui/views/mus/input_method_mus.h" | 13 #include "ui/views/mus/input_method_mus.h" |
16 #include "ui/views/mus/native_widget_mus.h" | 14 #include "ui/views/mus/native_widget_mus.h" |
17 | 15 |
18 namespace views { | 16 namespace views { |
19 | 17 |
20 namespace { | 18 namespace { |
21 static uint32_t accelerated_widget_count = 1; | 19 static uint32_t accelerated_widget_count = 1; |
22 } | 20 } |
23 | 21 |
24 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
25 // WindowTreeHostMus, public: | 23 // WindowTreeHostMus, public: |
26 | 24 |
27 WindowTreeHostMus::WindowTreeHostMus(shell::Connector* connector, | 25 WindowTreeHostMus::WindowTreeHostMus(NativeWidgetMus* native_widget, |
28 NativeWidgetMus* native_widget, | |
29 mus::Window* window) | 26 mus::Window* window) |
30 : native_widget_(native_widget) { | 27 : native_widget_(native_widget) { |
31 // We need accelerated widget numbers to be different for each | 28 // We need accelerated widget numbers to be different for each |
32 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t | 29 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t |
33 // has this property. | 30 // has this property. |
34 #if defined(OS_WIN) || defined(OS_ANDROID) | 31 #if defined(OS_WIN) || defined(OS_ANDROID) |
35 gfx::AcceleratedWidget accelerated_widget = | 32 gfx::AcceleratedWidget accelerated_widget = |
36 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); | 33 reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); |
37 #else | 34 #else |
38 gfx::AcceleratedWidget accelerated_widget = | 35 gfx::AcceleratedWidget accelerated_widget = |
39 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); | 36 static_cast<gfx::AcceleratedWidget>(accelerated_widget_count++); |
40 #endif | 37 #endif |
41 // TODO(markdittmer): Use correct device-scale-factor from |window|. | 38 // TODO(markdittmer): Use correct device-scale-factor from |window|. |
42 OnAcceleratedWidgetAvailable(accelerated_widget, 1.f); | 39 OnAcceleratedWidgetAvailable(accelerated_widget, 1.f); |
43 | 40 |
44 // If no connector was passed, then it's entirely possible that mojo has not | |
45 // been initialized and BitmapUploader will not work. This occurs, for | |
46 // example, in some unit test contexts. | |
47 if (connector) { | |
48 bitmap_uploader_.reset(new bitmap_uploader::BitmapUploader(window)); | |
49 bitmap_uploader_->Init(connector); | |
50 prop_.reset( | |
51 new ui::ViewProp(accelerated_widget, | |
52 bitmap_uploader::kBitmapUploaderForAcceleratedWidget, | |
53 bitmap_uploader_.get())); | |
54 } | |
55 | |
56 SetPlatformWindow(base::WrapUnique(new ui::StubWindow(nullptr))); | 41 SetPlatformWindow(base::WrapUnique(new ui::StubWindow(nullptr))); |
57 | 42 |
58 // The location of events is already transformed, and there is no way to | 43 // The location of events is already transformed, and there is no way to |
59 // correctly determine the reverse transform. So, don't attempt to transform | 44 // correctly determine the reverse transform. So, don't attempt to transform |
60 // event locations, else the root location is wrong. | 45 // event locations, else the root location is wrong. |
61 // TODO(sky): we need to transform for device scale though. | 46 // TODO(sky): we need to transform for device scale though. |
62 dispatcher()->set_transform_events(false); | 47 dispatcher()->set_transform_events(false); |
63 compositor()->SetHostHasTransparentBackground(true); | 48 compositor()->SetHostHasTransparentBackground(true); |
64 | 49 |
65 input_method_.reset(new InputMethodMUS(this, window)); | 50 input_method_.reset(new InputMethodMUS(this, window)); |
(...skipping 27 matching lines...) Expand all Loading... |
93 if (native_widget_) | 78 if (native_widget_) |
94 native_widget_->OnActivationChanged(active); | 79 native_widget_->OnActivationChanged(active); |
95 WindowTreeHostPlatform::OnActivationChanged(active); | 80 WindowTreeHostPlatform::OnActivationChanged(active); |
96 } | 81 } |
97 | 82 |
98 void WindowTreeHostMus::OnCloseRequest() { | 83 void WindowTreeHostMus::OnCloseRequest() { |
99 OnHostCloseRequested(); | 84 OnHostCloseRequested(); |
100 } | 85 } |
101 | 86 |
102 } // namespace views | 87 } // namespace views |
OLD | NEW |