OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/ws/platform_display_default.h" | 5 #include "services/ui/ws/platform_display_default.h" |
6 | 6 |
7 #include "gpu/ipc/client/gpu_channel_host.h" | 7 #include "gpu/ipc/client/gpu_channel_host.h" |
8 #include "services/ui/display/screen_manager.h" | 8 #include "services/ui/display/screen_manager.h" |
9 #include "services/ui/ws/platform_display_init_params.h" | 9 #include "services/ui/ws/platform_display_init_params.h" |
10 #include "services/ui/ws/server_window.h" | 10 #include "services/ui/ws/server_window.h" |
11 #include "ui/base/cursor/cursor_loader.h" | 11 #include "ui/base/cursor/image_cursors.h" |
12 #include "ui/display/display.h" | 12 #include "ui/display/display.h" |
13 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
14 #include "ui/events/event_utils.h" | 14 #include "ui/events/event_utils.h" |
15 #include "ui/platform_window/platform_ime_controller.h" | 15 #include "ui/platform_window/platform_ime_controller.h" |
16 #include "ui/platform_window/platform_window.h" | 16 #include "ui/platform_window/platform_window.h" |
17 | 17 |
18 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
19 #include "ui/platform_window/win/win_window.h" | 19 #include "ui/platform_window/win/win_window.h" |
20 #elif defined(USE_X11) && !defined(OS_CHROMEOS) | 20 #elif defined(USE_X11) && !defined(OS_CHROMEOS) |
21 #include "ui/platform_window/x11/x11_window.h" | 21 #include "ui/platform_window/x11/x11_window.h" |
22 #elif defined(OS_ANDROID) | 22 #elif defined(OS_ANDROID) |
23 #include "ui/platform_window/android/platform_window_android.h" | 23 #include "ui/platform_window/android/platform_window_android.h" |
24 #elif defined(USE_OZONE) | 24 #elif defined(USE_OZONE) |
25 #include "ui/ozone/public/ozone_platform.h" | 25 #include "ui/ozone/public/ozone_platform.h" |
26 #endif | 26 #endif |
27 | 27 |
28 namespace ui { | 28 namespace ui { |
29 namespace ws { | 29 namespace ws { |
30 | 30 |
31 PlatformDisplayDefault::PlatformDisplayDefault( | 31 PlatformDisplayDefault::PlatformDisplayDefault( |
32 const PlatformDisplayInitParams& init_params) | 32 const PlatformDisplayInitParams& init_params) |
33 : display_id_(init_params.display_id), | 33 : display_id_(init_params.display_id), |
34 #if !defined(OS_ANDROID) | 34 #if !defined(OS_ANDROID) |
35 cursor_loader_(ui::CursorLoader::Create()), | 35 image_cursors_(new ImageCursors), |
36 #endif | 36 #endif |
37 frame_generator_(new FrameGenerator(this, init_params.root_window)), | 37 frame_generator_(new FrameGenerator(this, init_params.root_window)), |
38 metrics_(init_params.metrics) { | 38 metrics_(init_params.metrics) { |
39 } | 39 } |
40 | 40 |
41 PlatformDisplayDefault::~PlatformDisplayDefault() { | 41 PlatformDisplayDefault::~PlatformDisplayDefault() { |
42 // Don't notify the delegate from the destructor. | 42 // Don't notify the delegate from the destructor. |
43 delegate_ = nullptr; | 43 delegate_ = nullptr; |
44 | 44 |
45 frame_generator_.reset(); | 45 frame_generator_.reset(); |
(...skipping 20 matching lines...) Expand all Loading... |
66 platform_window_ = base::MakeUnique<ui::PlatformWindowAndroid>(this); | 66 platform_window_ = base::MakeUnique<ui::PlatformWindowAndroid>(this); |
67 platform_window_->SetBounds(bounds); | 67 platform_window_->SetBounds(bounds); |
68 #elif defined(USE_OZONE) | 68 #elif defined(USE_OZONE) |
69 platform_window_ = | 69 platform_window_ = |
70 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); | 70 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); |
71 #else | 71 #else |
72 NOTREACHED() << "Unsupported platform"; | 72 NOTREACHED() << "Unsupported platform"; |
73 #endif | 73 #endif |
74 | 74 |
75 platform_window_->Show(); | 75 platform_window_->Show(); |
| 76 #if !defined(OS_ANDROID) |
| 77 image_cursors_->SetDisplay(delegate_->GetDisplay(), |
| 78 metrics_.device_scale_factor); |
| 79 #endif |
76 } | 80 } |
77 | 81 |
78 int64_t PlatformDisplayDefault::GetId() const { | 82 int64_t PlatformDisplayDefault::GetId() const { |
79 return display_id_; | 83 return display_id_; |
80 } | 84 } |
81 | 85 |
82 void PlatformDisplayDefault::SetViewportSize(const gfx::Size& size) { | 86 void PlatformDisplayDefault::SetViewportSize(const gfx::Size& size) { |
83 platform_window_->SetBounds(gfx::Rect(size)); | 87 platform_window_->SetBounds(gfx::Rect(size)); |
84 } | 88 } |
85 | 89 |
(...skipping 10 matching lines...) Expand all Loading... |
96 } | 100 } |
97 | 101 |
98 void PlatformDisplayDefault::SetCursorById(mojom::Cursor cursor_id) { | 102 void PlatformDisplayDefault::SetCursorById(mojom::Cursor cursor_id) { |
99 #if !defined(OS_ANDROID) | 103 #if !defined(OS_ANDROID) |
100 // TODO(erg): This still isn't sufficient, and will only use native cursors | 104 // TODO(erg): This still isn't sufficient, and will only use native cursors |
101 // that chrome would use, not custom image cursors. For that, we should | 105 // that chrome would use, not custom image cursors. For that, we should |
102 // delegate to the window manager to load images from resource packs. | 106 // delegate to the window manager to load images from resource packs. |
103 // | 107 // |
104 // We probably also need to deal with different DPIs. | 108 // We probably also need to deal with different DPIs. |
105 ui::Cursor cursor(static_cast<int32_t>(cursor_id)); | 109 ui::Cursor cursor(static_cast<int32_t>(cursor_id)); |
106 cursor_loader_->SetPlatformCursor(&cursor); | 110 image_cursors_->SetPlatformCursor(&cursor); |
107 platform_window_->SetCursor(cursor.platform()); | 111 platform_window_->SetCursor(cursor.platform()); |
108 #endif | 112 #endif |
109 } | 113 } |
110 | 114 |
111 void PlatformDisplayDefault::UpdateTextInputState( | 115 void PlatformDisplayDefault::UpdateTextInputState( |
112 const ui::TextInputState& state) { | 116 const ui::TextInputState& state) { |
113 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); | 117 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); |
114 if (ime) | 118 if (ime) |
115 ime->UpdateTextInputState(state); | 119 ime->UpdateTextInputState(state); |
116 } | 120 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 243 } |
240 | 244 |
241 void PlatformDisplayDefault::OnActivationChanged(bool active) {} | 245 void PlatformDisplayDefault::OnActivationChanged(bool active) {} |
242 | 246 |
243 bool PlatformDisplayDefault::IsInHighContrastMode() { | 247 bool PlatformDisplayDefault::IsInHighContrastMode() { |
244 return delegate_ ? delegate_->IsInHighContrastMode() : false; | 248 return delegate_ ? delegate_->IsInHighContrastMode() : false; |
245 } | 249 } |
246 | 250 |
247 } // namespace ws | 251 } // namespace ws |
248 } // namespace ui | 252 } // namespace ui |
OLD | NEW |