| 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 #if defined(USE_X11) | 7 #if defined(USE_X11) |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 | 10 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // Releases a capture from the |window|. | 113 // Releases a capture from the |window|. |
| 114 void ReleaseCapture(aura::Window* window) override {} | 114 void ReleaseCapture(aura::Window* window) override {} |
| 115 | 115 |
| 116 // Returns the current capture window. | 116 // Returns the current capture window. |
| 117 aura::Window* GetCaptureWindow() override { return NULL; } | 117 aura::Window* GetCaptureWindow() override { return NULL; } |
| 118 aura::Window* GetGlobalCaptureWindow() override { return NULL; } | 118 aura::Window* GetGlobalCaptureWindow() override { return NULL; } |
| 119 | 119 |
| 120 DISALLOW_COPY_AND_ASSIGN(NoneCaptureClient); | 120 DISALLOW_COPY_AND_ASSIGN(NoneCaptureClient); |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 DisplayManager::MultiDisplayMode GetCurrentMultiDisplayMode() { |
| 124 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 125 return display_manager->IsInUnifiedMode() |
| 126 ? DisplayManager::UNIFIED |
| 127 : (display_manager->IsInMirrorMode() ? DisplayManager::MIRRORING |
| 128 : DisplayManager::EXTENDED); |
| 129 } |
| 130 |
| 123 } // namespace | 131 } // namespace |
| 124 | 132 |
| 125 struct MirrorWindowController::MirroringHostInfo { | 133 struct MirrorWindowController::MirroringHostInfo { |
| 126 MirroringHostInfo(); | 134 MirroringHostInfo(); |
| 127 ~MirroringHostInfo(); | 135 ~MirroringHostInfo(); |
| 128 scoped_ptr<AshWindowTreeHost> ash_host; | 136 scoped_ptr<AshWindowTreeHost> ash_host; |
| 129 gfx::Size mirror_window_host_size; | 137 gfx::Size mirror_window_host_size; |
| 130 aura::Window* mirror_window = nullptr; | 138 aura::Window* mirror_window = nullptr; |
| 131 }; | 139 }; |
| 132 | 140 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 146 } | 154 } |
| 147 | 155 |
| 148 void MirrorWindowController::UpdateWindow( | 156 void MirrorWindowController::UpdateWindow( |
| 149 const std::vector<DisplayInfo>& display_info_list) { | 157 const std::vector<DisplayInfo>& display_info_list) { |
| 150 static int mirror_host_count = 0; | 158 static int mirror_host_count = 0; |
| 151 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 159 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 152 const gfx::Display& primary = Shell::GetScreen()->GetPrimaryDisplay(); | 160 const gfx::Display& primary = Shell::GetScreen()->GetPrimaryDisplay(); |
| 153 const DisplayInfo& source_display_info = | 161 const DisplayInfo& source_display_info = |
| 154 display_manager->GetDisplayInfo(primary.id()); | 162 display_manager->GetDisplayInfo(primary.id()); |
| 155 | 163 |
| 164 multi_display_mode_ = GetCurrentMultiDisplayMode(); |
| 165 |
| 156 gfx::Point mirroring_origin; | 166 gfx::Point mirroring_origin; |
| 157 for (const DisplayInfo& display_info : display_info_list) { | 167 for (const DisplayInfo& display_info : display_info_list) { |
| 158 if (mirroring_host_info_map_.find(display_info.id()) == | 168 if (mirroring_host_info_map_.find(display_info.id()) == |
| 159 mirroring_host_info_map_.end()) { | 169 mirroring_host_info_map_.end()) { |
| 160 AshWindowTreeHostInitParams init_params; | 170 AshWindowTreeHostInitParams init_params; |
| 161 init_params.initial_bounds = display_info.bounds_in_native(); | 171 init_params.initial_bounds = display_info.bounds_in_native(); |
| 162 MirroringHostInfo* host_info = new MirroringHostInfo; | 172 MirroringHostInfo* host_info = new MirroringHostInfo; |
| 163 host_info->ash_host.reset(AshWindowTreeHost::Create(init_params)); | 173 host_info->ash_host.reset(AshWindowTreeHost::Create(init_params)); |
| 164 mirroring_host_info_map_[display_info.id()] = host_info; | 174 mirroring_host_info_map_[display_info.id()] = host_info; |
| 165 | 175 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 if (!mirroring_host_info_map_.size()) | 271 if (!mirroring_host_info_map_.size()) |
| 262 return; | 272 return; |
| 263 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 273 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 264 std::vector<DisplayInfo> display_info_list; | 274 std::vector<DisplayInfo> display_info_list; |
| 265 for (auto& pair : mirroring_host_info_map_) | 275 for (auto& pair : mirroring_host_info_map_) |
| 266 display_info_list.push_back(display_manager->GetDisplayInfo(pair.first)); | 276 display_info_list.push_back(display_manager->GetDisplayInfo(pair.first)); |
| 267 UpdateWindow(display_info_list); | 277 UpdateWindow(display_info_list); |
| 268 } | 278 } |
| 269 | 279 |
| 270 void MirrorWindowController::CloseIfNotNecessary() { | 280 void MirrorWindowController::CloseIfNotNecessary() { |
| 271 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 281 DisplayManager::MultiDisplayMode new_mode = GetCurrentMultiDisplayMode(); |
| 272 | |
| 273 DisplayManager::MultiDisplayMode new_mode = | |
| 274 display_manager->IsInUnifiedMode() | |
| 275 ? DisplayManager::UNIFIED | |
| 276 : (display_manager->IsInMirrorMode() ? DisplayManager::MIRRORING | |
| 277 : DisplayManager::EXTENDED); | |
| 278 if (multi_display_mode_ != new_mode) | 282 if (multi_display_mode_ != new_mode) |
| 279 Close(true); | 283 Close(true); |
| 280 multi_display_mode_ = new_mode; | 284 multi_display_mode_ = new_mode; |
| 281 } | 285 } |
| 282 | 286 |
| 283 void MirrorWindowController::Close(bool delay_host_deletion) { | 287 void MirrorWindowController::Close(bool delay_host_deletion) { |
| 284 for (auto& info : mirroring_host_info_map_) | 288 for (auto& info : mirroring_host_info_map_) |
| 285 CloseAndDeleteHost(info.second, delay_host_deletion); | 289 CloseAndDeleteHost(info.second, delay_host_deletion); |
| 286 | 290 |
| 287 mirroring_host_info_map_.clear(); | 291 mirroring_host_info_map_.clear(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); | 392 display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); |
| 389 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( | 393 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( |
| 390 Shell::GetScreen()->GetPrimaryDisplay().id()); | 394 Shell::GetScreen()->GetPrimaryDisplay().id()); |
| 391 DCHECK(display_manager->IsInMirrorMode()); | 395 DCHECK(display_manager->IsInMirrorMode()); |
| 392 return scoped_ptr<RootWindowTransformer>( | 396 return scoped_ptr<RootWindowTransformer>( |
| 393 CreateRootWindowTransformerForMirroredDisplay(source_display_info, | 397 CreateRootWindowTransformerForMirroredDisplay(source_display_info, |
| 394 mirror_display_info)); | 398 mirror_display_info)); |
| 395 } | 399 } |
| 396 | 400 |
| 397 } // namespace ash | 401 } // namespace ash |
| OLD | NEW |