summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspang <spang@chromium.org>2015-06-09 10:07:08 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-09 17:07:44 +0000
commitac2ffadacece2698f02b414f55fa7372c720e828 (patch)
tree327e2b2474776d519ac25979ba32e5d5cdaac914
parent936c5dd07832efe4b2ef9753a9d7e99a4350d4ff (diff)
downloadchromium_src-ac2ffadacece2698f02b414f55fa7372c720e828.zip
chromium_src-ac2ffadacece2698f02b414f55fa7372c720e828.tar.gz
chromium_src-ac2ffadacece2698f02b414f55fa7372c720e828.tar.bz2
ozone: evdev: Invert enable_repeat as suppress_auto_repeat
This incorporates comments from wez@ on top of r333349. See https://codereview.chromium.org/1166113003/#msg16. The primary change is to invert the sense of the repeat option for key events so that "true" causes suppression of repeat and "false" is the usual behavior that triggers repeats. Also add some docs and make some minor tweaks to naming. BUG=496420 TEST=visit rbyers.github.io/eventTest.html via it2me from chromebook to chromebook key repeat works normally Review URL: https://codereview.chromium.org/1164403003 Cr-Commit-Position: refs/heads/master@{#333511}
-rw-r--r--remoting/host/input_injector_chromeos.cc4
-rw-r--r--ui/events/ozone/evdev/device_event_dispatcher_evdev.cc4
-rw-r--r--ui/events/ozone/evdev/device_event_dispatcher_evdev.h4
-rw-r--r--ui/events/ozone/evdev/event_converter_evdev_impl.cc5
-rw-r--r--ui/events/ozone/evdev/event_factory_evdev.cc2
-rw-r--r--ui/events/ozone/evdev/input_injector_evdev.cc10
-rw-r--r--ui/events/ozone/evdev/input_injector_evdev.h4
-rw-r--r--ui/events/ozone/evdev/keyboard_evdev.cc18
-rw-r--r--ui/events/ozone/evdev/keyboard_evdev.h11
-rw-r--r--ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc2
-rw-r--r--ui/ozone/public/system_input_injector.h10
11 files changed, 41 insertions, 33 deletions
diff --git a/remoting/host/input_injector_chromeos.cc b/remoting/host/input_injector_chromeos.cc
index 58afde0..8fa2ea2 100644
--- a/remoting/host/input_injector_chromeos.cc
+++ b/remoting/host/input_injector_chromeos.cc
@@ -84,8 +84,8 @@ void InputInjectorChromeos::Core::InjectKeyEvent(const KeyEvent& event) {
// Ignore events which can't be mapped.
if (dom_code != ui::DomCode::NONE) {
- delegate_->InjectKeyPress(dom_code, event.pressed(),
- false /* enable_repeat */);
+ delegate_->InjectKeyEvent(dom_code, event.pressed(),
+ true /* suppress_auto_repeat */);
}
}
diff --git a/ui/events/ozone/evdev/device_event_dispatcher_evdev.cc b/ui/events/ozone/evdev/device_event_dispatcher_evdev.cc
index 8fe624d..47725bd 100644
--- a/ui/events/ozone/evdev/device_event_dispatcher_evdev.cc
+++ b/ui/events/ozone/evdev/device_event_dispatcher_evdev.cc
@@ -9,12 +9,12 @@ namespace ui {
KeyEventParams::KeyEventParams(int device_id,
unsigned int code,
bool down,
- bool enable_repeat,
+ bool suppress_auto_repeat,
base::TimeDelta timestamp)
: device_id(device_id),
code(code),
down(down),
- enable_repeat(enable_repeat),
+ suppress_auto_repeat(suppress_auto_repeat),
timestamp(timestamp) {
}
diff --git a/ui/events/ozone/evdev/device_event_dispatcher_evdev.h b/ui/events/ozone/evdev/device_event_dispatcher_evdev.h
index c49cff0..0ff64be 100644
--- a/ui/events/ozone/evdev/device_event_dispatcher_evdev.h
+++ b/ui/events/ozone/evdev/device_event_dispatcher_evdev.h
@@ -23,7 +23,7 @@ struct EVENTS_OZONE_EVDEV_EXPORT KeyEventParams {
KeyEventParams(int device_id,
unsigned int code,
bool down,
- bool enable_repeat,
+ bool suppress_auto_repeat,
base::TimeDelta timestamp);
KeyEventParams(const KeyEventParams& other);
~KeyEventParams();
@@ -31,7 +31,7 @@ struct EVENTS_OZONE_EVDEV_EXPORT KeyEventParams {
int device_id;
unsigned int code;
bool down;
- bool enable_repeat;
+ bool suppress_auto_repeat;
base::TimeDelta timestamp;
};
diff --git a/ui/events/ozone/evdev/event_converter_evdev_impl.cc b/ui/events/ozone/evdev/event_converter_evdev_impl.cc
index 23c6f14..1718c7c 100644
--- a/ui/events/ozone/evdev/event_converter_evdev_impl.cc
+++ b/ui/events/ozone/evdev/event_converter_evdev_impl.cc
@@ -188,8 +188,9 @@ void EventConverterEvdevImpl::OnKeyChange(unsigned int key,
// State transition: !(down) -> (down)
key_state_.set(key, down);
- dispatcher_->DispatchKeyEvent(KeyEventParams(
- input_device_.id, key, down, true /* enable_repeat */, timestamp));
+ dispatcher_->DispatchKeyEvent(KeyEventParams(input_device_.id, key, down,
+ false /* suppress_auto_repeat */,
+ timestamp));
}
void EventConverterEvdevImpl::ReleaseKeys() {
diff --git a/ui/events/ozone/evdev/event_factory_evdev.cc b/ui/events/ozone/evdev/event_factory_evdev.cc
index fff6aaa..ad141e6 100644
--- a/ui/events/ozone/evdev/event_factory_evdev.cc
+++ b/ui/events/ozone/evdev/event_factory_evdev.cc
@@ -152,7 +152,7 @@ scoped_ptr<SystemInputInjector> EventFactoryEvdev::CreateSystemInputInjector() {
void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) {
TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchKeyEvent", "device",
params.device_id);
- keyboard_.OnKeyChange(params.code, params.down, params.enable_repeat,
+ keyboard_.OnKeyChange(params.code, params.down, params.suppress_auto_repeat,
params.timestamp, params.device_id);
}
diff --git a/ui/events/ozone/evdev/input_injector_evdev.cc b/ui/events/ozone/evdev/input_injector_evdev.cc
index 86bc35b..7c37fe9 100644
--- a/ui/events/ozone/evdev/input_injector_evdev.cc
+++ b/ui/events/ozone/evdev/input_injector_evdev.cc
@@ -66,18 +66,18 @@ void InputInjectorEvdev::MoveCursorTo(const gfx::PointF& location) {
kDeviceIdForInjection, cursor_->GetLocation(), EventTimeForNow()));
}
-void InputInjectorEvdev::InjectKeyPress(DomCode physical_key,
+void InputInjectorEvdev::InjectKeyEvent(DomCode physical_key,
bool down,
- bool enable_repeat) {
+ bool suppress_auto_repeat) {
if (physical_key == DomCode::NONE)
return;
int native_keycode = KeycodeConverter::DomCodeToNativeKeycode(physical_key);
int evdev_code = NativeCodeToEvdevCode(native_keycode);
- dispatcher_->DispatchKeyEvent(KeyEventParams(kDeviceIdForInjection,
- evdev_code, down, enable_repeat,
- EventTimeForNow()));
+ dispatcher_->DispatchKeyEvent(
+ KeyEventParams(kDeviceIdForInjection, evdev_code, down,
+ suppress_auto_repeat, EventTimeForNow()));
}
} // namespace ui
diff --git a/ui/events/ozone/evdev/input_injector_evdev.h b/ui/events/ozone/evdev/input_injector_evdev.h
index 59b5e36..cdb60fa 100644
--- a/ui/events/ozone/evdev/input_injector_evdev.h
+++ b/ui/events/ozone/evdev/input_injector_evdev.h
@@ -27,9 +27,9 @@ class EVENTS_OZONE_EVDEV_EXPORT InputInjectorEvdev
void InjectMouseButton(EventFlags button, bool down) override;
void InjectMouseWheel(int delta_x, int delta_y) override;
void MoveCursorTo(const gfx::PointF& location) override;
- void InjectKeyPress(DomCode physical_key,
+ void InjectKeyEvent(DomCode physical_key,
bool down,
- bool enable_repeat) override;
+ bool suppress_auto_repeat) override;
private:
// Shared cursor state.
diff --git a/ui/events/ozone/evdev/keyboard_evdev.cc b/ui/events/ozone/evdev/keyboard_evdev.cc
index 36f2bf6..53a48e4 100644
--- a/ui/events/ozone/evdev/keyboard_evdev.cc
+++ b/ui/events/ozone/evdev/keyboard_evdev.cc
@@ -60,7 +60,7 @@ KeyboardEvdev::KeyboardEvdev(EventModifiersEvdev* modifiers,
: callback_(callback),
modifiers_(modifiers),
keyboard_layout_engine_(keyboard_layout_engine),
- repeat_enabled_(true),
+ auto_repeat_enabled_(true),
repeat_key_(KEY_RESERVED),
repeat_sequence_(0),
repeat_device_id_(0),
@@ -74,20 +74,20 @@ KeyboardEvdev::~KeyboardEvdev() {
void KeyboardEvdev::OnKeyChange(unsigned int key,
bool down,
- bool enable_repeat,
+ bool suppress_auto_repeat,
base::TimeDelta timestamp,
int device_id) {
if (key > KEY_MAX)
return;
bool was_down = key_state_.test(key);
- bool repeat = down && was_down;
+ bool is_repeat = down && was_down;
if (!down && !was_down)
return; // Key already released.
key_state_.set(key, down);
- UpdateKeyRepeat(key, down, enable_repeat, device_id);
- DispatchKey(key, down, repeat, timestamp, device_id);
+ UpdateKeyRepeat(key, down, suppress_auto_repeat, device_id);
+ DispatchKey(key, down, is_repeat, timestamp, device_id);
}
void KeyboardEvdev::SetCapsLockEnabled(bool enabled) {
@@ -99,11 +99,11 @@ bool KeyboardEvdev::IsCapsLockEnabled() {
}
bool KeyboardEvdev::IsAutoRepeatEnabled() {
- return repeat_enabled_;
+ return auto_repeat_enabled_;
}
void KeyboardEvdev::SetAutoRepeatEnabled(bool enabled) {
- repeat_enabled_ = enabled;
+ auto_repeat_enabled_ = enabled;
}
void KeyboardEvdev::SetAutoRepeatRate(const base::TimeDelta& delay,
@@ -141,9 +141,9 @@ void KeyboardEvdev::UpdateModifier(int modifier_flag, bool down) {
void KeyboardEvdev::UpdateKeyRepeat(unsigned int key,
bool down,
- bool enable_repeat,
+ bool suppress_auto_repeat,
int device_id) {
- if (!repeat_enabled_ || !enable_repeat)
+ if (!auto_repeat_enabled_ || suppress_auto_repeat)
StopKeyRepeat();
else if (key != repeat_key_ && down)
StartKeyRepeat(key, device_id);
diff --git a/ui/events/ozone/evdev/keyboard_evdev.h b/ui/events/ozone/evdev/keyboard_evdev.h
index 7071831..34e5162 100644
--- a/ui/events/ozone/evdev/keyboard_evdev.h
+++ b/ui/events/ozone/evdev/keyboard_evdev.h
@@ -34,9 +34,14 @@ class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev {
~KeyboardEvdev();
// Handlers for raw key presses & releases.
+ //
+ // |code| is a Linux key code (from <linux/input.h>). |down| represents the
+ // key state. |suppress_auto_repeat| prevents the event from triggering
+ // auto-repeat, if enabled. |device_id| uniquely identifies the source
+ // keyboard device.
void OnKeyChange(unsigned int code,
bool down,
- bool enable_repeat,
+ bool suppress_auto_repeat,
base::TimeDelta timestamp,
int device_id);
@@ -56,7 +61,7 @@ class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev {
void UpdateCapsLockLed();
void UpdateKeyRepeat(unsigned int key,
bool down,
- bool enable_repeat,
+ bool suppress_auto_repeat,
int device_id);
void StartKeyRepeat(unsigned int key, int device_id);
void StopKeyRepeat();
@@ -88,7 +93,7 @@ class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev {
KeyboardLayoutEngine* keyboard_layout_engine_;
// Key repeat state.
- bool repeat_enabled_;
+ bool auto_repeat_enabled_;
unsigned int repeat_key_;
unsigned int repeat_sequence_;
int repeat_device_id_;
diff --git a/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc b/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc
index db41c1c..dad9f01 100644
--- a/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc
+++ b/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc
@@ -452,7 +452,7 @@ void GestureInterpreterLibevdevCros::DispatchChangedKeys(
// Dispatch key press or release to keyboard.
dispatcher_->DispatchKeyEvent(
- KeyEventParams(id_, key, value, true /* enable_repeat */,
+ KeyEventParams(id_, key, value, false /* suppress_auto_repeat */,
StimeToTimedelta(timestamp)));
}
}
diff --git a/ui/ozone/public/system_input_injector.h b/ui/ozone/public/system_input_injector.h
index 3c379c0..a13051f 100644
--- a/ui/ozone/public/system_input_injector.h
+++ b/ui/ozone/public/system_input_injector.h
@@ -39,11 +39,13 @@ class OZONE_EXPORT SystemInputInjector {
// factor.
virtual void InjectMouseWheel(int delta_x, int delta_y) = 0;
- // Simulates a key press. SystemInputInjector maps |physical_key| to the
- // correct logical key based on the current keyboard layout.
- virtual void InjectKeyPress(DomCode physical_key,
+ // Simulates a key event. SystemInputInjector maps |physical_key| to the
+ // correct logical key based on the current keyboard layout. |down| is true
+ // for presses. If |suppress_auto_repeat| is set, the platform must not
+ // auto-repeat the event.
+ virtual void InjectKeyEvent(DomCode physical_key,
bool down,
- bool enable_repeat) = 0;
+ bool suppress_auto_repeat) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(SystemInputInjector);