| 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" | |
| 18 #include "ash/host/ash_window_tree_host.h" | 17 #include "ash/host/ash_window_tree_host.h" |
| 19 #include "ash/host/ash_window_tree_host_init_params.h" | 18 #include "ash/host/ash_window_tree_host_init_params.h" |
| 20 #include "ash/host/root_window_transformer.h" | 19 #include "ash/host/root_window_transformer.h" |
| 21 #include "ash/root_window_controller.h" | 20 #include "ash/root_window_controller.h" |
| 22 #include "ash/root_window_settings.h" | 21 #include "ash/root_window_settings.h" |
| 23 #include "ash/screen_util.h" | 22 #include "ash/screen_util.h" |
| 24 #include "ash/shell.h" | 23 #include "ash/shell.h" |
| 25 #include "ash/shell_delegate.h" | 24 #include "ash/shell_delegate.h" |
| 26 #include "ash/wm/coordinate_conversion.h" | 25 #include "ash/wm/coordinate_conversion.h" |
| 27 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 // stale display info from previous tests. | 243 // stale display info from previous tests. |
| 245 primary_display_id = gfx::Display::kInvalidDisplayID; | 244 primary_display_id = gfx::Display::kInvalidDisplayID; |
| 246 } | 245 } |
| 247 | 246 |
| 248 DisplayController::~DisplayController() { | 247 DisplayController::~DisplayController() { |
| 249 } | 248 } |
| 250 | 249 |
| 251 void DisplayController::Start() { | 250 void DisplayController::Start() { |
| 252 // Created here so that Shell has finished being created. Adds itself | 251 // Created here so that Shell has finished being created. Adds itself |
| 253 // as a ShellObserver. | 252 // as a ShellObserver. |
| 254 virtual_keyboard_window_controller_.reset( | |
| 255 new VirtualKeyboardWindowController); | |
| 256 Shell::GetScreen()->AddObserver(this); | 253 Shell::GetScreen()->AddObserver(this); |
| 257 Shell::GetInstance()->display_manager()->set_delegate(this); | 254 Shell::GetInstance()->display_manager()->set_delegate(this); |
| 258 } | 255 } |
| 259 | 256 |
| 260 void DisplayController::Shutdown() { | 257 void DisplayController::Shutdown() { |
| 261 // Unset the display manager's delegate here because | 258 // Unset the display manager's delegate here because |
| 262 // DisplayManager outlives DisplayController. | 259 // DisplayManager outlives DisplayController. |
| 263 Shell::GetInstance()->display_manager()->set_delegate(NULL); | 260 Shell::GetInstance()->display_manager()->set_delegate(NULL); |
| 264 | 261 |
| 265 cursor_window_controller_.reset(); | 262 cursor_window_controller_.reset(); |
| 266 mirror_window_controller_.reset(); | 263 mirror_window_controller_.reset(); |
| 267 virtual_keyboard_window_controller_.reset(); | |
| 268 | 264 |
| 269 Shell::GetScreen()->RemoveObserver(this); | 265 Shell::GetScreen()->RemoveObserver(this); |
| 270 | 266 |
| 271 int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 267 int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
| 272 | 268 |
| 273 // Delete non primary root window controllers first, then | 269 // Delete non primary root window controllers first, then |
| 274 // delete the primary root window controller. | 270 // delete the primary root window controller. |
| 275 aura::Window::Windows root_windows = DisplayController::GetAllRootWindows(); | 271 aura::Window::Windows root_windows = DisplayController::GetAllRootWindows(); |
| 276 std::vector<RootWindowController*> to_delete; | 272 std::vector<RootWindowController*> to_delete; |
| 277 RootWindowController* primary_rwc = NULL; | 273 RootWindowController* primary_rwc = NULL; |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 cursor_window_controller_->UpdateContainer(); | 655 cursor_window_controller_->UpdateContainer(); |
| 660 } | 656 } |
| 661 } | 657 } |
| 662 | 658 |
| 663 void DisplayController::CreateOrUpdateNonDesktopDisplay( | 659 void DisplayController::CreateOrUpdateNonDesktopDisplay( |
| 664 const DisplayInfo& info) { | 660 const DisplayInfo& info) { |
| 665 switch (GetDisplayManager()->second_display_mode()) { | 661 switch (GetDisplayManager()->second_display_mode()) { |
| 666 case DisplayManager::MIRRORING: | 662 case DisplayManager::MIRRORING: |
| 667 mirror_window_controller_->UpdateWindow(info); | 663 mirror_window_controller_->UpdateWindow(info); |
| 668 cursor_window_controller_->UpdateContainer(); | 664 cursor_window_controller_->UpdateContainer(); |
| 669 virtual_keyboard_window_controller_->Close(); | |
| 670 break; | |
| 671 case DisplayManager::VIRTUAL_KEYBOARD: | |
| 672 mirror_window_controller_->Close(); | |
| 673 cursor_window_controller_->UpdateContainer(); | |
| 674 virtual_keyboard_window_controller_->UpdateWindow(info); | |
| 675 break; | 665 break; |
| 676 case DisplayManager::EXTENDED: | 666 case DisplayManager::EXTENDED: |
| 677 NOTREACHED(); | 667 NOTREACHED(); |
| 678 } | 668 } |
| 679 } | 669 } |
| 680 | 670 |
| 681 void DisplayController::CloseNonDesktopDisplay() { | 671 void DisplayController::CloseNonDesktopDisplay() { |
| 682 mirror_window_controller_->Close(); | 672 mirror_window_controller_->Close(); |
| 683 cursor_window_controller_->UpdateContainer(); | 673 cursor_window_controller_->UpdateContainer(); |
| 684 virtual_keyboard_window_controller_->Close(); | |
| 685 } | 674 } |
| 686 | 675 |
| 687 void DisplayController::PreDisplayConfigurationChange(bool clear_focus) { | 676 void DisplayController::PreDisplayConfigurationChange(bool clear_focus) { |
| 688 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); | 677 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); |
| 689 focus_activation_store_->Store(clear_focus); | 678 focus_activation_store_->Store(clear_focus); |
| 690 gfx::Screen* screen = Shell::GetScreen(); | 679 gfx::Screen* screen = Shell::GetScreen(); |
| 691 gfx::Point point_in_screen = screen->GetCursorScreenPoint(); | 680 gfx::Point point_in_screen = screen->GetCursorScreenPoint(); |
| 692 gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen); | 681 gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen); |
| 693 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); | 682 aura::Window* root_window = GetRootWindowForDisplayId(display.id()); |
| 694 | 683 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 std::string name = | 775 std::string name = |
| 787 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 776 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
| 788 gfx::AcceleratedWidget xwindow = | 777 gfx::AcceleratedWidget xwindow = |
| 789 root_windows[i]->GetHost()->GetAcceleratedWidget(); | 778 root_windows[i]->GetHost()->GetAcceleratedWidget(); |
| 790 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 779 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
| 791 } | 780 } |
| 792 #endif | 781 #endif |
| 793 } | 782 } |
| 794 | 783 |
| 795 } // namespace ash | 784 } // namespace ash |
| OLD | NEW |