Commit b8da407f authored by Harry Cutts's avatar Harry Cutts Committed by Commit Bot

[CrOS Settings] Expose pointing stick presence to device settings pages

This will be used to show or hide a separate set of settings for
pointing sticks. For now, the visibility logic is modified to show mouse
settings if either a mouse or pointing stick is connected, to preserve
existing behaviour.

To test, you can use a Python script [0] to create a fake pointing
stick with uinput.

[0]: https://gist.github.com/HarryCutts/e17783d9475e45abcc4b73b9e7aabb7a

Bug: 1114828
Test: check `hasPointingStick` value with and without a pointing stick

Change-Id: I917c8ead69a126280752a9a1a4b4bea609c7e33c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2427888
Auto-Submit: Harry Cutts <hcutts@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Yaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812790}
parent 31cfb21a
...@@ -30,6 +30,7 @@ class TestInputController : public ui::InputController { ...@@ -30,6 +30,7 @@ class TestInputController : public ui::InputController {
// these are all stubs that are not used yet in these tests // these are all stubs that are not used yet in these tests
bool HasMouse() override { return false; } bool HasMouse() override { return false; }
bool HasPointingStick() override { return false; }
bool HasTouchpad() override { return false; } bool HasTouchpad() override { return false; }
bool IsCapsLockEnabled() override { return false; } bool IsCapsLockEnabled() override { return false; }
void SetCapsLockEnabled(bool enabled) override {} void SetCapsLockEnabled(bool enabled) override {}
......
...@@ -106,6 +106,11 @@ void FakeInputDeviceSettings::SetMouseScrollAcceleration(bool enabled) { ...@@ -106,6 +106,11 @@ void FakeInputDeviceSettings::SetMouseScrollAcceleration(bool enabled) {
UpdateMouseSettings(settings); UpdateMouseSettings(settings);
} }
void FakeInputDeviceSettings::PointingStickExists(
DeviceExistsCallback callback) {
std::move(callback).Run(pointing_stick_exists_);
}
void FakeInputDeviceSettings::SetTouchpadAcceleration(bool enabled) { void FakeInputDeviceSettings::SetTouchpadAcceleration(bool enabled) {
TouchpadSettings settings; TouchpadSettings settings;
settings.SetAcceleration(enabled); settings.SetAcceleration(enabled);
...@@ -137,6 +142,10 @@ void FakeInputDeviceSettings::set_mouse_exists(bool exists) { ...@@ -137,6 +142,10 @@ void FakeInputDeviceSettings::set_mouse_exists(bool exists) {
mouse_exists_ = exists; mouse_exists_ = exists;
} }
void FakeInputDeviceSettings::set_pointing_stick_exists(bool exists) {
pointing_stick_exists_ = exists;
}
const TouchpadSettings& FakeInputDeviceSettings::current_touchpad_settings() const TouchpadSettings& FakeInputDeviceSettings::current_touchpad_settings()
const { const {
return current_touchpad_settings_; return current_touchpad_settings_;
......
...@@ -35,6 +35,7 @@ class FakeInputDeviceSettings : public InputDeviceSettings, ...@@ -35,6 +35,7 @@ class FakeInputDeviceSettings : public InputDeviceSettings,
void SetMouseReverseScroll(bool enabled) override; void SetMouseReverseScroll(bool enabled) override;
void SetMouseAcceleration(bool enabled) override; void SetMouseAcceleration(bool enabled) override;
void SetMouseScrollAcceleration(bool enabled) override; void SetMouseScrollAcceleration(bool enabled) override;
void PointingStickExists(DeviceExistsCallback callback) override;
void SetTouchpadAcceleration(bool enabled) override; void SetTouchpadAcceleration(bool enabled) override;
void SetTouchpadScrollAcceleration(bool enabled) override; void SetTouchpadScrollAcceleration(bool enabled) override;
void SetNaturalScroll(bool enabled) override; void SetNaturalScroll(bool enabled) override;
...@@ -45,6 +46,7 @@ class FakeInputDeviceSettings : public InputDeviceSettings, ...@@ -45,6 +46,7 @@ class FakeInputDeviceSettings : public InputDeviceSettings,
// Overridden from InputDeviceSettings::FakeInterface. // Overridden from InputDeviceSettings::FakeInterface.
void set_touchpad_exists(bool exists) override; void set_touchpad_exists(bool exists) override;
void set_mouse_exists(bool exists) override; void set_mouse_exists(bool exists) override;
void set_pointing_stick_exists(bool exists) override;
const TouchpadSettings& current_touchpad_settings() const override; const TouchpadSettings& current_touchpad_settings() const override;
const MouseSettings& current_mouse_settings() const override; const MouseSettings& current_mouse_settings() const override;
...@@ -54,6 +56,7 @@ class FakeInputDeviceSettings : public InputDeviceSettings, ...@@ -54,6 +56,7 @@ class FakeInputDeviceSettings : public InputDeviceSettings,
bool touchpad_exists_ = true; bool touchpad_exists_ = true;
bool mouse_exists_ = true; bool mouse_exists_ = true;
bool pointing_stick_exists_ = true;
DISALLOW_COPY_AND_ASSIGN(FakeInputDeviceSettings); DISALLOW_COPY_AND_ASSIGN(FakeInputDeviceSettings);
}; };
......
...@@ -151,6 +151,7 @@ class InputDeviceSettings { ...@@ -151,6 +151,7 @@ class InputDeviceSettings {
public: public:
virtual void set_touchpad_exists(bool exists) = 0; virtual void set_touchpad_exists(bool exists) = 0;
virtual void set_mouse_exists(bool exists) = 0; virtual void set_mouse_exists(bool exists) = 0;
virtual void set_pointing_stick_exists(bool exists) = 0;
virtual const TouchpadSettings& current_touchpad_settings() const = 0; virtual const TouchpadSettings& current_touchpad_settings() const = 0;
virtual const MouseSettings& current_mouse_settings() const = 0; virtual const MouseSettings& current_mouse_settings() const = 0;
}; };
...@@ -222,6 +223,10 @@ class InputDeviceSettings { ...@@ -222,6 +223,10 @@ class InputDeviceSettings {
// Turns mouse scroll acceleration on/off. // Turns mouse scroll acceleration on/off.
virtual void SetMouseScrollAcceleration(bool enabled) = 0; virtual void SetMouseScrollAcceleration(bool enabled) = 0;
// Calls |callback|, possibly asynchronously, after determining if a pointing
// stick is connected.
virtual void PointingStickExists(DeviceExistsCallback callback) = 0;
// Turns touchpad acceleration on/off. // Turns touchpad acceleration on/off.
virtual void SetTouchpadAcceleration(bool enabled) = 0; virtual void SetTouchpadAcceleration(bool enabled) = 0;
......
...@@ -46,6 +46,7 @@ class InputDeviceSettingsImplOzone : public InputDeviceSettings { ...@@ -46,6 +46,7 @@ class InputDeviceSettingsImplOzone : public InputDeviceSettings {
void SetMouseReverseScroll(bool enabled) override; void SetMouseReverseScroll(bool enabled) override;
void SetMouseAcceleration(bool enabled) override; void SetMouseAcceleration(bool enabled) override;
void SetMouseScrollAcceleration(bool enabled) override; void SetMouseScrollAcceleration(bool enabled) override;
void PointingStickExists(DeviceExistsCallback callback) override;
void SetTouchpadAcceleration(bool enabled) override; void SetTouchpadAcceleration(bool enabled) override;
void SetTouchpadScrollAcceleration(bool enabled) override; void SetTouchpadScrollAcceleration(bool enabled) override;
void ReapplyTouchpadSettings() override; void ReapplyTouchpadSettings() override;
...@@ -159,6 +160,12 @@ void InputDeviceSettingsImplOzone::SetMouseScrollAcceleration(bool enabled) { ...@@ -159,6 +160,12 @@ void InputDeviceSettingsImplOzone::SetMouseScrollAcceleration(bool enabled) {
input_controller()->SetMouseScrollAcceleration(enabled); input_controller()->SetMouseScrollAcceleration(enabled);
} }
void InputDeviceSettingsImplOzone::PointingStickExists(
DeviceExistsCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
std::move(callback).Run(input_controller()->HasPointingStick());
}
void InputDeviceSettingsImplOzone::SetTouchpadAcceleration(bool enabled) { void InputDeviceSettingsImplOzone::SetTouchpadAcceleration(bool enabled) {
current_touchpad_settings_.SetAcceleration(enabled); current_touchpad_settings_.SetAcceleration(enabled);
input_controller()->SetTouchpadAcceleration(enabled); input_controller()->SetTouchpadAcceleration(enabled);
......
...@@ -27,6 +27,7 @@ void PointerDeviceObserver::Init() { ...@@ -27,6 +27,7 @@ void PointerDeviceObserver::Init() {
void PointerDeviceObserver::CheckDevices() { void PointerDeviceObserver::CheckDevices() {
CheckMouseExists(); CheckMouseExists();
CheckPointingStickExists();
CheckTouchpadExists(); CheckTouchpadExists();
} }
...@@ -56,6 +57,12 @@ void PointerDeviceObserver::CheckMouseExists() { ...@@ -56,6 +57,12 @@ void PointerDeviceObserver::CheckMouseExists() {
&PointerDeviceObserver::OnMouseExists, weak_factory_.GetWeakPtr())); &PointerDeviceObserver::OnMouseExists, weak_factory_.GetWeakPtr()));
} }
void PointerDeviceObserver::CheckPointingStickExists() {
InputDeviceSettings::Get()->PointingStickExists(
base::BindOnce(&PointerDeviceObserver::OnPointingStickExists,
weak_factory_.GetWeakPtr()));
}
void PointerDeviceObserver::OnTouchpadExists(bool exists) { void PointerDeviceObserver::OnTouchpadExists(bool exists) {
for (auto& observer : observers_) for (auto& observer : observers_)
observer.TouchpadExists(exists); observer.TouchpadExists(exists);
...@@ -66,6 +73,11 @@ void PointerDeviceObserver::OnMouseExists(bool exists) { ...@@ -66,6 +73,11 @@ void PointerDeviceObserver::OnMouseExists(bool exists) {
observer.MouseExists(exists); observer.MouseExists(exists);
} }
void PointerDeviceObserver::OnPointingStickExists(bool exists) {
for (auto& observer : observers_)
observer.PointingStickExists(exists);
}
PointerDeviceObserver::Observer::~Observer() { PointerDeviceObserver::Observer::~Observer() {
} }
......
...@@ -28,6 +28,7 @@ class PointerDeviceObserver : public ui::InputDeviceEventObserver { ...@@ -28,6 +28,7 @@ class PointerDeviceObserver : public ui::InputDeviceEventObserver {
public: public:
virtual void TouchpadExists(bool exists) = 0; virtual void TouchpadExists(bool exists) = 0;
virtual void MouseExists(bool exists) = 0; virtual void MouseExists(bool exists) = 0;
virtual void PointingStickExists(bool exists) = 0;
protected: protected:
Observer() {} Observer() {}
...@@ -43,10 +44,12 @@ class PointerDeviceObserver : public ui::InputDeviceEventObserver { ...@@ -43,10 +44,12 @@ class PointerDeviceObserver : public ui::InputDeviceEventObserver {
// Check for pointer devices. // Check for pointer devices.
void CheckTouchpadExists(); void CheckTouchpadExists();
void CheckMouseExists(); void CheckMouseExists();
void CheckPointingStickExists();
// Callback for pointer device checks. // Callback for pointer device checks.
void OnTouchpadExists(bool exists); void OnTouchpadExists(bool exists);
void OnMouseExists(bool exists); void OnMouseExists(bool exists);
void OnPointingStickExists(bool exists);
base::ObserverList<Observer>::Unchecked observers_; base::ObserverList<Observer>::Unchecked observers_;
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
focus-config="[[focusConfig_]]"> focus-config="[[focusConfig_]]">
<div id="main" route-path="default"> <div id="main" route-path="default">
<cr-link-row id="pointersRow" <cr-link-row id="pointersRow"
label="[[getPointersTitle_(hasMouse_, hasTouchpad_)]]" label="[[getPointersTitle_(hasMouse_, hasPointingStick_,
hasTouchpad_)]]"
on-click="onPointersTap_" on-click="onPointersTap_"
role-description="$i18n{subpageArrowRoleDescription}"></cr-link-row> role-description="$i18n{subpageArrowRoleDescription}"></cr-link-row>
<cr-link-row class="hr" id="keyboardRow" label="$i18n{keyboardTitle}" <cr-link-row class="hr" id="keyboardRow" label="$i18n{keyboardTitle}"
...@@ -50,9 +51,12 @@ ...@@ -50,9 +51,12 @@
<template is="dom-if" route-path="/pointer-overlay"> <template is="dom-if" route-path="/pointer-overlay">
<settings-subpage <settings-subpage
associated-control="[[$$('#pointersRow')]]" associated-control="[[$$('#pointersRow')]]"
page-title="[[getPointersTitle_(hasMouse_, hasTouchpad_)]]"> page-title="[[getPointersTitle_(hasMouse_, hasPointingStick_,
hasTouchpad_)]]">
<settings-pointers prefs="{{prefs}}" <settings-pointers prefs="{{prefs}}"
has-mouse="[[hasMouse_]]" has-touchpad="[[hasTouchpad_]]"> has-mouse="[[hasMouse_]]"
has-pointing-stick="[[hasPointingStick_]]"
has-touchpad="[[hasTouchpad_]]">
</settings-pointers> </settings-pointers>
</settings-subpage> </settings-subpage>
</template> </template>
......
...@@ -24,12 +24,18 @@ Polymer({ ...@@ -24,12 +24,18 @@ Polymer({
showCrostini: Boolean, showCrostini: Boolean,
/** /**
* |hasMouse_| and |hasTouchpad_| start undefined so observers don't trigger * |hasMouse_|, |hasPointingStick_|, and |hasTouchpad_| start undefined so
* until they have been populated. * observers don't trigger until they have been populated.
* @private * @private
*/ */
hasMouse_: Boolean, hasMouse_: Boolean,
/**
* Whether a pointing stick (such as a TrackPoint) is connected.
* @private
*/
hasPointingStick_: Boolean,
/** @private */ /** @private */
hasTouchpad_: Boolean, hasTouchpad_: Boolean,
...@@ -98,13 +104,15 @@ Polymer({ ...@@ -98,13 +104,15 @@ Polymer({
}, },
observers: [ observers: [
'pointersChanged_(hasMouse_, hasTouchpad_)', 'pointersChanged_(hasMouse_, hasPointingStick_, hasTouchpad_)',
], ],
/** @override */ /** @override */
attached() { attached() {
this.addWebUIListener( this.addWebUIListener(
'has-mouse-changed', this.set.bind(this, 'hasMouse_')); 'has-mouse-changed', this.set.bind(this, 'hasMouse_'));
this.addWebUIListener(
'has-pointing-stick-changed', this.set.bind(this, 'hasPointingStick_'));
this.addWebUIListener( this.addWebUIListener(
'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_')); 'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_'));
settings.DevicePageBrowserProxyImpl.getInstance().initializePointers(); settings.DevicePageBrowserProxyImpl.getInstance().initializePointers();
...@@ -124,10 +132,13 @@ Polymer({ ...@@ -124,10 +132,13 @@ Polymer({
* @private * @private
*/ */
getPointersTitle_() { getPointersTitle_() {
if (this.hasMouse_ && this.hasTouchpad_) { // For the purposes of the title, we call pointing sticks mice. The user
// will know what we mean, and otherwise we'd get too many possible titles.
const hasMouseOrPointingStick = this.hasMouse_ || this.hasPointingStick_;
if (hasMouseOrPointingStick && this.hasTouchpad_) {
return this.i18n('mouseAndTouchpadTitle'); return this.i18n('mouseAndTouchpadTitle');
} }
if (this.hasMouse_) { if (hasMouseOrPointingStick) {
return this.i18n('mouseTitle'); return this.i18n('mouseTitle');
} }
if (this.hasTouchpad_) { if (this.hasTouchpad_) {
...@@ -191,11 +202,12 @@ Polymer({ ...@@ -191,11 +202,12 @@ Polymer({
/** /**
* @param {boolean} hasMouse * @param {boolean} hasMouse
* @param {boolean} hasPointingStick
* @param {boolean} hasTouchpad * @param {boolean} hasTouchpad
* @private * @private
*/ */
pointersChanged_(hasMouse, hasTouchpad) { pointersChanged_(hasMouse, hasPointingStick, hasTouchpad) {
this.$.pointersRow.hidden = !hasMouse && !hasTouchpad; this.$.pointersRow.hidden = !hasMouse && !hasPointingStick && !hasTouchpad;
this.checkPointerSubpage_(); this.checkPointerSubpage_();
}, },
...@@ -205,7 +217,8 @@ Polymer({ ...@@ -205,7 +217,8 @@ Polymer({
*/ */
checkPointerSubpage_() { checkPointerSubpage_() {
// Check that the properties have explicitly been set to false. // Check that the properties have explicitly been set to false.
if (this.hasMouse_ === false && this.hasTouchpad_ === false && if (this.hasMouse_ === false && this.hasPointingStick_ === false &&
this.hasTouchpad_ === false &&
settings.Router.getInstance().getCurrentRoute() == settings.Router.getInstance().getCurrentRoute() ==
settings.routes.POINTERS) { settings.routes.POINTERS) {
settings.Router.getInstance().navigateTo(settings.routes.DEVICE); settings.Router.getInstance().navigateTo(settings.routes.DEVICE);
......
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
padding-inline-end: 0; padding-inline-end: 0;
} }
</style> </style>
<div id="mouse" hidden$="[[!hasMouse]]"> <div id="mouse" hidden$="[[!showMouseSection_]]">
<!-- Subsection title only appears if both mouse and touchpad exist. --> <!-- Subsection title only appears if both mouse and touchpad exist. -->
<h2 hidden$="[[!hasTouchpad]]">$i18n{mouseTitle}</h2> <h2 hidden$="[[!hasTouchpad]]">$i18n{mouseTitle}</h2>
<div class$="[[getSubsectionClass_(hasMouse, hasTouchpad)]]"> <div class$="[[getSubsectionClass_(showMouseSection_, hasTouchpad)]]">
<!-- Do not change the mouse button pref before the mouse is released. <!-- Do not change the mouse button pref before the mouse is released.
See crbug.com/686949 --> See crbug.com/686949 -->
<settings-toggle-button id="mouseSwapButton" <settings-toggle-button id="mouseSwapButton"
...@@ -107,8 +107,8 @@ ...@@ -107,8 +107,8 @@
</div> </div>
<div id="touchpad" hidden$="[[!hasTouchpad]]"> <div id="touchpad" hidden$="[[!hasTouchpad]]">
<!-- Subsection title only appears if both mouse and touchpad exist. --> <!-- Subsection title only appears if both mouse and touchpad exist. -->
<h2 hidden$="[[!hasMouse]]">$i18n{touchpadTitle}</h2> <h2 hidden$="[[!showMouseSection_]]">$i18n{touchpadTitle}</h2>
<div class$="[[getSubsectionClass_(hasMouse, hasTouchpad)]]"> <div class$="[[getSubsectionClass_(showMouseSection_, hasTouchpad)]]">
<settings-toggle-button id="enableTapToClick" <settings-toggle-button id="enableTapToClick"
pref="{{prefs.settings.touchpad.enable_tap_to_click}}" pref="{{prefs.settings.touchpad.enable_tap_to_click}}"
label="$i18n{touchpadTapToClickEnabledLabel}" label="$i18n{touchpadTapToClickEnabledLabel}"
......
...@@ -23,8 +23,20 @@ Polymer({ ...@@ -23,8 +23,20 @@ Polymer({
hasMouse: Boolean, hasMouse: Boolean,
hasPointingStick: Boolean,
hasTouchpad: Boolean, hasTouchpad: Boolean,
/**
* Interim property for use until we have a separate subsection for pointing
* sticks. (See crbug.com/1114828)
* @private
*/
showMouseSection_: {
type: Boolean,
computed: 'computeShowMouseSection_(hasMouse, hasPointingStick)',
},
/** /**
* TODO(michaelpg): settings-slider should optionally take a min and max so * TODO(michaelpg): settings-slider should optionally take a min and max so
* we don't have to generate a simple range of natural numbers ourselves. * we don't have to generate a simple range of natural numbers ourselves.
...@@ -81,6 +93,14 @@ Polymer({ ...@@ -81,6 +93,14 @@ Polymer({
}, },
}, },
/**
* @param {boolean} hasMouse
* @param {boolean} hasPointingStick
*/
computeShowMouseSection_(hasMouse, hasPointingStick) {
return hasMouse || hasPointingStick;
},
// Used to correctly identify when the mouse button has been released. // Used to correctly identify when the mouse button has been released.
// crbug.com/686949. // crbug.com/686949.
receivedMouseSwapButtonsDown_: false, receivedMouseSwapButtonsDown_: false,
...@@ -100,13 +120,13 @@ Polymer({ ...@@ -100,13 +120,13 @@ Polymer({
/** /**
* Mouse and touchpad sections are only subsections if they are both present. * Mouse and touchpad sections are only subsections if they are both present.
* @param {boolean} hasMouse * @param {boolean} showMouseSection
* @param {boolean} hasTouchpad * @param {boolean} hasTouchpad
* @return {string} * @return {string}
* @private * @private
*/ */
getSubsectionClass_(hasMouse, hasTouchpad) { getSubsectionClass_(showMouseSection, hasTouchpad) {
return hasMouse && hasTouchpad ? 'subsection' : ''; return showMouseSection && hasTouchpad ? 'subsection' : '';
}, },
/** @private */ /** @private */
......
...@@ -197,8 +197,9 @@ Polymer({ ...@@ -197,8 +197,9 @@ Polymer({
}, },
/** /**
* |hasKeyboard_|, |hasMouse_|, and |hasTouchpad_| start undefined so * |hasKeyboard_|, |hasMouse_|, |hasPointingStick_|, and |hasTouchpad_|
* observers don't trigger until they have been populated. * start undefined so observers don't trigger until they have been
* populated.
* @private * @private
*/ */
hasKeyboard_: Boolean, hasKeyboard_: Boolean,
...@@ -206,6 +207,9 @@ Polymer({ ...@@ -206,6 +207,9 @@ Polymer({
/** @private */ /** @private */
hasMouse_: Boolean, hasMouse_: Boolean,
/** @private */
hasPointingStick_: Boolean,
/** @private */ /** @private */
hasTouchpad_: Boolean, hasTouchpad_: Boolean,
...@@ -268,7 +272,8 @@ Polymer({ ...@@ -268,7 +272,8 @@ Polymer({
}, },
observers: [ observers: [
'pointersChanged_(hasMouse_, hasTouchpad_, isKioskModeActive_)', 'pointersChanged_(hasMouse_, hasPointingStick_, hasTouchpad_, ' +
'isKioskModeActive_)',
], ],
/** settings.RouteOriginBehavior override */ /** settings.RouteOriginBehavior override */
...@@ -291,6 +296,8 @@ Polymer({ ...@@ -291,6 +296,8 @@ Polymer({
attached() { attached() {
this.addWebUIListener( this.addWebUIListener(
'has-mouse-changed', this.set.bind(this, 'hasMouse_')); 'has-mouse-changed', this.set.bind(this, 'hasMouse_'));
this.addWebUIListener(
'has-pointing-stick-changed', this.set.bind(this, 'hasPointingStick_'));
this.addWebUIListener( this.addWebUIListener(
'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_')); 'has-touchpad-changed', this.set.bind(this, 'hasTouchpad_'));
this.deviceBrowserProxy_.initializePointers(); this.deviceBrowserProxy_.initializePointers();
...@@ -331,12 +338,13 @@ Polymer({ ...@@ -331,12 +338,13 @@ Polymer({
/** /**
* @param {boolean} hasMouse * @param {boolean} hasMouse
* @param {boolean} hasPointingStick
* @param {boolean} hasTouchpad * @param {boolean} hasTouchpad
* @private * @private
*/ */
pointersChanged_(hasMouse, hasTouchpad, isKioskModeActive) { pointersChanged_(hasMouse, hasTouchpad, hasPointingStick, isKioskModeActive) {
this.$.pointerSubpageButton.hidden = this.$.pointerSubpageButton.hidden =
(!hasMouse && !hasTouchpad) || isKioskModeActive; (!hasMouse && !hasPointingStick && !hasTouchpad) || isKioskModeActive;
}, },
/** /**
......
...@@ -645,4 +645,8 @@ void DeviceEmulatorMessageHandler::MouseExists(bool exists) { ...@@ -645,4 +645,8 @@ void DeviceEmulatorMessageHandler::MouseExists(bool exists) {
FireWebUIListener("mouse-exists-changed", base::Value(exists)); FireWebUIListener("mouse-exists-changed", base::Value(exists));
} }
void DeviceEmulatorMessageHandler::PointingStickExists(bool exists) {
// TODO(crbug.com/1114828): support fake pointing sticks.
}
} // namespace chromeos } // namespace chromeos
...@@ -124,6 +124,7 @@ class DeviceEmulatorMessageHandler : ...@@ -124,6 +124,7 @@ class DeviceEmulatorMessageHandler :
// system::PointerDeviceObserver::Observer: // system::PointerDeviceObserver::Observer:
void TouchpadExists(bool exists) override; void TouchpadExists(bool exists) override;
void MouseExists(bool exists) override; void MouseExists(bool exists) override;
void PointingStickExists(bool exists) override;
bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_; bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_;
std::unique_ptr<BluetoothObserver> bluetooth_observer_; std::unique_ptr<BluetoothObserver> bluetooth_observer_;
......
...@@ -44,6 +44,10 @@ void PointerHandler::MouseExists(bool exists) { ...@@ -44,6 +44,10 @@ void PointerHandler::MouseExists(bool exists) {
FireWebUIListener("has-mouse-changed", base::Value(exists)); FireWebUIListener("has-mouse-changed", base::Value(exists));
} }
void PointerHandler::PointingStickExists(bool exists) {
FireWebUIListener("has-pointing-stick-changed", base::Value(exists));
}
void PointerHandler::HandleInitialize(const base::ListValue* args) { void PointerHandler::HandleInitialize(const base::ListValue* args) {
AllowJavascript(); AllowJavascript();
......
...@@ -35,6 +35,7 @@ class PointerHandler ...@@ -35,6 +35,7 @@ class PointerHandler
// PointerDeviceObserver implementation. // PointerDeviceObserver implementation.
void TouchpadExists(bool exists) override; void TouchpadExists(bool exists) override;
void MouseExists(bool exists) override; void MouseExists(bool exists) override;
void PointingStickExists(bool exists) override;
// Initializes the page with the current pointer information. // Initializes the page with the current pointer information.
void HandleInitialize(const base::ListValue* args); void HandleInitialize(const base::ListValue* args);
......
...@@ -963,6 +963,10 @@ void DeviceSection::MouseExists(bool exists) { ...@@ -963,6 +963,10 @@ void DeviceSection::MouseExists(bool exists) {
updater.RemoveSearchTags(GetMouseSearchConcepts()); updater.RemoveSearchTags(GetMouseSearchConcepts());
} }
void DeviceSection::PointingStickExists(bool exists) {
// TODO(crbug.com/1114828): manage search tags when the UI is implemented.
}
void DeviceSection::OnDeviceListsComplete() { void DeviceSection::OnDeviceListsComplete() {
UpdateStylusSearchTags(); UpdateStylusSearchTags();
} }
......
...@@ -57,6 +57,7 @@ class DeviceSection : public OsSettingsSection, ...@@ -57,6 +57,7 @@ class DeviceSection : public OsSettingsSection,
// system::PointerDeviceObserver::Observer: // system::PointerDeviceObserver::Observer:
void TouchpadExists(bool exists) override; void TouchpadExists(bool exists) override;
void MouseExists(bool exists) override; void MouseExists(bool exists) override;
void PointingStickExists(bool exists) override;
// ui::InputDeviceObserver: // ui::InputDeviceObserver:
void OnDeviceListsComplete() override; void OnDeviceListsComplete() override;
......
...@@ -39,6 +39,7 @@ cr.define('device_page_tests', function() { ...@@ -39,6 +39,7 @@ cr.define('device_page_tests', function() {
initializePointers: function() { initializePointers: function() {
// Enable mouse and touchpad. // Enable mouse and touchpad.
cr.webUIListenerCallback('has-mouse-changed', true); cr.webUIListenerCallback('has-mouse-changed', true);
cr.webUIListenerCallback('has-pointing-stick-changed', true);
cr.webUIListenerCallback('has-touchpad-changed', true); cr.webUIListenerCallback('has-touchpad-changed', true);
}, },
...@@ -591,6 +592,8 @@ cr.define('device_page_tests', function() { ...@@ -591,6 +592,8 @@ cr.define('device_page_tests', function() {
cr.webUIListenerCallback('has-mouse-changed', false); cr.webUIListenerCallback('has-mouse-changed', false);
expectLT(0, devicePage.$$('#pointersRow').offsetHeight); expectLT(0, devicePage.$$('#pointersRow').offsetHeight);
cr.webUIListenerCallback('has-pointing-stick-changed', false);
expectLT(0, devicePage.$$('#pointersRow').offsetHeight);
cr.webUIListenerCallback('has-touchpad-changed', false); cr.webUIListenerCallback('has-touchpad-changed', false);
expectEquals(0, devicePage.$$('#pointersRow').offsetHeight); expectEquals(0, devicePage.$$('#pointersRow').offsetHeight);
cr.webUIListenerCallback('has-mouse-changed', true); cr.webUIListenerCallback('has-mouse-changed', true);
...@@ -625,6 +628,15 @@ cr.define('device_page_tests', function() { ...@@ -625,6 +628,15 @@ cr.define('device_page_tests', function() {
assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight); assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight);
assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight); assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight);
cr.webUIListenerCallback('has-pointing-stick-changed', false);
assertEquals(
settings.routes.POINTERS,
settings.Router.getInstance().getCurrentRoute());
assertLT(0, pointersPage.$$('#mouse').offsetHeight);
assertEquals(0, pointersPage.$$('#touchpad').offsetHeight);
assertEquals(0, pointersPage.$$('#mouse h2').offsetHeight);
assertEquals(0, pointersPage.$$('#touchpad h2').offsetHeight);
cr.webUIListenerCallback('has-mouse-changed', false); cr.webUIListenerCallback('has-mouse-changed', false);
assertEquals( assertEquals(
settings.routes.DEVICE, settings.routes.DEVICE,
......
...@@ -52,8 +52,11 @@ void InputControllerEvdev::SetInputDevicesEnabled(bool enabled) { ...@@ -52,8 +52,11 @@ void InputControllerEvdev::SetInputDevicesEnabled(bool enabled) {
} }
bool InputControllerEvdev::HasMouse() { bool InputControllerEvdev::HasMouse() {
// TODO(crbug.com/1114828): add a separate HasPointingStick method. return has_mouse_;
return has_mouse_ || has_pointing_stick_; }
bool InputControllerEvdev::HasPointingStick() {
return has_pointing_stick_;
} }
bool InputControllerEvdev::HasTouchpad() { bool InputControllerEvdev::HasTouchpad() {
......
...@@ -40,6 +40,7 @@ class COMPONENT_EXPORT(EVDEV) InputControllerEvdev : public InputController { ...@@ -40,6 +40,7 @@ class COMPONENT_EXPORT(EVDEV) InputControllerEvdev : public InputController {
// InputController: // InputController:
bool HasMouse() override; bool HasMouse() override;
bool HasPointingStick() override;
bool HasTouchpad() override; bool HasTouchpad() override;
bool IsCapsLockEnabled() override; bool IsCapsLockEnabled() override;
void SetCapsLockEnabled(bool enabled) override; void SetCapsLockEnabled(bool enabled) override;
......
...@@ -21,6 +21,7 @@ class StubInputController : public InputController { ...@@ -21,6 +21,7 @@ class StubInputController : public InputController {
// InputController: // InputController:
bool HasMouse() override { return false; } bool HasMouse() override { return false; }
bool HasPointingStick() override { return false; }
bool HasTouchpad() override { return false; } bool HasTouchpad() override { return false; }
bool IsCapsLockEnabled() override { return false; } bool IsCapsLockEnabled() override { return false; }
void SetCapsLockEnabled(bool enabled) override {} void SetCapsLockEnabled(bool enabled) override {}
......
...@@ -43,6 +43,7 @@ class COMPONENT_EXPORT(OZONE_BASE) InputController { ...@@ -43,6 +43,7 @@ class COMPONENT_EXPORT(OZONE_BASE) InputController {
// Functions for checking devices existence. // Functions for checking devices existence.
virtual bool HasMouse() = 0; virtual bool HasMouse() = 0;
virtual bool HasPointingStick() = 0;
virtual bool HasTouchpad() = 0; virtual bool HasTouchpad() = 0;
// Keyboard settings. // Keyboard settings.
......
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