From 62e31ac2ddce4ae5fbbc2f1275e7b0da9819a408 Mon Sep 17 00:00:00 2001 From: pkotwicz Date: Wed, 14 Jan 2015 09:51:49 -0800 Subject: Port ScopedDisableInternalMouseAndKeyboardX11 to Ozone BUG=401598 TEST=Manual, see bug Review URL: https://codereview.chromium.org/806693009 Cr-Commit-Position: refs/heads/master@{#311505} --- ash/BUILD.gn | 4 ++ ash/ash.gyp | 7 ++++ ash/wm/maximize_mode/maximize_mode_controller.cc | 6 +++ ...ed_disable_internal_mouse_and_keyboard_ozone.cc | 44 ++++++++++++++++++++++ ...ped_disable_internal_mouse_and_keyboard_ozone.h | 27 +++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.cc create mode 100644 ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h (limited to 'ash') diff --git a/ash/BUILD.gn b/ash/BUILD.gn index b55fdc9..6a92848 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn @@ -74,6 +74,10 @@ component("ash") { ] } + if (use_ozone) { + deps += [ "//ui/ozone" ] + } + if (is_chromeos) { deps += [ "//device/bluetooth", diff --git a/ash/ash.gyp b/ash/ash.gyp index ba8167d..639fa84 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -528,6 +528,8 @@ 'wm/maximize_mode/maximize_mode_window_state.cc', 'wm/maximize_mode/maximize_mode_window_state.h', 'wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h', + 'wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.cc', + 'wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h', 'wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc', 'wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h', 'wm/maximize_mode/workspace_backdrop_delegate.cc', @@ -930,6 +932,11 @@ '../build/linux/system.gyp:xfixes', ], }], + ['use_ozone==1', { + 'dependencies': [ + '../ui/ozone/ozone.gyp:ozone', + ], + }], ['chromeos==1', { 'dependencies': [ '../chromeos/chromeos.gyp:chromeos', diff --git a/ash/wm/maximize_mode/maximize_mode_controller.cc b/ash/wm/maximize_mode/maximize_mode_controller.cc index f391de7..1463a50 100644 --- a/ash/wm/maximize_mode/maximize_mode_controller.cc +++ b/ash/wm/maximize_mode/maximize_mode_controller.cc @@ -24,6 +24,10 @@ #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h" #endif +#if defined(USE_OZONE) +#include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h" +#endif + #if defined(OS_CHROMEOS) #include "chromeos/dbus/dbus_thread_manager.h" #endif // OS_CHROMEOS @@ -226,6 +230,8 @@ void MaximizeModeController::HandleHingeRotation(const gfx::Vector3dF& base, } #if defined(USE_X11) event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardX11); +#elif defined(USE_OZONE) + event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardOzone); #endif } } 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 new file mode 100644 index 0000000..ddc8452 --- /dev/null +++ b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.cc @@ -0,0 +1,44 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h" + +#include + +#include "ash/shell.h" +#include "ui/aura/client/cursor_client.h" +#include "ui/events/keycodes/dom3/dom_code.h" +#include "ui/ozone/public/input_controller.h" +#include "ui/ozone/public/ozone_platform.h" + +namespace ash { + +ScopedDisableInternalMouseAndKeyboardOzone:: + ScopedDisableInternalMouseAndKeyboardOzone() { + ui::InputController* input_controller = + ui::OzonePlatform::GetInstance()->GetInputController(); + if (input_controller->HasTouchpad()) { + input_controller->DisableInternalTouchpad(); + aura::client::GetCursorClient(Shell::GetInstance()->GetPrimaryRootWindow()) + ->HideCursor(); + } + + // Allow the acccessible keys present on the side of some devices to continue + // working. + scoped_ptr> excepted_keys(new std::set); + excepted_keys->insert(ui::DomCode::VOLUME_DOWN); + excepted_keys->insert(ui::DomCode::VOLUME_UP); + excepted_keys->insert(ui::DomCode::POWER); + input_controller->DisableInternalKeyboardExceptKeys(excepted_keys.Pass()); +} + +ScopedDisableInternalMouseAndKeyboardOzone:: + ~ScopedDisableInternalMouseAndKeyboardOzone() { + ui::InputController* input_controller = + ui::OzonePlatform::GetInstance()->GetInputController(); + input_controller->EnableInternalTouchpad(); + input_controller->EnableInternalKeyboard(); +} + +} // namespace ash 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 new file mode 100644 index 0000000..2376504 --- /dev/null +++ b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_ozone.h @@ -0,0 +1,27 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_WM_MAXIMIZE_MODE_SCOPED_DISABLE_INTERNAL_MOUSE_AND_KEYBOARD_OZONE_H_ +#define ASH_WM_MAXIMIZE_MODE_SCOPED_DISABLE_INTERNAL_MOUSE_AND_KEYBOARD_OZONE_H_ + +#include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard.h" +#include "base/macros.h" + +namespace ash { + +// Disables the internal mouse and keyboard for the duration of the class' +// lifetime. +class ScopedDisableInternalMouseAndKeyboardOzone + : public ScopedDisableInternalMouseAndKeyboard { + public: + ScopedDisableInternalMouseAndKeyboardOzone(); + ~ScopedDisableInternalMouseAndKeyboardOzone() override; + + private: + DISALLOW_COPY_AND_ASSIGN(ScopedDisableInternalMouseAndKeyboardOzone); +}; + +} // namespace ash + +#endif // ASH_WM_MAXIMIZE_MODE_SCOPED_DISABLE_INTERNAL_MOUSE_AND_KEYBOARD_OZONE_H_ -- cgit v1.1