autocommit 2022-04-01 01:44:10 CEST
This commit is contained in:
parent
ab4ac883ee
commit
2dd433aa04
32 changed files with 626 additions and 139 deletions
36
src/backends/dummy.rs
Normal file
36
src/backends/dummy.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
use crate::backend::{Backend, Output, OutputId};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct DummyBackend {}
|
||||
|
||||
impl Backend for DummyBackend {
|
||||
fn switch_to(&self, vtnr: u32) {
|
||||
let _ = vtnr;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DummyOutput {
|
||||
pub id: OutputId,
|
||||
}
|
||||
|
||||
impl Output for DummyOutput {
|
||||
fn id(&self) -> OutputId {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn removed(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn width(&self) -> i32 {
|
||||
100
|
||||
}
|
||||
|
||||
fn height(&self) -> i32 {
|
||||
100
|
||||
}
|
||||
|
||||
fn on_change(&self, _cb: Rc<dyn Fn()>) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
|
@ -196,6 +196,7 @@ struct MetalInputDevice {
|
|||
cb: CloneCell<Option<Rc<dyn Fn()>>>,
|
||||
hscroll: Cell<f64>,
|
||||
vscroll: Cell<f64>,
|
||||
name: CloneCell<Rc<String>>,
|
||||
|
||||
// config
|
||||
left_handed: Cell<Option<bool>>,
|
||||
|
|
@ -223,16 +224,13 @@ impl LibInputAdapter for DeviceHolder {
|
|||
Ok(s) => s,
|
||||
Err(e) => return Err(LibInputError::Stat(e.into())),
|
||||
};
|
||||
match self.devices.get(&stat.st_rdev) {
|
||||
Some(MetalDevice::Input(d)) => match d.fd.get() {
|
||||
Some(fd) => match uapi::fcntl_dupfd_cloexec(fd.raw(), 0) {
|
||||
Ok(fd) => Ok(fd),
|
||||
Err(e) => Err(LibInputError::DupFd(e.into())),
|
||||
},
|
||||
_ => Err(LibInputError::DeviceUnavailable),
|
||||
},
|
||||
_ => Err(LibInputError::DeviceUnavailable),
|
||||
if let Some(MetalDevice::Input(d)) = self.devices.get(&stat.st_rdev) {
|
||||
if let Some(fd) = d.fd.get() {
|
||||
return uapi::fcntl_dupfd_cloexec(fd.raw(), 0)
|
||||
.map_err(|e| LibInputError::DupFd(e.into()));
|
||||
}
|
||||
}
|
||||
Err(LibInputError::DeviceUnavailable)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,6 +317,10 @@ impl InputDevice for MetalInputDevice {
|
|||
fn set_transform_matrix(&self, matrix: [[f64; 2]; 2]) {
|
||||
self.transform_matrix.set(Some(matrix));
|
||||
}
|
||||
|
||||
fn name(&self) -> Rc<String> {
|
||||
self.name.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl MetalInputDevice {
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ impl MetalBackend {
|
|||
cb: Default::default(),
|
||||
hscroll: Cell::new(0.0),
|
||||
vscroll: Cell::new(0.0),
|
||||
name: Default::default(),
|
||||
left_handed: Default::default(),
|
||||
accel_profile: Default::default(),
|
||||
accel_speed: Default::default(),
|
||||
|
|
@ -323,6 +324,7 @@ impl MetalBackend {
|
|||
Err(_) => return,
|
||||
};
|
||||
inputdev.device().set_slot(slot);
|
||||
dev.name.set(Rc::new(inputdev.device().name()));
|
||||
dev.inputdev.set(Some(inputdev));
|
||||
dev.apply_config();
|
||||
slf.state
|
||||
|
|
|
|||
|
|
@ -532,6 +532,8 @@ impl XBackendData {
|
|||
kb_events: RefCell::new(Default::default()),
|
||||
mouse_events: RefCell::new(Default::default()),
|
||||
button_map: Default::default(),
|
||||
kb_name: Rc::new(format!("kb{}", info.deviceid)),
|
||||
mouse_name: Rc::new(format!("mouse{}", info.deviceid)),
|
||||
});
|
||||
seat.update_button_map().await;
|
||||
self.seats.set(info.deviceid, seat.clone());
|
||||
|
|
@ -888,6 +890,8 @@ struct XSeat {
|
|||
kb_events: RefCell<VecDeque<InputEvent>>,
|
||||
mouse_events: RefCell<VecDeque<InputEvent>>,
|
||||
button_map: CopyHashMap<u32, u32>,
|
||||
kb_name: Rc<String>,
|
||||
mouse_name: Rc<String>,
|
||||
}
|
||||
|
||||
struct XSeatKeyboard(Rc<XSeat>);
|
||||
|
|
@ -982,6 +986,10 @@ impl InputDevice for XSeatKeyboard {
|
|||
fn set_transform_matrix(&self, matrix: [[f64; 2]; 2]) {
|
||||
let _ = matrix;
|
||||
}
|
||||
|
||||
fn name(&self) -> Rc<String> {
|
||||
self.0.kb_name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl InputDevice for XSeatMouse {
|
||||
|
|
@ -1027,4 +1035,8 @@ impl InputDevice for XSeatMouse {
|
|||
fn set_transform_matrix(&self, matrix: [[f64; 2]; 2]) {
|
||||
let _ = matrix;
|
||||
}
|
||||
|
||||
fn name(&self) -> Rc<String> {
|
||||
self.0.mouse_name.clone()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue