Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Unified Diff: ui/events/ozone/evdev/event_converter_evdev_impl.cc

Issue 806693009: Port ScopedDisableInternalMouseAndKeyboardX11 to Ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/events/ozone/evdev/event_converter_evdev_impl.cc
diff --git a/ui/events/ozone/evdev/event_converter_evdev_impl.cc b/ui/events/ozone/evdev/event_converter_evdev_impl.cc
index 011a6c2dda5c5c783ccb092cf774b758ba98592b..866a4c285d88ae44134025ca351ce4dea18c15f9 100644
--- a/ui/events/ozone/evdev/event_converter_evdev_impl.cc
+++ b/ui/events/ozone/evdev/event_converter_evdev_impl.cc
@@ -10,7 +10,7 @@
#include "base/message_loop/message_loop.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/dom4/keycode_converter.h"
-#include "ui/events/keycodes/keyboard_codes.h"
+#include "ui/events/ozone/evdev/keyboard_evdev.h"
namespace ui {
@@ -31,6 +31,7 @@ EventConverterEvdevImpl::EventConverterEvdevImpl(
const EventDispatchCallback& callback)
: EventConverterEvdev(fd, path, id, type),
has_keyboard_(devinfo.HasKeyboard()),
+ has_touchpad_(devinfo.HasTouchpad()),
x_offset_(0),
y_offset_(0),
cursor_(cursor),
@@ -57,6 +58,11 @@ void EventConverterEvdevImpl::OnFileCanReadWithoutBlocking(int fd) {
return;
}
+ // TODO(spang): Re-implement this by releasing buttons & temporarily closing
+ // the device.
+ if (ignore_events_)
+ return;
+
DCHECK_EQ(read_size % sizeof(*inputs), 0u);
ProcessEvents(inputs, read_size / sizeof(*inputs));
}
@@ -65,6 +71,21 @@ bool EventConverterEvdevImpl::HasKeyboard() const {
return has_keyboard_;
}
+bool EventConverterEvdevImpl::HasTouchpad() const {
+ return has_touchpad_;
+}
+
+void EventConverterEvdevImpl::SetAllowedKeys(
+ scoped_ptr<std::set<DomCode>> allowed_keys) {
+ DCHECK(HasKeyboard());
+ allowed_keys_ = allowed_keys.Pass();
+}
+
+void EventConverterEvdevImpl::AllowAllKeys() {
+ DCHECK(HasKeyboard());
+ allowed_keys_.reset();
+}
+
void EventConverterEvdevImpl::ProcessEvents(const input_event* inputs,
int count) {
for (int i = 0; i < count; ++i) {
@@ -95,7 +116,10 @@ void EventConverterEvdevImpl::ConvertKeyEvent(const input_event& input) {
}
// Keyboard processing.
- keyboard_->OnKeyChange(input.code, input.value != kKeyReleaseValue);
+ DomCode key_code = KeycodeConverter::NativeKeycodeToDomCode(
+ KeyboardEvdev::EvdevCodeToNativeCode(input.code));
+ if (!allowed_keys_ || allowed_keys_->count(key_code))
+ keyboard_->OnKeyChange(input.code, input.value != kKeyReleaseValue);
}
void EventConverterEvdevImpl::ConvertMouseMoveEvent(const input_event& input) {

Powered by Google App Engine
This is Rietveld 408576698