| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/display_controller.h" | 5 #include "ash/display/display_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/display/cursor_window_controller.h" | 12 #include "ash/display/cursor_window_controller.h" |
| 13 #include "ash/display/display_layout_store.h" | 13 #include "ash/display/display_layout_store.h" |
| 14 #include "ash/display/display_manager.h" | 14 #include "ash/display/display_manager.h" |
| 15 #include "ash/display/mirror_window_controller.h" | 15 #include "ash/display/mirror_window_controller.h" |
| 16 #include "ash/display/root_window_transformers.h" | 16 #include "ash/display/root_window_transformers.h" |
| 17 #include "ash/display/virtual_keyboard_window_controller.h" | 17 #include "ash/display/virtual_keyboard_window_controller.h" |
| 18 #include "ash/host/ash_window_tree_host.h" | 18 #include "ash/host/ash_window_tree_host.h" |
| 19 #include "ash/host/ash_window_tree_host_init_params.h" |
| 19 #include "ash/host/root_window_transformer.h" | 20 #include "ash/host/root_window_transformer.h" |
| 20 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
| 21 #include "ash/root_window_settings.h" | 22 #include "ash/root_window_settings.h" |
| 22 #include "ash/screen_util.h" | 23 #include "ash/screen_util.h" |
| 23 #include "ash/shell.h" | 24 #include "ash/shell.h" |
| 24 #include "ash/shell_delegate.h" | 25 #include "ash/shell_delegate.h" |
| 25 #include "ash/wm/coordinate_conversion.h" | 26 #include "ash/wm/coordinate_conversion.h" |
| 26 #include "base/command_line.h" | 27 #include "base/command_line.h" |
| 27 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
| 28 #include "ui/aura/client/capture_client.h" | 29 #include "ui/aura/client/capture_client.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 window_tree_hosts_.rbegin(); | 267 window_tree_hosts_.rbegin(); |
| 267 it != window_tree_hosts_.rend(); | 268 it != window_tree_hosts_.rend(); |
| 268 ++it) { | 269 ++it) { |
| 269 RootWindowController* controller = | 270 RootWindowController* controller = |
| 270 GetRootWindowController(GetWindow(it->second)); | 271 GetRootWindowController(GetWindow(it->second)); |
| 271 DCHECK(controller); | 272 DCHECK(controller); |
| 272 delete controller; | 273 delete controller; |
| 273 } | 274 } |
| 274 } | 275 } |
| 275 | 276 |
| 276 void DisplayController::CreatePrimaryHost() { | 277 void DisplayController::CreatePrimaryHost( |
| 278 const AshWindowTreeHostInitParams& init_params) { |
| 277 const gfx::Display& primary_candidate = | 279 const gfx::Display& primary_candidate = |
| 278 GetDisplayManager()->GetPrimaryDisplayCandidate(); | 280 GetDisplayManager()->GetPrimaryDisplayCandidate(); |
| 279 primary_display_id = primary_candidate.id(); | 281 primary_display_id = primary_candidate.id(); |
| 280 AddWindowTreeHostForDisplay(primary_candidate); | 282 AddWindowTreeHostForDisplay(primary_candidate, init_params); |
| 281 } | 283 } |
| 282 | 284 |
| 283 void DisplayController::InitDisplays() { | 285 void DisplayController::InitDisplays() { |
| 284 RootWindowController::CreateForPrimaryDisplay( | 286 RootWindowController::CreateForPrimaryDisplay( |
| 285 window_tree_hosts_[primary_display_id]); | 287 window_tree_hosts_[primary_display_id]); |
| 286 | 288 |
| 287 DisplayManager* display_manager = GetDisplayManager(); | 289 DisplayManager* display_manager = GetDisplayManager(); |
| 288 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { | 290 for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { |
| 289 const gfx::Display& display = display_manager->GetDisplayAt(i); | 291 const gfx::Display& display = display_manager->GetDisplayAt(i); |
| 290 if (primary_display_id != display.id()) { | 292 if (primary_display_id != display.id()) { |
| 291 AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay(display); | 293 AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay( |
| 294 display, AshWindowTreeHostInitParams()); |
| 292 RootWindowController::CreateForSecondaryDisplay(ash_host); | 295 RootWindowController::CreateForSecondaryDisplay(ash_host); |
| 293 } | 296 } |
| 294 } | 297 } |
| 295 UpdateHostWindowNames(); | 298 UpdateHostWindowNames(); |
| 296 | 299 |
| 297 FOR_EACH_OBSERVER(Observer, observers_, OnDisplaysInitialized()); | 300 FOR_EACH_OBSERVER(Observer, observers_, OnDisplaysInitialized()); |
| 298 } | 301 } |
| 299 | 302 |
| 300 void DisplayController::AddObserver(Observer* observer) { | 303 void DisplayController::AddObserver(Observer* observer) { |
| 301 observers_.AddObserver(observer); | 304 observers_.AddObserver(observer); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 primary_tree_host_for_replace_ = NULL; | 566 primary_tree_host_for_replace_ = NULL; |
| 564 const DisplayInfo& display_info = | 567 const DisplayInfo& display_info = |
| 565 GetDisplayManager()->GetDisplayInfo(display.id()); | 568 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 566 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()]; | 569 AshWindowTreeHost* ash_host = window_tree_hosts_[display.id()]; |
| 567 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native()); | 570 ash_host->AsWindowTreeHost()->SetBounds(display_info.bounds_in_native()); |
| 568 SetDisplayPropertiesOnHost(ash_host, display); | 571 SetDisplayPropertiesOnHost(ash_host, display); |
| 569 } else { | 572 } else { |
| 570 if (primary_display_id == gfx::Display::kInvalidDisplayID) | 573 if (primary_display_id == gfx::Display::kInvalidDisplayID) |
| 571 primary_display_id = display.id(); | 574 primary_display_id = display.id(); |
| 572 DCHECK(!window_tree_hosts_.empty()); | 575 DCHECK(!window_tree_hosts_.empty()); |
| 573 AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay(display); | 576 AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay( |
| 577 display, AshWindowTreeHostInitParams()); |
| 574 RootWindowController::CreateForSecondaryDisplay(ash_host); | 578 RootWindowController::CreateForSecondaryDisplay(ash_host); |
| 575 } | 579 } |
| 576 } | 580 } |
| 577 | 581 |
| 578 void DisplayController::OnDisplayRemoved(const gfx::Display& display) { | 582 void DisplayController::OnDisplayRemoved(const gfx::Display& display) { |
| 579 AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()]; | 583 AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()]; |
| 580 DCHECK(host_to_delete) << display.ToString(); | 584 DCHECK(host_to_delete) << display.ToString(); |
| 581 | 585 |
| 582 // Display for root window will be deleted when the Primary RootWindow | 586 // Display for root window will be deleted when the Primary RootWindow |
| 583 // is deleted by the Shell. | 587 // is deleted by the Shell. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 layout_store->UpdatePrimaryDisplayId( | 698 layout_store->UpdatePrimaryDisplayId( |
| 695 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); | 699 pair, Shell::GetScreen()->GetPrimaryDisplay().id()); |
| 696 } | 700 } |
| 697 } | 701 } |
| 698 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); | 702 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); |
| 699 UpdateHostWindowNames(); | 703 UpdateHostWindowNames(); |
| 700 EnsurePointerInDisplays(); | 704 EnsurePointerInDisplays(); |
| 701 } | 705 } |
| 702 | 706 |
| 703 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( | 707 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( |
| 704 const gfx::Display& display) { | 708 const gfx::Display& display, |
| 709 const AshWindowTreeHostInitParams& init_params) { |
| 705 static int host_count = 0; | 710 static int host_count = 0; |
| 706 const DisplayInfo& display_info = | 711 const DisplayInfo& display_info = |
| 707 GetDisplayManager()->GetDisplayInfo(display.id()); | 712 GetDisplayManager()->GetDisplayInfo(display.id()); |
| 708 const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); | 713 AshWindowTreeHostInitParams params_with_bounds(init_params); |
| 709 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(bounds_in_native); | 714 params_with_bounds.initial_bounds = display_info.bounds_in_native(); |
| 715 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); |
| 710 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 716 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
| 711 | 717 |
| 712 host->window()->SetName(base::StringPrintf("RootWindow-%d", host_count++)); | 718 host->window()->SetName(base::StringPrintf("RootWindow-%d", host_count++)); |
| 713 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 719 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
| 714 // No need to remove our observer observer because the DisplayController | 720 // No need to remove our observer observer because the DisplayController |
| 715 // outlives the host. | 721 // outlives the host. |
| 716 host->AddObserver(this); | 722 host->AddObserver(this); |
| 717 InitRootWindowSettings(host->window())->display_id = display.id(); | 723 InitRootWindowSettings(host->window())->display_id = display.id(); |
| 718 host->InitHost(); | 724 host->InitHost(); |
| 719 | 725 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 749 std::string name = | 755 std::string name = |
| 750 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 756 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
| 751 gfx::AcceleratedWidget xwindow = | 757 gfx::AcceleratedWidget xwindow = |
| 752 root_windows[i]->GetHost()->GetAcceleratedWidget(); | 758 root_windows[i]->GetHost()->GetAcceleratedWidget(); |
| 753 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 759 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
| 754 } | 760 } |
| 755 #endif | 761 #endif |
| 756 } | 762 } |
| 757 | 763 |
| 758 } // namespace ash | 764 } // namespace ash |
| OLD | NEW |