| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/virtual_keyboard_window_controller.h" | 5 #include "ash/display/virtual_keyboard_window_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/display_info.h" | 8 #include "ash/display/display_info.h" |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/root_window_transformers.h" | 10 #include "ash/display/root_window_transformers.h" |
| 11 #include "ash/host/window_tree_host_factory.h" | 11 #include "ash/host/ash_window_tree_host.h" |
| 12 #include "ash/host/root_window_transformer.h" |
| 12 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 13 #include "ash/root_window_settings.h" | 14 #include "ash/root_window_settings.h" |
| 14 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 15 #include "ash/shell_window_ids.h" | 16 #include "ash/shell_window_ids.h" |
| 16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 19 #include "ui/aura/root_window_transformer.h" | |
| 20 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
| 21 #include "ui/keyboard/keyboard_controller.h" | 21 #include "ui/keyboard/keyboard_controller.h" |
| 22 #include "ui/keyboard/keyboard_util.h" | 22 #include "ui/keyboard/keyboard_util.h" |
| 23 | 23 |
| 24 namespace ash { | 24 namespace ash { |
| 25 namespace internal { | 25 namespace internal { |
| 26 | 26 |
| 27 VirtualKeyboardWindowController::VirtualKeyboardWindowController() { | 27 VirtualKeyboardWindowController::VirtualKeyboardWindowController() { |
| 28 Shell::GetInstance()->AddShellObserver(this); | 28 Shell::GetInstance()->AddShellObserver(this); |
| 29 } | 29 } |
| 30 | 30 |
| 31 VirtualKeyboardWindowController::~VirtualKeyboardWindowController() { | 31 VirtualKeyboardWindowController::~VirtualKeyboardWindowController() { |
| 32 Shell::GetInstance()->RemoveShellObserver(this); | 32 Shell::GetInstance()->RemoveShellObserver(this); |
| 33 // Make sure the root window gets deleted before cursor_window_delegate. | 33 // Make sure the root window gets deleted before cursor_window_delegate. |
| 34 Close(); | 34 Close(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void VirtualKeyboardWindowController::ActivateKeyboard( | 37 void VirtualKeyboardWindowController::ActivateKeyboard( |
| 38 keyboard::KeyboardController* keyboard_controller) { | 38 keyboard::KeyboardController* keyboard_controller) { |
| 39 root_window_controller_->ActivateKeyboard(keyboard_controller); | 39 root_window_controller_->ActivateKeyboard(keyboard_controller); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void VirtualKeyboardWindowController::UpdateWindow( | 42 void VirtualKeyboardWindowController::UpdateWindow( |
| 43 const DisplayInfo& display_info) { | 43 const DisplayInfo& display_info) { |
| 44 static int virtual_keyboard_host_count = 0; | 44 static int virtual_keyboard_host_count = 0; |
| 45 if (!root_window_controller_.get()) { | 45 if (!root_window_controller_.get()) { |
| 46 const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); | 46 const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); |
| 47 aura::WindowTreeHost* host = | 47 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(bounds_in_native); |
| 48 Shell::GetInstance()->window_tree_host_factory()->CreateWindowTreeHost( | 48 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
| 49 bounds_in_native); | 49 |
| 50 host->window()->SetName( | 50 host->window()->SetName(base::StringPrintf("VirtualKeyboardRootWindow-%d", |
| 51 base::StringPrintf("VirtualKeyboardRootWindow-%d", | 51 virtual_keyboard_host_count++)); |
| 52 virtual_keyboard_host_count++)); | |
| 53 | 52 |
| 54 // No need to remove WindowTreeHostObserver because the DisplayController | 53 // No need to remove WindowTreeHostObserver because the DisplayController |
| 55 // outlives the host. | 54 // outlives the host. |
| 56 host->AddObserver(Shell::GetInstance()->display_controller()); | 55 host->AddObserver(Shell::GetInstance()->display_controller()); |
| 57 InitRootWindowSettings(host->window())->display_id = display_info.id(); | 56 InitRootWindowSettings(host->window())->display_id = display_info.id(); |
| 58 host->InitHost(); | 57 host->InitHost(); |
| 59 RootWindowController::CreateForVirtualKeyboardDisplay(host); | 58 RootWindowController::CreateForVirtualKeyboardDisplay(ash_host); |
| 60 root_window_controller_.reset(GetRootWindowController(host->window())); | 59 root_window_controller_.reset(GetRootWindowController(host->window())); |
| 61 root_window_controller_->host()->Show(); | 60 root_window_controller_->host()->Show(); |
| 62 root_window_controller_->ActivateKeyboard( | 61 root_window_controller_->ActivateKeyboard( |
| 63 Shell::GetInstance()->keyboard_controller()); | 62 Shell::GetInstance()->keyboard_controller()); |
| 64 FlipDisplay(); | 63 FlipDisplay(); |
| 65 } else { | 64 } else { |
| 66 aura::WindowTreeHost* host = root_window_controller_->host(); | 65 aura::WindowTreeHost* host = root_window_controller_->host(); |
| 67 GetRootWindowSettings(host->window())->display_id = display_info.id(); | 66 GetRootWindowSettings(host->window())->display_id = display_info.id(); |
| 68 host->SetBounds(display_info.bounds_in_native()); | 67 host->SetBounds(display_info.bounds_in_native()); |
| 69 } | 68 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 82 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 81 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 83 if (!display_manager->virtual_keyboard_root_window_enabled()) { | 82 if (!display_manager->virtual_keyboard_root_window_enabled()) { |
| 84 NOTREACHED() << "Attempting to flip virtual keyboard root window when it " | 83 NOTREACHED() << "Attempting to flip virtual keyboard root window when it " |
| 85 << "is not enabled."; | 84 << "is not enabled."; |
| 86 return; | 85 return; |
| 87 } | 86 } |
| 88 display_manager->SetDisplayRotation( | 87 display_manager->SetDisplayRotation( |
| 89 display_manager->non_desktop_display().id(), gfx::Display::ROTATE_180); | 88 display_manager->non_desktop_display().id(), gfx::Display::ROTATE_180); |
| 90 | 89 |
| 91 aura::WindowTreeHost* host = root_window_controller_->host(); | 90 aura::WindowTreeHost* host = root_window_controller_->host(); |
| 92 scoped_ptr<aura::RootWindowTransformer> transformer( | 91 scoped_ptr<RootWindowTransformer> transformer( |
| 93 internal::CreateRootWindowTransformerForDisplay(host->window(), | 92 internal::CreateRootWindowTransformerForDisplay(host->window(), |
| 94 display_manager->non_desktop_display())); | 93 display_manager->non_desktop_display())); |
| 95 host->SetRootWindowTransformer(transformer.Pass()); | 94 root_window_controller_->ash_host()->SetRootWindowTransformer(transformer.Pass
()); |
| 96 } | 95 } |
| 97 | 96 |
| 98 void VirtualKeyboardWindowController::OnMaximizeModeStarted() { | 97 void VirtualKeyboardWindowController::OnMaximizeModeStarted() { |
| 99 keyboard::SetTouchKeyboardEnabled(true); | 98 keyboard::SetTouchKeyboardEnabled(true); |
| 100 Shell::GetInstance()->CreateKeyboard(); | 99 Shell::GetInstance()->CreateKeyboard(); |
| 101 } | 100 } |
| 102 | 101 |
| 103 void VirtualKeyboardWindowController::OnMaximizeModeEnded() { | 102 void VirtualKeyboardWindowController::OnMaximizeModeEnded() { |
| 104 keyboard::SetTouchKeyboardEnabled(false); | 103 keyboard::SetTouchKeyboardEnabled(false); |
| 105 if (!keyboard::IsKeyboardEnabled()) | 104 if (!keyboard::IsKeyboardEnabled()) |
| 106 Shell::GetInstance()->DeactivateKeyboard(); | 105 Shell::GetInstance()->DeactivateKeyboard(); |
| 107 } | 106 } |
| 108 | 107 |
| 109 } // namespace internal | 108 } // namespace internal |
| 110 } // namespace ash | 109 } // namespace ash |
| OLD | NEW |