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. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 Close(); | 157 Close(); |
158 } | 158 } |
159 | 159 |
160 void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) { | 160 void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) { |
161 static int mirror_root_window_count = 0; | 161 static int mirror_root_window_count = 0; |
162 | 162 |
163 if (!root_window_.get()) { | 163 if (!root_window_.get()) { |
164 const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); | 164 const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); |
165 aura::RootWindow::CreateParams params(bounds_in_native); | 165 aura::RootWindow::CreateParams params(bounds_in_native); |
166 params.host = Shell::GetInstance()->root_window_host_factory()-> | 166 params.host = Shell::GetInstance()->root_window_host_factory()-> |
167 CreateRootWindowHost(bounds_in_native); | 167 CreateWindowTreeHost(bounds_in_native); |
168 root_window_.reset(new aura::RootWindow(params)); | 168 root_window_.reset(new aura::RootWindow(params)); |
169 root_window_->window()->SetName( | 169 root_window_->window()->SetName( |
170 base::StringPrintf("MirrorRootWindow-%d", mirror_root_window_count++)); | 170 base::StringPrintf("MirrorRootWindow-%d", mirror_root_window_count++)); |
171 root_window_->host()->compositor()->SetBackgroundColor(SK_ColorBLACK); | 171 root_window_->host()->compositor()->SetBackgroundColor(SK_ColorBLACK); |
172 // No need to remove RootWindowObserver because | 172 // No need to remove RootWindowObserver because |
173 // the DisplayController object outlives RootWindow objects. | 173 // the DisplayController object outlives RootWindow objects. |
174 root_window_->AddRootWindowObserver( | 174 root_window_->AddRootWindowObserver( |
175 Shell::GetInstance()->display_controller()); | 175 Shell::GetInstance()->display_controller()); |
176 root_window_->AddRootWindowObserver(this); | 176 root_window_->AddRootWindowObserver(this); |
177 // TODO(oshima): TouchHUD is using idkey. | 177 // TODO(oshima): TouchHUD is using idkey. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 gfx::Rect(cursor_window_->bounds().size())); | 311 gfx::Rect(cursor_window_->bounds().size())); |
312 UpdateCursorLocation(); | 312 UpdateCursorLocation(); |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 void MirrorWindowController::SetMirroredCursorVisibility(bool visible) { | 316 void MirrorWindowController::SetMirroredCursorVisibility(bool visible) { |
317 if (cursor_window_) | 317 if (cursor_window_) |
318 visible ? cursor_window_->Show() : cursor_window_->Hide(); | 318 visible ? cursor_window_->Show() : cursor_window_->Hide(); |
319 } | 319 } |
320 | 320 |
321 void MirrorWindowController::OnRootWindowHostResized( | 321 void MirrorWindowController::OnWindowTreeHostResized( |
322 const aura::RootWindow* root) { | 322 const aura::RootWindow* root) { |
323 // Do not use |old_size| as it contains RootWindow's (but not host's) size, | 323 // Do not use |old_size| as it contains RootWindow's (but not host's) size, |
324 // and this parameter wil be removed soon. | 324 // and this parameter wil be removed soon. |
325 if (mirror_window_host_size_ == root->host()->GetBounds().size()) | 325 if (mirror_window_host_size_ == root->host()->GetBounds().size()) |
326 return; | 326 return; |
327 mirror_window_host_size_ = root->host()->GetBounds().size(); | 327 mirror_window_host_size_ = root->host()->GetBounds().size(); |
328 reflector_->OnMirroringCompositorResized(); | 328 reflector_->OnMirroringCompositorResized(); |
329 root_window_->host()->SetRootWindowTransformer( | 329 root_window_->host()->SetRootWindowTransformer( |
330 CreateRootWindowTransformer().Pass()); | 330 CreateRootWindowTransformer().Pass()); |
331 UpdateCursorLocation(); | 331 UpdateCursorLocation(); |
332 } | 332 } |
333 | 333 |
334 | 334 |
335 scoped_ptr<aura::RootWindowTransformer> | 335 scoped_ptr<aura::RootWindowTransformer> |
336 MirrorWindowController::CreateRootWindowTransformer() const { | 336 MirrorWindowController::CreateRootWindowTransformer() const { |
337 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 337 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
338 const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo( | 338 const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo( |
339 display_manager->mirrored_display_id()); | 339 display_manager->mirrored_display_id()); |
340 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( | 340 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( |
341 Shell::GetScreen()->GetPrimaryDisplay().id()); | 341 Shell::GetScreen()->GetPrimaryDisplay().id()); |
342 DCHECK(display_manager->IsMirrored()); | 342 DCHECK(display_manager->IsMirrored()); |
343 return scoped_ptr<aura::RootWindowTransformer>( | 343 return scoped_ptr<aura::RootWindowTransformer>( |
344 internal::CreateRootWindowTransformerForMirroredDisplay( | 344 internal::CreateRootWindowTransformerForMirroredDisplay( |
345 source_display_info, | 345 source_display_info, |
346 mirror_display_info)); | 346 mirror_display_info)); |
347 } | 347 } |
348 | 348 |
349 } // namespace internal | 349 } // namespace internal |
350 } // namespace ash | 350 } // namespace ash |
OLD | NEW |