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/common/display/display_info.h" | |
18 #include "ash/display/cursor_window_controller.h" | 17 #include "ash/display/cursor_window_controller.h" |
19 #include "ash/display/display_manager.h" | 18 #include "ash/display/display_manager.h" |
20 #include "ash/display/root_window_transformers.h" | 19 #include "ash/display/root_window_transformers.h" |
21 #include "ash/display/screen_position_controller.h" | 20 #include "ash/display/screen_position_controller.h" |
22 #include "ash/display/window_tree_host_manager.h" | 21 #include "ash/display/window_tree_host_manager.h" |
23 #include "ash/host/ash_window_tree_host.h" | 22 #include "ash/host/ash_window_tree_host.h" |
24 #include "ash/host/ash_window_tree_host_init_params.h" | 23 #include "ash/host/ash_window_tree_host_init_params.h" |
25 #include "ash/host/root_window_transformer.h" | 24 #include "ash/host/root_window_transformer.h" |
26 #include "ash/root_window_settings.h" | 25 #include "ash/root_window_settings.h" |
27 #include "ash/shell.h" | 26 #include "ash/shell.h" |
28 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
29 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
30 #include "ui/aura/client/capture_client.h" | 29 #include "ui/aura/client/capture_client.h" |
31 #include "ui/aura/env.h" | 30 #include "ui/aura/env.h" |
32 #include "ui/aura/window_delegate.h" | 31 #include "ui/aura/window_delegate.h" |
33 #include "ui/aura/window_event_dispatcher.h" | 32 #include "ui/aura/window_event_dispatcher.h" |
34 #include "ui/aura/window_tree_host.h" | 33 #include "ui/aura/window_tree_host.h" |
35 #include "ui/base/layout.h" | 34 #include "ui/base/layout.h" |
36 #include "ui/compositor/reflector.h" | 35 #include "ui/compositor/reflector.h" |
37 #include "ui/display/manager/display_layout.h" | 36 #include "ui/display/manager/display_layout.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/gfx/x/x11_types.h" // nogncheck | 43 #include "ui/gfx/x/x11_types.h" // nogncheck |
44 #endif | 44 #endif |
45 | 45 |
46 namespace ash { | 46 namespace ash { |
47 namespace { | 47 namespace { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 MirrorWindowController::MirrorWindowController() | 151 MirrorWindowController::MirrorWindowController() |
152 : multi_display_mode_(DisplayManager::EXTENDED), | 152 : multi_display_mode_(DisplayManager::EXTENDED), |
153 screen_position_client_(new MirroringScreenPositionClient(this)) {} | 153 screen_position_client_(new MirroringScreenPositionClient(this)) {} |
154 | 154 |
155 MirrorWindowController::~MirrorWindowController() { | 155 MirrorWindowController::~MirrorWindowController() { |
156 // Make sure the root window gets deleted before cursor_window_delegate. | 156 // Make sure the root window gets deleted before cursor_window_delegate. |
157 Close(false); | 157 Close(false); |
158 } | 158 } |
159 | 159 |
160 void MirrorWindowController::UpdateWindow( | 160 void MirrorWindowController::UpdateWindow( |
161 const std::vector<DisplayInfo>& display_info_list) { | 161 const std::vector<display::ManagedDisplayInfo>& display_info_list) { |
162 static int mirror_host_count = 0; | 162 static int mirror_host_count = 0; |
163 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 163 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
164 const display::Display& primary = | 164 const display::Display& primary = |
165 display::Screen::GetScreen()->GetPrimaryDisplay(); | 165 display::Screen::GetScreen()->GetPrimaryDisplay(); |
166 const DisplayInfo& source_display_info = | 166 const display::ManagedDisplayInfo& source_display_info = |
167 display_manager->GetDisplayInfo(primary.id()); | 167 display_manager->GetDisplayInfo(primary.id()); |
168 | 168 |
169 multi_display_mode_ = GetCurrentMultiDisplayMode(); | 169 multi_display_mode_ = GetCurrentMultiDisplayMode(); |
170 | 170 |
171 for (const DisplayInfo& display_info : display_info_list) { | 171 for (const display::ManagedDisplayInfo& display_info : display_info_list) { |
172 std::unique_ptr<RootWindowTransformer> transformer; | 172 std::unique_ptr<RootWindowTransformer> transformer; |
173 if (display_manager->IsInMirrorMode()) { | 173 if (display_manager->IsInMirrorMode()) { |
174 transformer.reset(CreateRootWindowTransformerForMirroredDisplay( | 174 transformer.reset(CreateRootWindowTransformerForMirroredDisplay( |
175 source_display_info, display_info)); | 175 source_display_info, display_info)); |
176 } else if (display_manager->IsInUnifiedMode()) { | 176 } else if (display_manager->IsInUnifiedMode()) { |
177 display::Display display = | 177 display::Display display = |
178 display_manager->GetMirroringDisplayById(display_info.id()); | 178 display_manager->GetMirroringDisplayById(display_info.id()); |
179 transformer.reset(CreateRootWindowTransformerForUnifiedDesktop( | 179 transformer.reset(CreateRootWindowTransformerForUnifiedDesktop( |
180 primary.bounds(), display)); | 180 primary.bounds(), display)); |
181 } else { | 181 } else { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 ash_host->SetRootWindowTransformer(std::move(transformer)); | 250 ash_host->SetRootWindowTransformer(std::move(transformer)); |
251 host->SetBounds(display_info.bounds_in_native()); | 251 host->SetBounds(display_info.bounds_in_native()); |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 // Deleting WTHs for disconnected displays. | 255 // Deleting WTHs for disconnected displays. |
256 if (mirroring_host_info_map_.size() > display_info_list.size()) { | 256 if (mirroring_host_info_map_.size() > display_info_list.size()) { |
257 for (MirroringHostInfoMap::iterator iter = mirroring_host_info_map_.begin(); | 257 for (MirroringHostInfoMap::iterator iter = mirroring_host_info_map_.begin(); |
258 iter != mirroring_host_info_map_.end();) { | 258 iter != mirroring_host_info_map_.end();) { |
259 if (std::find_if(display_info_list.begin(), display_info_list.end(), | 259 if (std::find_if(display_info_list.begin(), display_info_list.end(), |
260 [iter](const DisplayInfo& info) { | 260 [iter](const display::ManagedDisplayInfo& info) { |
261 return info.id() == iter->first; | 261 return info.id() == iter->first; |
262 }) == display_info_list.end()) { | 262 }) == display_info_list.end()) { |
263 CloseAndDeleteHost(iter->second, true); | 263 CloseAndDeleteHost(iter->second, true); |
264 iter = mirroring_host_info_map_.erase(iter); | 264 iter = mirroring_host_info_map_.erase(iter); |
265 } else { | 265 } else { |
266 ++iter; | 266 ++iter; |
267 } | 267 } |
268 } | 268 } |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 void MirrorWindowController::UpdateWindow() { | 272 void MirrorWindowController::UpdateWindow() { |
273 if (mirroring_host_info_map_.empty()) | 273 if (mirroring_host_info_map_.empty()) |
274 return; | 274 return; |
275 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 275 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
276 std::vector<DisplayInfo> display_info_list; | 276 std::vector<display::ManagedDisplayInfo> display_info_list; |
277 for (auto& pair : mirroring_host_info_map_) | 277 for (auto& pair : mirroring_host_info_map_) |
278 display_info_list.push_back(display_manager->GetDisplayInfo(pair.first)); | 278 display_info_list.push_back(display_manager->GetDisplayInfo(pair.first)); |
279 UpdateWindow(display_info_list); | 279 UpdateWindow(display_info_list); |
280 } | 280 } |
281 | 281 |
282 void MirrorWindowController::CloseIfNotNecessary() { | 282 void MirrorWindowController::CloseIfNotNecessary() { |
283 DisplayManager::MultiDisplayMode new_mode = GetCurrentMultiDisplayMode(); | 283 DisplayManager::MultiDisplayMode new_mode = GetCurrentMultiDisplayMode(); |
284 if (multi_display_mode_ != new_mode) | 284 if (multi_display_mode_ != new_mode) |
285 Close(true); | 285 Close(true); |
286 multi_display_mode_ = new_mode; | 286 multi_display_mode_ = new_mode; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 // EventProcessor may be accessed after this call if the mirroring window | 380 // EventProcessor may be accessed after this call if the mirroring window |
381 // was deleted as a result of input event (e.g. shortcut), so don't delete | 381 // was deleted as a result of input event (e.g. shortcut), so don't delete |
382 // now. | 382 // now. |
383 if (delay_host_deletion) | 383 if (delay_host_deletion) |
384 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info); | 384 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info); |
385 else | 385 else |
386 delete host_info; | 386 delete host_info; |
387 } | 387 } |
388 | 388 |
389 } // namespace ash | 389 } // namespace ash |
OLD | NEW |