summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorafakhry <afakhry@chromium.org>2015-11-09 18:31:22 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-10 02:32:09 +0000
commite8eac60b676dc33060e16c1d0e69f8c5150e68ca (patch)
tree7bb6e2404f61036076fdc09fa22be8a7ef0f5206 /ash
parent90b6605758feea9d4f2a56ad3f6992e1e868b445 (diff)
downloadchromium_src-e8eac60b676dc33060e16c1d0e69f8c5150e68ca.zip
chromium_src-e8eac60b676dc33060e16c1d0e69f8c5150e68ca.tar.gz
chromium_src-e8eac60b676dc33060e16c1d0e69f8c5150e68ca.tar.bz2
Developer Feature: Add Debug Accelerators to Toggle Touchscreen/Touchpad On or Off
Add two debugging accelerators for toggling the touchscreen / touchpad on or off. These settings must be persistent between reboots. We ignore the case when users turn off the debugging accelerators flag. This is only for ChromeOS. We add an UMA user metric to track how often they're used. The two shortcuts are: Search+Shift+T ---> Toggle touch screen. Search+Shift+P ---> Toggle touchpad. BUG=546654 Review URL: https://codereview.chromium.org/1412623006 Cr-Commit-Position: refs/heads/master@{#358758}
Diffstat (limited to 'ash')
-rw-r--r--ash/accelerators/accelerator_controller.cc6
-rw-r--r--ash/accelerators/accelerator_table.cc14
-rw-r--r--ash/accelerators/accelerator_table.h2
-rw-r--r--ash/accelerators/debug_commands.cc25
-rw-r--r--ash/shell_delegate.h4
-rw-r--r--ash/wm/maximize_mode/maximize_mode_controller.cc3
-rw-r--r--ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.cc14
-rw-r--r--ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h4
-rw-r--r--ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc19
9 files changed, 78 insertions, 13 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index b18d0a0..f7e1e9e 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -986,6 +986,8 @@ bool AcceleratorController::CanPerformAction(
return CanHandlePositionCenter();
#if defined(OS_CHROMEOS)
case DEBUG_ADD_REMOVE_DISPLAY:
+ case DEBUG_TOGGLE_TOUCH_PAD:
+ case DEBUG_TOGGLE_TOUCH_SCREEN:
case DEBUG_TOGGLE_UNIFIED_DESKTOP:
return debug::DebugAcceleratorsEnabled();
case DISABLE_CAPS_LOCK:
@@ -1242,8 +1244,8 @@ void AcceleratorController::PerformAction(AcceleratorAction action,
HandleBrightnessUp(brightness_control_delegate_.get(), accelerator);
break;
case DEBUG_ADD_REMOVE_DISPLAY:
- debug::PerformDebugActionIfEnabled(action);
- break;
+ case DEBUG_TOGGLE_TOUCH_PAD:
+ case DEBUG_TOGGLE_TOUCH_SCREEN:
case DEBUG_TOGGLE_UNIFIED_DESKTOP:
debug::PerformDebugActionIfEnabled(action);
break;
diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc
index 35888ed..c848eae 100644
--- a/ash/accelerators/accelerator_table.cc
+++ b/ash/accelerators/accelerator_table.cc
@@ -238,6 +238,10 @@ const AcceleratorData kDebugAcceleratorData[] = {
DEBUG_TOGGLE_UNIFIED_DESKTOP},
{true, ui::VKEY_M, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN,
TOGGLE_MIRROR_MODE},
+ {true, ui::VKEY_P, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN,
+ DEBUG_TOGGLE_TOUCH_PAD},
+ {true, ui::VKEY_T, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN,
+ DEBUG_TOGGLE_TOUCH_SCREEN},
{true, ui::VKEY_W, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, TOGGLE_WIFI},
// Extra shortcut for display swapping as alt-f4 is taken on linux desktop.
{true, ui::VKEY_S, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN,
@@ -320,6 +324,8 @@ const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = {
BRIGHTNESS_DOWN,
BRIGHTNESS_UP,
DEBUG_ADD_REMOVE_DISPLAY,
+ DEBUG_TOGGLE_TOUCH_PAD,
+ DEBUG_TOGGLE_TOUCH_SCREEN,
DISABLE_CAPS_LOCK,
DISABLE_GPU_WATCHDOG,
KEYBOARD_BRIGHTNESS_DOWN,
@@ -373,6 +379,8 @@ const AcceleratorAction kActionsAllowedAtModalWindow[] = {
BRIGHTNESS_DOWN,
BRIGHTNESS_UP,
DEBUG_ADD_REMOVE_DISPLAY,
+ DEBUG_TOGGLE_TOUCH_PAD,
+ DEBUG_TOGGLE_TOUCH_SCREEN,
DISABLE_CAPS_LOCK,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
@@ -411,6 +419,8 @@ const AcceleratorAction kNonrepeatableActions[] = {
TOGGLE_MAXIMIZED,
WINDOW_MINIMIZE,
#if defined(OS_CHROMEOS)
+ DEBUG_TOGGLE_TOUCH_PAD,
+ DEBUG_TOGGLE_TOUCH_SCREEN,
LOCK_SCREEN,
#endif
};
@@ -439,6 +449,8 @@ const AcceleratorAction kActionsAllowedInAppMode[] = {
BRIGHTNESS_DOWN,
BRIGHTNESS_UP,
DEBUG_ADD_REMOVE_DISPLAY,
+ DEBUG_TOGGLE_TOUCH_PAD,
+ DEBUG_TOGGLE_TOUCH_SCREEN,
DISABLE_CAPS_LOCK,
DISABLE_GPU_WATCHDOG,
KEYBOARD_BRIGHTNESS_DOWN,
@@ -488,6 +500,8 @@ const AcceleratorAction kActionsKeepingMenuOpen[] = {
#if defined(OS_CHROMEOS)
BRIGHTNESS_DOWN,
BRIGHTNESS_UP,
+ DEBUG_TOGGLE_TOUCH_PAD,
+ DEBUG_TOGGLE_TOUCH_SCREEN,
DISABLE_CAPS_LOCK,
KEYBOARD_BRIGHTNESS_DOWN,
KEYBOARD_BRIGHTNESS_UP,
diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h
index 658cad5..e691367 100644
--- a/ash/accelerators/accelerator_table.h
+++ b/ash/accelerators/accelerator_table.h
@@ -112,6 +112,8 @@ enum AcceleratorAction {
BRIGHTNESS_DOWN,
BRIGHTNESS_UP,
DEBUG_ADD_REMOVE_DISPLAY,
+ DEBUG_TOGGLE_TOUCH_PAD,
+ DEBUG_TOGGLE_TOUCH_SCREEN,
DEBUG_TOGGLE_UNIFIED_DESKTOP,
DISABLE_CAPS_LOCK,
DISABLE_GPU_WATCHDOG,
diff --git a/ash/accelerators/debug_commands.cc b/ash/accelerators/debug_commands.cc
index fe4589d..4e7a4e8 100644
--- a/ash/accelerators/debug_commands.cc
+++ b/ash/accelerators/debug_commands.cc
@@ -13,8 +13,11 @@
#include "ash/host/ash_window_tree_host.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
+#include "ash/shell_delegate.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
+#include "base/metrics/user_metrics.h"
+#include "base/metrics/user_metrics_action.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "ui/aura/window.h"
@@ -123,6 +126,22 @@ void HandleToggleDesktopBackgroundMode() {
}
}
+#if defined(OS_CHROMEOS)
+
+void HandleToggleTouchpad() {
+ base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchpad"));
+
+ ash::Shell::GetInstance()->delegate()->ToggleTouchpad();
+}
+
+void HandleToggleTouchscreen() {
+ base::RecordAction(base::UserMetricsAction("Accel_Toggle_Touchscreen"));
+
+ ash::Shell::GetInstance()->delegate()->ToggleTouchscreen();
+}
+
+#endif // defined(OS_CHROMEOS)
+
} // namespace
void PrintUIHierarchies() {
@@ -148,6 +167,12 @@ void PerformDebugActionIfEnabled(AcceleratorAction action) {
case DEBUG_ADD_REMOVE_DISPLAY:
Shell::GetInstance()->display_manager()->AddRemoveDisplay();
break;
+ case DEBUG_TOGGLE_TOUCH_PAD:
+ HandleToggleTouchpad();
+ break;
+ case DEBUG_TOGGLE_TOUCH_SCREEN:
+ HandleToggleTouchscreen();
+ break;
case DEBUG_TOGGLE_UNIFIED_DESKTOP:
Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(
!Shell::GetInstance()->display_manager()->unified_desktop_enabled());
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index f2c3971..e378e77 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -162,6 +162,10 @@ class ASH_EXPORT ShellDelegate {
virtual void OpenKeyboardShortcutHelpPage() const {}
virtual gfx::Image GetDeprecatedAcceleratorImage() const = 0;
+
+ // Toggles the status of the touchpad / touchscreen on or off.
+ virtual void ToggleTouchpad() {}
+ virtual void ToggleTouchscreen() {}
};
} // namespace ash
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.cc b/ash/wm/maximize_mode/maximize_mode_controller.cc
index 50403ec..c732863 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller.cc
@@ -301,6 +301,9 @@ void MaximizeModeController::HandleHingeRotation(
HasSwitch(switches::kAshEnableTouchViewTesting)) {
EnterMaximizeMode();
}
+ // Always reset first to avoid creation before destruction of a previous
+ // object.
+ event_blocker_.reset();
#if defined(USE_X11)
event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardX11);
#elif defined(USE_OZONE)
diff --git a/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.cc b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.cc
index a6d0b64..41f4849 100644
--- a/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.cc
+++ b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.cc
@@ -18,10 +18,11 @@ ScopedDisableInternalMouseAndKeyboardOzone::
ScopedDisableInternalMouseAndKeyboardOzone() {
ui::InputController* input_controller =
ui::OzonePlatform::GetInstance()->GetInputController();
- if (input_controller->HasTouchpad()) {
+ if (input_controller->HasTouchpad() &&
+ input_controller->IsInternalTouchpadEnabled()) {
+ should_ignore_touch_pad_ = false;
input_controller->SetInternalTouchpadEnabled(false);
- aura::client::GetCursorClient(Shell::GetInstance()->GetPrimaryRootWindow())
- ->HideCursor();
+ Shell::GetInstance()->cursor_manager()->HideCursor();
}
// Allow the acccessible keys present on the side of some devices to continue
@@ -38,7 +39,12 @@ ScopedDisableInternalMouseAndKeyboardOzone::
~ScopedDisableInternalMouseAndKeyboardOzone() {
ui::InputController* input_controller =
ui::OzonePlatform::GetInstance()->GetInputController();
- input_controller->SetInternalTouchpadEnabled(true);
+
+ if (!should_ignore_touch_pad_) {
+ input_controller->SetInternalTouchpadEnabled(true);
+ Shell::GetInstance()->cursor_manager()->ShowCursor();
+ }
+
input_controller->SetInternalKeyboardFilter(false /* enable_filter */,
std::vector<ui::DomCode>());
}
diff --git a/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h
index 2376504..6783fcb 100644
--- a/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h
+++ b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h
@@ -19,6 +19,10 @@ class ScopedDisableInternalMouseAndKeyboardOzone
~ScopedDisableInternalMouseAndKeyboardOzone() override;
private:
+ // If the touch pad is already disabled we ignore re-enabling it in the
+ // destructor.
+ bool should_ignore_touch_pad_ = false;
+
DISALLOW_COPY_AND_ASSIGN(ScopedDisableInternalMouseAndKeyboardOzone);
};
diff --git a/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc
index 7704394..2f7fde2 100644
--- a/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc
+++ b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc
@@ -73,8 +73,7 @@ ScopedDisableInternalMouseAndKeyboardX11::
last_mouse_location_(GetMouseLocationInScreen()) {
ui::DeviceDataManagerX11* device_data_manager =
- static_cast<ui::DeviceDataManagerX11*>(
- ui::DeviceDataManager::GetInstance());
+ ui::DeviceDataManagerX11::GetInstance();
if (device_data_manager->IsXInput2Available()) {
const XIDeviceList& xi_dev_list =
ui::DeviceListCacheX11::GetInstance()->GetXI2DeviceList(
@@ -83,10 +82,14 @@ ScopedDisableInternalMouseAndKeyboardX11::
std::string device_name(xi_dev_list[i].name);
base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name);
if (device_name == kInternalTouchpadName) {
- touchpad_device_id_ = xi_dev_list[i].deviceid;
- device_data_manager->DisableDevice(touchpad_device_id_);
- aura::client::GetCursorClient(
- Shell::GetInstance()->GetPrimaryRootWindow())->HideCursor();
+ if (device_data_manager->IsDeviceEnabled(xi_dev_list[i].deviceid)) {
+ // If the touchpad is already disabled we will do nothing about it.
+ // This will result in doing nothing in the destructor as well since
+ // |touchpad_device_id_| will remain |kDeviceIdNone|.
+ touchpad_device_id_ = xi_dev_list[i].deviceid;
+ device_data_manager->DisableDevice(touchpad_device_id_);
+ Shell::GetInstance()->cursor_manager()->HideCursor();
+ }
} else if (device_name == kCoreKeyboardName) {
core_keyboard_device_id_ = xi_dev_list[i].deviceid;
device_data_manager->DisableDevice(core_keyboard_device_id_);
@@ -118,8 +121,10 @@ ScopedDisableInternalMouseAndKeyboardX11::
ui::DeviceDataManagerX11* device_data_manager =
static_cast<ui::DeviceDataManagerX11*>(
ui::DeviceDataManager::GetInstance());
- if (touchpad_device_id_ != kDeviceIdNone)
+ if (touchpad_device_id_ != kDeviceIdNone) {
device_data_manager->EnableDevice(touchpad_device_id_);
+ Shell::GetInstance()->cursor_manager()->ShowCursor();
+ }
if (keyboard_device_id_ != kDeviceIdNone)
device_data_manager->EnableDevice(keyboard_device_id_);
if (core_keyboard_device_id_ != kDeviceIdNone)