OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/virtual_keyboard_controller.h" | 5 #include "ash/virtual_keyboard_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/keyboard/keyboard_ui.h" | 9 #include "ash/keyboard/keyboard_ui.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/system/tray/system_tray_notifier.h" | 12 #include "ash/system/tray/system_tray_notifier.h" |
13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 13 #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
15 #include "ash/wm_window.h" | 15 #include "ash/wm_window.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "ui/display/display.h" | 18 #include "ui/display/display.h" |
19 #include "ui/display/screen.h" | 19 #include "ui/display/screen.h" |
20 #include "ui/events/devices/input_device.h" | 20 #include "ui/events/devices/input_device.h" |
21 #include "ui/events/devices/input_device_manager.h" | 21 #include "ui/events/devices/input_device_manager.h" |
22 #include "ui/events/devices/touchscreen_device.h" | 22 #include "ui/events/devices/touchscreen_device.h" |
23 #include "ui/keyboard/keyboard_controller.h" | 23 #include "ui/keyboard/keyboard_controller.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 Shell::Get()->AddShellObserver(this); | 72 Shell::Get()->AddShellObserver(this); |
73 ui::InputDeviceManager::GetInstance()->AddObserver(this); | 73 ui::InputDeviceManager::GetInstance()->AddObserver(this); |
74 UpdateDevices(); | 74 UpdateDevices(); |
75 } | 75 } |
76 | 76 |
77 VirtualKeyboardController::~VirtualKeyboardController() { | 77 VirtualKeyboardController::~VirtualKeyboardController() { |
78 Shell::Get()->RemoveShellObserver(this); | 78 Shell::Get()->RemoveShellObserver(this); |
79 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); | 79 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); |
80 } | 80 } |
81 | 81 |
82 void VirtualKeyboardController::OnMaximizeModeStarted() { | 82 void VirtualKeyboardController::OnTabletModeStarted() { |
83 if (!IsSmartVirtualKeyboardEnabled()) { | 83 if (!IsSmartVirtualKeyboardEnabled()) { |
84 SetKeyboardEnabled(true); | 84 SetKeyboardEnabled(true); |
85 } else { | 85 } else { |
86 UpdateKeyboardEnabled(); | 86 UpdateKeyboardEnabled(); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 void VirtualKeyboardController::OnMaximizeModeEnded() { | 90 void VirtualKeyboardController::OnTabletModeEnded() { |
91 if (!IsSmartVirtualKeyboardEnabled()) { | 91 if (!IsSmartVirtualKeyboardEnabled()) { |
92 SetKeyboardEnabled(false); | 92 SetKeyboardEnabled(false); |
93 } else { | 93 } else { |
94 UpdateKeyboardEnabled(); | 94 UpdateKeyboardEnabled(); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 void VirtualKeyboardController::OnTouchscreenDeviceConfigurationChanged() { | 98 void VirtualKeyboardController::OnTouchscreenDeviceConfigurationChanged() { |
99 UpdateDevices(); | 99 UpdateDevices(); |
100 } | 100 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL) | 175 if (type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL) |
176 has_external_keyboard_ = true; | 176 has_external_keyboard_ = true; |
177 } | 177 } |
178 // Update keyboard state. | 178 // Update keyboard state. |
179 UpdateKeyboardEnabled(); | 179 UpdateKeyboardEnabled(); |
180 } | 180 } |
181 | 181 |
182 void VirtualKeyboardController::UpdateKeyboardEnabled() { | 182 void VirtualKeyboardController::UpdateKeyboardEnabled() { |
183 if (!IsSmartVirtualKeyboardEnabled()) { | 183 if (!IsSmartVirtualKeyboardEnabled()) { |
184 SetKeyboardEnabled(Shell::Get() | 184 SetKeyboardEnabled(Shell::Get() |
185 ->maximize_mode_controller() | 185 ->tablet_mode_controller() |
186 ->IsMaximizeModeWindowManagerEnabled()); | 186 ->IsTabletModeWindowManagerEnabled()); |
187 return; | 187 return; |
188 } | 188 } |
189 bool ignore_internal_keyboard = Shell::Get() | 189 bool ignore_internal_keyboard = Shell::Get() |
190 ->maximize_mode_controller() | 190 ->tablet_mode_controller() |
191 ->IsMaximizeModeWindowManagerEnabled(); | 191 ->IsTabletModeWindowManagerEnabled(); |
192 bool is_internal_keyboard_active = | 192 bool is_internal_keyboard_active = |
193 has_internal_keyboard_ && !ignore_internal_keyboard; | 193 has_internal_keyboard_ && !ignore_internal_keyboard; |
194 SetKeyboardEnabled(!is_internal_keyboard_active && has_touchscreen_ && | 194 SetKeyboardEnabled(!is_internal_keyboard_active && has_touchscreen_ && |
195 (!has_external_keyboard_ || ignore_external_keyboard_)); | 195 (!has_external_keyboard_ || ignore_external_keyboard_)); |
196 Shell::Get()->system_tray_notifier()->NotifyVirtualKeyboardSuppressionChanged( | 196 Shell::Get()->system_tray_notifier()->NotifyVirtualKeyboardSuppressionChanged( |
197 !is_internal_keyboard_active && has_touchscreen_ && | 197 !is_internal_keyboard_active && has_touchscreen_ && |
198 has_external_keyboard_); | 198 has_external_keyboard_); |
199 } | 199 } |
200 | 200 |
201 void VirtualKeyboardController::SetKeyboardEnabled(bool enabled) { | 201 void VirtualKeyboardController::SetKeyboardEnabled(bool enabled) { |
202 bool was_enabled = keyboard::IsKeyboardEnabled(); | 202 bool was_enabled = keyboard::IsKeyboardEnabled(); |
203 keyboard::SetTouchKeyboardEnabled(enabled); | 203 keyboard::SetTouchKeyboardEnabled(enabled); |
204 bool is_enabled = keyboard::IsKeyboardEnabled(); | 204 bool is_enabled = keyboard::IsKeyboardEnabled(); |
205 if (is_enabled == was_enabled) | 205 if (is_enabled == was_enabled) |
206 return; | 206 return; |
207 if (is_enabled) { | 207 if (is_enabled) { |
208 Shell::Get()->CreateKeyboard(); | 208 Shell::Get()->CreateKeyboard(); |
209 } else { | 209 } else { |
210 Shell::Get()->DeactivateKeyboard(); | 210 Shell::Get()->DeactivateKeyboard(); |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 } // namespace ash | 214 } // namespace ash |
OLD | NEW |