Commit 592195c4 authored by Joe Downing's avatar Joe Downing Committed by Commit Bot

Restore cursor visibility state after CRD disconnects

The core use case being addressed is the case where a user connects
to a CrOS device in Kiosk mode which is used as signage (no user
interaction).  In this scenario, the mouse cursor becomes visible when
we inject mouse input and remains visible after we disconnect.

This change checks the cursor visibility prior to any input injection
and then hides the cursor when the input injector is torn down.


Bug: 1072886
Change-Id: I7e534ffbb3a078b0f90f5d79bdf2212fb2769f11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2258780
Commit-Queue: Joe Downing <joedow@chromium.org>
Commit-Queue: Jamie Walch <jamiewalch@chromium.org>
Auto-Submit: Joe Downing <joedow@chromium.org>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781399}
parent e5ffe711
...@@ -7,14 +7,15 @@ ...@@ -7,14 +7,15 @@
#include <set> #include <set>
#include <utility> #include <utility>
#include "ash/shell.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/location.h" #include "base/location.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "remoting/host/chromeos/point_transformer.h" #include "remoting/host/chromeos/point_transformer.h"
#include "remoting/host/clipboard.h" #include "remoting/host/clipboard.h"
#include "remoting/proto/internal.pb.h" #include "remoting/proto/internal.pb.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/base/ime/chromeos/ime_keyboard.h" #include "ui/base/ime/chromeos/ime_keyboard.h"
#include "ui/base/ime/chromeos/input_method_manager.h" #include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/events/keycodes/dom/dom_code.h" #include "ui/events/keycodes/dom/dom_code.h"
...@@ -80,6 +81,7 @@ void SetCapsLockState(bool caps_lock) { ...@@ -80,6 +81,7 @@ void SetCapsLockState(bool caps_lock) {
class InputInjectorChromeos::Core { class InputInjectorChromeos::Core {
public: public:
Core(); Core();
~Core();
// Mirrors the public InputInjectorChromeos interface. // Mirrors the public InputInjectorChromeos interface.
void InjectClipboardEvent(const ClipboardEvent& event); void InjectClipboardEvent(const ClipboardEvent& event);
...@@ -91,6 +93,7 @@ class InputInjectorChromeos::Core { ...@@ -91,6 +93,7 @@ class InputInjectorChromeos::Core {
private: private:
void SetLockStates(uint32_t states); void SetLockStates(uint32_t states);
bool hide_cursor_on_disconnect_ = false;
std::unique_ptr<ui::SystemInputInjector> delegate_; std::unique_ptr<ui::SystemInputInjector> delegate_;
std::unique_ptr<Clipboard> clipboard_; std::unique_ptr<Clipboard> clipboard_;
...@@ -103,6 +106,16 @@ class InputInjectorChromeos::Core { ...@@ -103,6 +106,16 @@ class InputInjectorChromeos::Core {
InputInjectorChromeos::Core::Core() = default; InputInjectorChromeos::Core::Core() = default;
InputInjectorChromeos::Core::~Core() {
if (hide_cursor_on_disconnect_) {
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(ash::Shell::GetPrimaryRootWindow());
if (cursor_client) {
cursor_client->HideCursor();
}
}
}
void InputInjectorChromeos::Core::InjectClipboardEvent( void InputInjectorChromeos::Core::InjectClipboardEvent(
const ClipboardEvent& event) { const ClipboardEvent& event) {
clipboard_->InjectClipboardEvent(event); clipboard_->InjectClipboardEvent(event);
...@@ -159,6 +172,17 @@ void InputInjectorChromeos::Core::Start( ...@@ -159,6 +172,17 @@ void InputInjectorChromeos::Core::Start(
clipboard_ = Clipboard::Create(); clipboard_ = Clipboard::Create();
clipboard_->Start(std::move(client_clipboard)); clipboard_->Start(std::move(client_clipboard));
point_transformer_.reset(new PointTransformer()); point_transformer_.reset(new PointTransformer());
// If the cursor was hidden before we start injecting input then we should try
// to restore its state when the remote user disconnects. The main scenario
// where this is important is for devices in non-interactive Kiosk mode.
// Since no one is interacting with the screen in this mode, we will leave a
// visible cursor after disconnecting which can't be hidden w/o restarting.
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(ash::Shell::GetPrimaryRootWindow());
if (cursor_client) {
hide_cursor_on_disconnect_ = !cursor_client->IsCursorVisible();
}
} }
InputInjectorChromeos::InputInjectorChromeos( InputInjectorChromeos::InputInjectorChromeos(
...@@ -210,7 +234,7 @@ std::unique_ptr<InputInjector> InputInjector::Create( ...@@ -210,7 +234,7 @@ std::unique_ptr<InputInjector> InputInjector::Create(
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
// The Ozone input injector must be called on the UI task runner of the // The Ozone input injector must be called on the UI task runner of the
// browser process. // browser process.
return base::WrapUnique(new InputInjectorChromeos(ui_task_runner)); return std::make_unique<InputInjectorChromeos>(ui_task_runner);
} }
// static // static
......
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