OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/display/mirror_window_controller.h" | 5 #include "ash/display/mirror_window_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #if defined(USE_X11) | 9 #if defined(USE_X11) |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
11 #include <X11/Xlib.h> | 11 #include <X11/Xlib.h> |
12 | 12 |
13 // Xlib.h defines RootWindow. | 13 // Xlib.h defines RootWindow. |
14 #undef RootWindow | 14 #undef RootWindow |
15 #endif | 15 #endif |
16 | 16 |
17 #include "ash/display/cursor_window_controller.h" | 17 #include "ash/display/cursor_window_controller.h" |
18 #include "ash/display/display_manager.h" | |
19 #include "ash/display/root_window_transformers.h" | 18 #include "ash/display/root_window_transformers.h" |
20 #include "ash/display/screen_position_controller.h" | 19 #include "ash/display/screen_position_controller.h" |
21 #include "ash/display/window_tree_host_manager.h" | 20 #include "ash/display/window_tree_host_manager.h" |
22 #include "ash/host/ash_window_tree_host.h" | 21 #include "ash/host/ash_window_tree_host.h" |
23 #include "ash/host/ash_window_tree_host_init_params.h" | 22 #include "ash/host/ash_window_tree_host_init_params.h" |
24 #include "ash/host/root_window_transformer.h" | 23 #include "ash/host/root_window_transformer.h" |
25 #include "ash/root_window_settings.h" | 24 #include "ash/root_window_settings.h" |
26 #include "ash/shell.h" | 25 #include "ash/shell.h" |
27 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
28 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
29 #include "ui/aura/client/capture_client.h" | 28 #include "ui/aura/client/capture_client.h" |
30 #include "ui/aura/env.h" | 29 #include "ui/aura/env.h" |
31 #include "ui/aura/window_delegate.h" | 30 #include "ui/aura/window_delegate.h" |
32 #include "ui/aura/window_event_dispatcher.h" | 31 #include "ui/aura/window_event_dispatcher.h" |
33 #include "ui/aura/window_tree_host.h" | 32 #include "ui/aura/window_tree_host.h" |
34 #include "ui/base/layout.h" | 33 #include "ui/base/layout.h" |
35 #include "ui/compositor/reflector.h" | 34 #include "ui/compositor/reflector.h" |
36 #include "ui/display/manager/display_layout.h" | 35 #include "ui/display/manager/display_layout.h" |
| 36 #include "ui/display/manager/display_manager.h" |
37 #include "ui/display/manager/managed_display_info.h" | 37 #include "ui/display/manager/managed_display_info.h" |
38 #include "ui/display/screen.h" | 38 #include "ui/display/screen.h" |
39 #include "ui/gfx/canvas.h" | 39 #include "ui/gfx/canvas.h" |
40 #include "ui/gfx/native_widget_types.h" | 40 #include "ui/gfx/native_widget_types.h" |
41 | 41 |
42 #if defined(USE_X11) | 42 #if defined(USE_X11) |
43 #include "ui/aura/window_tree_host_x11.h" | 43 #include "ui/aura/window_tree_host_x11.h" |
44 #include "ui/gfx/x/x11_types.h" // nogncheck | 44 #include "ui/gfx/x/x11_types.h" // nogncheck |
45 #endif | 45 #endif |
46 | 46 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 void SetCapture(aura::Window* window) override {} | 106 void SetCapture(aura::Window* window) override {} |
107 void ReleaseCapture(aura::Window* window) override {} | 107 void ReleaseCapture(aura::Window* window) override {} |
108 aura::Window* GetCaptureWindow() override { return nullptr; } | 108 aura::Window* GetCaptureWindow() override { return nullptr; } |
109 aura::Window* GetGlobalCaptureWindow() override { return nullptr; } | 109 aura::Window* GetGlobalCaptureWindow() override { return nullptr; } |
110 void AddObserver(aura::client::CaptureClientObserver* observer) override {} | 110 void AddObserver(aura::client::CaptureClientObserver* observer) override {} |
111 void RemoveObserver(aura::client::CaptureClientObserver* observer) override {} | 111 void RemoveObserver(aura::client::CaptureClientObserver* observer) override {} |
112 | 112 |
113 DISALLOW_COPY_AND_ASSIGN(NoneCaptureClient); | 113 DISALLOW_COPY_AND_ASSIGN(NoneCaptureClient); |
114 }; | 114 }; |
115 | 115 |
116 DisplayManager::MultiDisplayMode GetCurrentMultiDisplayMode() { | 116 display::DisplayManager::MultiDisplayMode GetCurrentMultiDisplayMode() { |
117 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 117 display::DisplayManager* display_manager = |
| 118 Shell::GetInstance()->display_manager(); |
118 return display_manager->IsInUnifiedMode() | 119 return display_manager->IsInUnifiedMode() |
119 ? DisplayManager::UNIFIED | 120 ? display::DisplayManager::UNIFIED |
120 : (display_manager->IsInMirrorMode() ? DisplayManager::MIRRORING | 121 : (display_manager->IsInMirrorMode() |
121 : DisplayManager::EXTENDED); | 122 ? display::DisplayManager::MIRRORING |
| 123 : display::DisplayManager::EXTENDED); |
122 } | 124 } |
123 | 125 |
124 } // namespace | 126 } // namespace |
125 | 127 |
126 struct MirrorWindowController::MirroringHostInfo { | 128 struct MirrorWindowController::MirroringHostInfo { |
127 MirroringHostInfo(); | 129 MirroringHostInfo(); |
128 ~MirroringHostInfo(); | 130 ~MirroringHostInfo(); |
129 std::unique_ptr<AshWindowTreeHost> ash_host; | 131 std::unique_ptr<AshWindowTreeHost> ash_host; |
130 gfx::Size mirror_window_host_size; | 132 gfx::Size mirror_window_host_size; |
131 aura::Window* mirror_window = nullptr; | 133 aura::Window* mirror_window = nullptr; |
132 }; | 134 }; |
133 | 135 |
134 MirrorWindowController::MirroringHostInfo::MirroringHostInfo() {} | 136 MirrorWindowController::MirroringHostInfo::MirroringHostInfo() {} |
135 MirrorWindowController::MirroringHostInfo::~MirroringHostInfo() {} | 137 MirrorWindowController::MirroringHostInfo::~MirroringHostInfo() {} |
136 | 138 |
137 MirrorWindowController::MirrorWindowController() | 139 MirrorWindowController::MirrorWindowController() |
138 : multi_display_mode_(DisplayManager::EXTENDED), | 140 : multi_display_mode_(display::DisplayManager::EXTENDED), |
139 screen_position_client_(new MirroringScreenPositionClient(this)) {} | 141 screen_position_client_(new MirroringScreenPositionClient(this)) {} |
140 | 142 |
141 MirrorWindowController::~MirrorWindowController() { | 143 MirrorWindowController::~MirrorWindowController() { |
142 // Make sure the root window gets deleted before cursor_window_delegate. | 144 // Make sure the root window gets deleted before cursor_window_delegate. |
143 Close(false); | 145 Close(false); |
144 } | 146 } |
145 | 147 |
146 void MirrorWindowController::UpdateWindow( | 148 void MirrorWindowController::UpdateWindow( |
147 const std::vector<display::ManagedDisplayInfo>& display_info_list) { | 149 const std::vector<display::ManagedDisplayInfo>& display_info_list) { |
148 static int mirror_host_count = 0; | 150 static int mirror_host_count = 0; |
149 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 151 display::DisplayManager* display_manager = |
| 152 Shell::GetInstance()->display_manager(); |
150 const display::Display& primary = | 153 const display::Display& primary = |
151 display::Screen::GetScreen()->GetPrimaryDisplay(); | 154 display::Screen::GetScreen()->GetPrimaryDisplay(); |
152 const display::ManagedDisplayInfo& source_display_info = | 155 const display::ManagedDisplayInfo& source_display_info = |
153 display_manager->GetDisplayInfo(primary.id()); | 156 display_manager->GetDisplayInfo(primary.id()); |
154 | 157 |
155 multi_display_mode_ = GetCurrentMultiDisplayMode(); | 158 multi_display_mode_ = GetCurrentMultiDisplayMode(); |
156 | 159 |
157 for (const display::ManagedDisplayInfo& display_info : display_info_list) { | 160 for (const display::ManagedDisplayInfo& display_info : display_info_list) { |
158 std::unique_ptr<RootWindowTransformer> transformer; | 161 std::unique_ptr<RootWindowTransformer> transformer; |
159 if (display_manager->IsInMirrorMode()) { | 162 if (display_manager->IsInMirrorMode()) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } else { | 254 } else { |
252 ++iter; | 255 ++iter; |
253 } | 256 } |
254 } | 257 } |
255 } | 258 } |
256 } | 259 } |
257 | 260 |
258 void MirrorWindowController::UpdateWindow() { | 261 void MirrorWindowController::UpdateWindow() { |
259 if (mirroring_host_info_map_.empty()) | 262 if (mirroring_host_info_map_.empty()) |
260 return; | 263 return; |
261 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 264 display::DisplayManager* display_manager = |
| 265 Shell::GetInstance()->display_manager(); |
262 std::vector<display::ManagedDisplayInfo> display_info_list; | 266 std::vector<display::ManagedDisplayInfo> display_info_list; |
263 for (auto& pair : mirroring_host_info_map_) | 267 for (auto& pair : mirroring_host_info_map_) |
264 display_info_list.push_back(display_manager->GetDisplayInfo(pair.first)); | 268 display_info_list.push_back(display_manager->GetDisplayInfo(pair.first)); |
265 UpdateWindow(display_info_list); | 269 UpdateWindow(display_info_list); |
266 } | 270 } |
267 | 271 |
268 void MirrorWindowController::CloseIfNotNecessary() { | 272 void MirrorWindowController::CloseIfNotNecessary() { |
269 DisplayManager::MultiDisplayMode new_mode = GetCurrentMultiDisplayMode(); | 273 display::DisplayManager::MultiDisplayMode new_mode = |
| 274 GetCurrentMultiDisplayMode(); |
270 if (multi_display_mode_ != new_mode) | 275 if (multi_display_mode_ != new_mode) |
271 Close(true); | 276 Close(true); |
272 multi_display_mode_ = new_mode; | 277 multi_display_mode_ = new_mode; |
273 } | 278 } |
274 | 279 |
275 void MirrorWindowController::Close(bool delay_host_deletion) { | 280 void MirrorWindowController::Close(bool delay_host_deletion) { |
276 for (auto& info : mirroring_host_info_map_) | 281 for (auto& info : mirroring_host_info_map_) |
277 CloseAndDeleteHost(info.second, delay_host_deletion); | 282 CloseAndDeleteHost(info.second, delay_host_deletion); |
278 | 283 |
279 mirroring_host_info_map_.clear(); | 284 mirroring_host_info_map_.clear(); |
(...skipping 17 matching lines...) Expand all Loading... |
297 Shell::GetInstance() | 302 Shell::GetInstance() |
298 ->window_tree_host_manager() | 303 ->window_tree_host_manager() |
299 ->cursor_window_controller() | 304 ->cursor_window_controller() |
300 ->UpdateLocation(); | 305 ->UpdateLocation(); |
301 return; | 306 return; |
302 } | 307 } |
303 } | 308 } |
304 } | 309 } |
305 | 310 |
306 aura::Window* MirrorWindowController::GetWindow() { | 311 aura::Window* MirrorWindowController::GetWindow() { |
307 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 312 display::DisplayManager* display_manager = |
| 313 Shell::GetInstance()->display_manager(); |
308 if (!display_manager->IsInMirrorMode() || mirroring_host_info_map_.empty()) | 314 if (!display_manager->IsInMirrorMode() || mirroring_host_info_map_.empty()) |
309 return nullptr; | 315 return nullptr; |
310 DCHECK_EQ(1U, mirroring_host_info_map_.size()); | 316 DCHECK_EQ(1U, mirroring_host_info_map_.size()); |
311 return mirroring_host_info_map_.begin() | 317 return mirroring_host_info_map_.begin() |
312 ->second->ash_host->AsWindowTreeHost() | 318 ->second->ash_host->AsWindowTreeHost() |
313 ->window(); | 319 ->window(); |
314 } | 320 } |
315 | 321 |
316 display::Display MirrorWindowController::GetDisplayForRootWindow( | 322 display::Display MirrorWindowController::GetDisplayForRootWindow( |
317 const aura::Window* root) const { | 323 const aura::Window* root) const { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // EventProcessor may be accessed after this call if the mirroring window | 371 // EventProcessor may be accessed after this call if the mirroring window |
366 // was deleted as a result of input event (e.g. shortcut), so don't delete | 372 // was deleted as a result of input event (e.g. shortcut), so don't delete |
367 // now. | 373 // now. |
368 if (delay_host_deletion) | 374 if (delay_host_deletion) |
369 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info); | 375 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info); |
370 else | 376 else |
371 delete host_info; | 377 delete host_info; |
372 } | 378 } |
373 | 379 |
374 } // namespace ash | 380 } // namespace ash |
OLD | NEW |