From 2b0bc61ea718f468b570676225df96a40be3164a Mon Sep 17 00:00:00 2001 From: Zach Reizner Date: Fri, 22 Nov 2019 17:26:46 -0800 Subject: [PATCH] gpu_display: amend GpuDisplay to import and attach EventDevices This change also includes stubs for the wayland and x11 impls. TEST=compiles BUG=chromium:1023975 Change-Id: Ia2bcb5c2ed75ea47071dd77e149e60901a56595c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930407 Reviewed-by: Daniel Verkamp Reviewed-by: Stephen Barber Reviewed-by: Noah Gold Tested-by: Daniel Verkamp Tested-by: kokoro Commit-Queue: Daniel Verkamp --- gpu_display/src/gpu_display_wl.rs | 12 +++++++++++- gpu_display/src/gpu_display_x.rs | 11 ++++++++++- gpu_display/src/lib.rs | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/gpu_display/src/gpu_display_wl.rs b/gpu_display/src/gpu_display_wl.rs index 3e1fe9297c..04ddb54385 100644 --- a/gpu_display/src/gpu_display_wl.rs +++ b/gpu_display/src/gpu_display_wl.rs @@ -12,7 +12,7 @@ mod dwl; use dwl::*; -use crate::{DisplayT, GpuDisplayError, GpuDisplayFramebuffer}; +use crate::{DisplayT, EventDevice, GpuDisplayError, GpuDisplayFramebuffer}; use std::cell::Cell; use std::collections::HashMap; @@ -341,6 +341,16 @@ impl DisplayT for DisplayWl { None => debug_assert!(false, "invalid surface_id {}", surface_id), } } + + fn import_event_device(&mut self, _event_device: EventDevice) -> Result { + Err(GpuDisplayError::Unsupported) + } + fn release_event_device(&mut self, _event_device_id: u32) { + // unsupported + } + fn attach_event_device(&mut self, surface_id: u32, event_device_id: u32) { + // unsupported + } } impl AsRawFd for DisplayWl { diff --git a/gpu_display/src/gpu_display_x.rs b/gpu_display/src/gpu_display_x.rs index 837a15184c..1df7fc204e 100644 --- a/gpu_display/src/gpu_display_x.rs +++ b/gpu_display/src/gpu_display_x.rs @@ -22,7 +22,7 @@ use std::rc::Rc; use libc::{shmat, shmctl, shmdt, shmget, IPC_CREAT, IPC_PRIVATE, IPC_RMID}; -use crate::{DisplayT, GpuDisplayError, GpuDisplayFramebuffer}; +use crate::{DisplayT, EventDevice, GpuDisplayError, GpuDisplayFramebuffer}; use data_model::VolatileSlice; @@ -638,6 +638,15 @@ impl DisplayT for DisplayX { fn set_position(&mut self, surface_id: u32, x: u32, y: u32) { // unsupported } + fn import_event_device(&mut self, _event_device: EventDevice) -> Result { + Err(GpuDisplayError::Unsupported) + } + fn release_event_device(&mut self, _event_device_id: u32) { + // unsupported + } + fn attach_event_device(&mut self, surface_id: u32, event_device_id: u32) { + // unsupported + } } impl AsRawFd for DisplayX { diff --git a/gpu_display/src/lib.rs b/gpu_display/src/lib.rs index 5c243d6eb8..8cc018a5fa 100644 --- a/gpu_display/src/lib.rs +++ b/gpu_display/src/lib.rs @@ -155,6 +155,9 @@ trait DisplayT: AsRawFd { fn flip_to(&mut self, surface_id: u32, import_id: u32); fn close_requested(&self, surface_id: u32) -> bool; fn set_position(&mut self, surface_id: u32, x: u32, y: u32); + fn import_event_device(&mut self, event_device: EventDevice) -> Result; + fn release_event_device(&mut self, event_device_id: u32); + fn attach_event_device(&mut self, surface_id: u32, event_device_id: u32); } /// A connection to the compositor and associated collection of state. @@ -291,6 +294,21 @@ impl GpuDisplay { pub fn set_position(&mut self, surface_id: u32, x: u32, y: u32) { self.inner.set_position(surface_id, x, y) } + + pub fn import_event_device( + &mut self, + event_device: EventDevice, + ) -> Result { + self.inner.import_event_device(event_device) + } + + pub fn release_event_device(&mut self, event_device_id: u32) { + self.inner.release_event_device(event_device_id) + } + + pub fn attach_event_device(&mut self, surface_id: u32, event_device_id: u32) { + self.inner.attach_event_device(surface_id, event_device_id); + } } impl AsRawFd for GpuDisplay {