Commit 8502842e authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

tablet: Hide/show mouse on enter/exit tablet, not on block/unblock input

The mouse cursor will be hidden/shown when entering/exiting tablet mode,
instead of when internal touchpad input events are blocked/unblocked.
Examples:
1. Detach the internal keyboard/touchpad from a nocturne. It enters
tablet mode, but it does not block internal touchpad input events,
because the internal touchpad is gone. With the present CL, the mouse
cursor will be hidden. Without the present CL, it is not.
2. Attach an external pointing device and then flip the lid to tablet
position and back to clamshell position. Without the present CL, the
mouse cursor will be hidden when you flip to tablet position, and then
shown when you flip back to clamshell position. With the present CL,
that will not happen.

Fixed: 1123687, 1133031
Test: All/TabletModeControllerTest.ShowAndHideMouseCursorTest/?
Change-Id: I22cb7d3ffeb6d62b1b74f182c4bbe73b2338ff2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436325Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813819}
parent eb01ab84
......@@ -21,7 +21,6 @@
#include "components/prefs/pref_service.h"
#include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/wm/core/cursor_manager.h"
namespace ash {
......@@ -173,23 +172,11 @@ void TouchDevicesController::UpdateTapDraggingEnabled() {
}
void TouchDevicesController::UpdateTouchpadEnabled() {
bool enabled = GetTouchpadEnabled(TouchDeviceEnabledSource::GLOBAL) &&
GetTouchpadEnabled(TouchDeviceEnabledSource::USER_PREF);
ui::InputController* input_controller =
ui::OzonePlatform::GetInstance()->GetInputController();
const bool old_value = input_controller->IsInternalTouchpadEnabled();
input_controller->SetInternalTouchpadEnabled(enabled);
if (old_value == input_controller->IsInternalTouchpadEnabled())
return; // Value didn't actually change.
::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager();
if (!cursor_manager)
return;
if (enabled)
cursor_manager->ShowCursor();
else
cursor_manager->HideCursor();
ui::OzonePlatform::GetInstance()
->GetInputController()
->SetInternalTouchpadEnabled(
GetTouchpadEnabled(TouchDeviceEnabledSource::GLOBAL) &&
GetTouchpadEnabled(TouchDeviceEnabledSource::USER_PREF));
}
void TouchDevicesController::UpdateTouchscreenEnabled() {
......
......@@ -54,6 +54,7 @@
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/geometry/vector3d_f.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/cursor_manager.h"
#include "ui/wm/core/window_util.h"
namespace ash {
......@@ -888,6 +889,7 @@ void TabletModeController::SetTabletModeEnabledInternal(bool should_enable) {
VLOG(1) << "Exit tablet mode.";
UpdateInternalInputDevicesEventBlocker();
Shell::Get()->cursor_manager()->ShowCursor();
}
}
......@@ -1152,6 +1154,7 @@ void TabletModeController::FinishInitTabletMode() {
}
UpdateInternalInputDevicesEventBlocker();
Shell::Get()->cursor_manager()->HideCursor();
VLOG(1) << "Enter tablet mode.";
}
......
......@@ -65,6 +65,7 @@
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/vector3d_f.h"
#include "ui/message_center/message_center.h"
#include "ui/wm/core/cursor_manager.h"
#include "ui/wm/core/window_util.h"
namespace ash {
......@@ -1069,6 +1070,19 @@ TEST_P(TabletModeControllerTest, InternalKeyboardMouseInDockedModeTest) {
EXPECT_TRUE(AreEventsBlocked());
}
// Test that the mouse cursor is hidden when entering tablet mode, and shown
// when exiting tablet mode.
TEST_P(TabletModeControllerTest, ShowAndHideMouseCursorTest) {
wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager();
EXPECT_TRUE(cursor_manager->IsCursorVisible());
tablet_mode_controller()->SetEnabledForTest(true);
EXPECT_FALSE(cursor_manager->IsCursorVisible());
tablet_mode_controller()->SetEnabledForTest(false);
EXPECT_TRUE(cursor_manager->IsCursorVisible());
}
class TabletModeControllerForceTabletModeTest
: public TabletModeControllerTest {
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment