summary refs log tree commit diff
path: root/gpu_display/src/gpu_display_x.rs
diff options
context:
space:
mode:
authorNoah Gold <nkgold@google.com>2020-02-01 13:01:58 -0800
committerCommit Bot <commit-bot@chromium.org>2020-03-06 01:00:39 +0000
commitdc7f52bdb76a8f3b3cf6260bc0d861758956991e (patch)
treeabde34b5dc09609981c695f5de5772fe2661358a /gpu_display/src/gpu_display_x.rs
parentd2a862b41f07d387926f0b984c56dc838003102c (diff)
downloadcrosvm-dc7f52bdb76a8f3b3cf6260bc0d861758956991e.tar
crosvm-dc7f52bdb76a8f3b3cf6260bc0d861758956991e.tar.gz
crosvm-dc7f52bdb76a8f3b3cf6260bc0d861758956991e.tar.bz2
crosvm-dc7f52bdb76a8f3b3cf6260bc0d861758956991e.tar.lz
crosvm-dc7f52bdb76a8f3b3cf6260bc0d861758956991e.tar.xz
crosvm-dc7f52bdb76a8f3b3cf6260bc0d861758956991e.tar.zst
crosvm-dc7f52bdb76a8f3b3cf6260bc0d861758956991e.zip
Use simple virtio_input_events where possible.
Previously, all input events in CrosVM were required to be linux
input_events, which have a timestamp field that is actually unused by
when we send/receive from the guest which are of type
virtio_input_event. This CL allows CrosVM to understand both types of input
events in a first class manner. It is a follow up on
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930405.

This CL also addresses some bugs with window driven input:
1. attach_event_device was being called before the surface was
created, so the devices were never attached.
2. The default touchpad size was not being set to the display window
size.

Additionally, it removes the unused event "filter" feature on event
sources.

Breaking change: from this point forward, CrosVM will treat input events sent
via a socket (e.g. SocketEventSource) to be virtio_input_events.

BUG=None
TEST=builds + manual

Change-Id: I7fec07c582e5a071a6f116975ba70d6e621bb483
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2034046
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Diffstat (limited to 'gpu_display/src/gpu_display_x.rs')
-rw-r--r--gpu_display/src/gpu_display_x.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/gpu_display/src/gpu_display_x.rs b/gpu_display/src/gpu_display_x.rs
index c0074ca..2940f40 100644
--- a/gpu_display/src/gpu_display_x.rs
+++ b/gpu_display/src/gpu_display_x.rs
@@ -11,7 +11,7 @@
 )]
 mod xlib;
 
-use linux_input_sys::input_event;
+use linux_input_sys::virtio_input_event;
 use std::cmp::max;
 use std::collections::BTreeMap;
 use std::ffi::{c_void, CStr, CString};
@@ -333,7 +333,11 @@ impl Surface {
         }
     }
 
-    fn dispatch_to_event_devices(&mut self, events: &[input_event], device_type: EventDeviceKind) {
+    fn dispatch_to_event_devices(
+        &mut self,
+        events: &[virtio_input_event],
+        device_type: EventDeviceKind,
+    ) {
         for event_device in self.event_devices.values_mut() {
             if event_device.kind() != device_type {
                 continue;
@@ -348,7 +352,7 @@ impl Surface {
         match ev.as_enum(self.buffer_completion_type) {
             XEventEnum::KeyEvent(key) => {
                 if let Some(linux_keycode) = self.keycode_translator.translate(key.keycode) {
-                    let events = &[input_event::key(
+                    let events = &[virtio_input_event::key(
                         linux_keycode,
                         key.type_ == xlib::KeyPress as i32,
                     )];
@@ -363,9 +367,9 @@ impl Surface {
                 if button_event.button & xlib::Button1 != 0 {
                     // The touch event *must* be first per the Linux input subsystem's guidance.
                     let events = &[
-                        input_event::touch(pressed),
-                        input_event::absolute_x(max(0, button_event.x) as u32),
-                        input_event::absolute_y(max(0, button_event.y) as u32),
+                        virtio_input_event::touch(pressed),
+                        virtio_input_event::absolute_x(max(0, button_event.x) as u32),
+                        virtio_input_event::absolute_y(max(0, button_event.y) as u32),
                     ];
                     self.dispatch_to_event_devices(events, EventDeviceKind::Touchscreen);
                 }
@@ -373,9 +377,9 @@ impl Surface {
             XEventEnum::Motion(motion) => {
                 if motion.state & xlib::Button1Mask != 0 {
                     let events = &[
-                        input_event::touch(true),
-                        input_event::absolute_x(max(0, motion.x) as u32),
-                        input_event::absolute_y(max(0, motion.y) as u32),
+                        virtio_input_event::touch(true),
+                        virtio_input_event::absolute_x(max(0, motion.x) as u32),
+                        virtio_input_event::absolute_y(max(0, motion.y) as u32),
                     ];
                     self.dispatch_to_event_devices(events, EventDeviceKind::Touchscreen);
                 }