| 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 | 9 |
| 10 // Xlib.h defines RootWindow. | 10 // Xlib.h defines RootWindow. |
| 11 #undef RootWindow | 11 #undef RootWindow |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include "ash/display/cursor_window_controller.h" | 14 #include "ash/display/cursor_window_controller.h" |
| 15 #include "ash/display/display_controller.h" | 15 #include "ash/display/display_controller.h" |
| 16 #include "ash/display/display_info.h" | 16 #include "ash/display/display_info.h" |
| 17 #include "ash/display/display_manager.h" | 17 #include "ash/display/display_manager.h" |
| 18 #include "ash/display/root_window_transformers.h" | 18 #include "ash/display/root_window_transformers.h" |
| 19 #include "ash/host/ash_window_tree_host.h" | 19 #include "ash/host/ash_window_tree_host.h" |
| 20 #include "ash/host/ash_window_tree_host_init_params.h" |
| 20 #include "ash/host/root_window_transformer.h" | 21 #include "ash/host/root_window_transformer.h" |
| 21 #include "ash/root_window_settings.h" | 22 #include "ash/root_window_settings.h" |
| 22 #include "ash/shell.h" | 23 #include "ash/shell.h" |
| 23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 24 #include "ui/aura/client/capture_client.h" | 25 #include "ui/aura/client/capture_client.h" |
| 25 #include "ui/aura/window_delegate.h" | 26 #include "ui/aura/window_delegate.h" |
| 26 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
| 27 #include "ui/aura/window_tree_host.h" | 28 #include "ui/aura/window_tree_host.h" |
| 28 #include "ui/base/layout.h" | 29 #include "ui/base/layout.h" |
| 29 #include "ui/compositor/reflector.h" | 30 #include "ui/compositor/reflector.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 MirrorWindowController::MirrorWindowController() {} | 75 MirrorWindowController::MirrorWindowController() {} |
| 75 | 76 |
| 76 MirrorWindowController::~MirrorWindowController() { | 77 MirrorWindowController::~MirrorWindowController() { |
| 77 // Make sure the root window gets deleted before cursor_window_delegate. | 78 // Make sure the root window gets deleted before cursor_window_delegate. |
| 78 Close(); | 79 Close(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) { | 82 void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) { |
| 82 static int mirror_host_count = 0; | 83 static int mirror_host_count = 0; |
| 83 if (!ash_host_.get()) { | 84 if (!ash_host_.get()) { |
| 84 const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); | 85 AshWindowTreeHostInitParams init_params; |
| 85 ash_host_.reset(AshWindowTreeHost::Create(bounds_in_native)); | 86 init_params.initial_bounds = display_info.bounds_in_native(); |
| 87 ash_host_.reset(AshWindowTreeHost::Create(init_params)); |
| 86 aura::WindowTreeHost* host = ash_host_->AsWindowTreeHost(); | 88 aura::WindowTreeHost* host = ash_host_->AsWindowTreeHost(); |
| 87 host->window()->SetName( | 89 host->window()->SetName( |
| 88 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++)); | 90 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++)); |
| 89 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 91 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
| 90 // No need to remove the observer because the DisplayController outlives the | 92 // No need to remove the observer because the DisplayController outlives the |
| 91 // host. | 93 // host. |
| 92 host->AddObserver(Shell::GetInstance()->display_controller()); | 94 host->AddObserver(Shell::GetInstance()->display_controller()); |
| 93 host->AddObserver(this); | 95 host->AddObserver(this); |
| 94 // TODO(oshima): TouchHUD is using idkey. | 96 // TODO(oshima): TouchHUD is using idkey. |
| 95 InitRootWindowSettings(host->window())->display_id = display_info.id(); | 97 InitRootWindowSettings(host->window())->display_id = display_info.id(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 display_manager->mirrored_display_id()); | 174 display_manager->mirrored_display_id()); |
| 173 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( | 175 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( |
| 174 Shell::GetScreen()->GetPrimaryDisplay().id()); | 176 Shell::GetScreen()->GetPrimaryDisplay().id()); |
| 175 DCHECK(display_manager->IsMirrored()); | 177 DCHECK(display_manager->IsMirrored()); |
| 176 return scoped_ptr<RootWindowTransformer>( | 178 return scoped_ptr<RootWindowTransformer>( |
| 177 CreateRootWindowTransformerForMirroredDisplay(source_display_info, | 179 CreateRootWindowTransformerForMirroredDisplay(source_display_info, |
| 178 mirror_display_info)); | 180 mirror_display_info)); |
| 179 } | 181 } |
| 180 | 182 |
| 181 } // namespace ash | 183 } // namespace ash |
| OLD | NEW |