autocommit 2022-03-30 18:10:37 CEST
This commit is contained in:
parent
c4854c4d7d
commit
a8136ed88c
17 changed files with 189 additions and 81 deletions
|
|
@ -3,7 +3,7 @@ mod monitor;
|
|||
mod video;
|
||||
|
||||
use crate::async_engine::{AsyncError, AsyncFd};
|
||||
use crate::backend::{Backend, InputDevice, InputDeviceId, InputEvent};
|
||||
use crate::backend::{Backend, InputDevice, InputDeviceCapability, InputDeviceId, InputEvent};
|
||||
use crate::backends::metal::video::{MetalDrmDevice, PendingDrmDevice};
|
||||
use crate::dbus::DbusError;
|
||||
use crate::drm::drm::DrmError;
|
||||
|
|
@ -25,6 +25,7 @@ use std::future::pending;
|
|||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, OwnedFd};
|
||||
use crate::libinput::consts::{LIBINPUT_DEVICE_CAP_GESTURE, LIBINPUT_DEVICE_CAP_KEYBOARD, LIBINPUT_DEVICE_CAP_POINTER, LIBINPUT_DEVICE_CAP_SWITCH, LIBINPUT_DEVICE_CAP_TABLET_PAD, LIBINPUT_DEVICE_CAP_TABLET_TOOL, LIBINPUT_DEVICE_CAP_TOUCH};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum MetalError {
|
||||
|
|
@ -180,7 +181,7 @@ struct MetalInputDevice {
|
|||
id: InputDeviceId,
|
||||
_devnum: c::dev_t,
|
||||
fd: CloneCell<Option<Rc<OwnedFd>>>,
|
||||
inputdev: Cell<Option<RegisteredDevice>>,
|
||||
inputdev: CloneCell<Option<Rc<RegisteredDevice>>>,
|
||||
devnode: CString,
|
||||
_sysname: CString,
|
||||
removed: Cell<bool>,
|
||||
|
|
@ -242,6 +243,22 @@ impl InputDevice for MetalInputDevice {
|
|||
fn grab(&self, _grab: bool) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn has_capability(&self, cap: InputDeviceCapability) -> bool {
|
||||
let li = match cap {
|
||||
InputDeviceCapability::Keyboard => LIBINPUT_DEVICE_CAP_KEYBOARD,
|
||||
InputDeviceCapability::Pointer => LIBINPUT_DEVICE_CAP_POINTER,
|
||||
InputDeviceCapability::Touch => LIBINPUT_DEVICE_CAP_TOUCH,
|
||||
InputDeviceCapability::TabletTool => LIBINPUT_DEVICE_CAP_TABLET_TOOL,
|
||||
InputDeviceCapability::TabletPad => LIBINPUT_DEVICE_CAP_TABLET_PAD,
|
||||
InputDeviceCapability::Gesture => LIBINPUT_DEVICE_CAP_GESTURE,
|
||||
InputDeviceCapability::Switch => LIBINPUT_DEVICE_CAP_SWITCH,
|
||||
};
|
||||
match self.inputdev.get() {
|
||||
Some(dev) => dev.device().has_cap(li),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MetalInputDevice {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ impl MetalBackend {
|
|||
self.state.fdcloser.close(old);
|
||||
}
|
||||
let inputdev = match self.libinput.open(dev.devnode.as_c_str()) {
|
||||
Ok(d) => d,
|
||||
Ok(d) => Rc::new(d),
|
||||
Err(_) => return,
|
||||
};
|
||||
inputdev.device().set_slot(dev.slot);
|
||||
|
|
@ -314,7 +314,7 @@ impl MetalBackend {
|
|||
}
|
||||
dev.fd.set(Some(res.fd.clone()));
|
||||
let inputdev = match slf.libinput.open(dev.devnode.as_c_str()) {
|
||||
Ok(d) => d,
|
||||
Ok(d) => Rc::new(d),
|
||||
Err(_) => return,
|
||||
};
|
||||
inputdev.device().set_slot(slot);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
use crate::async_engine::{Phase, SpawnedFuture};
|
||||
use crate::backend::{
|
||||
Backend, BackendEvent, InputDevice, InputDeviceId, InputEvent, KeyState, Output, OutputId,
|
||||
ScrollAxis,
|
||||
};
|
||||
use crate::backend::{Backend, BackendEvent, InputDevice, InputDeviceCapability, InputDeviceId, InputEvent, KeyState, Output, OutputId, ScrollAxis};
|
||||
use crate::drm::drm::{Drm, DrmError};
|
||||
use crate::drm::gbm::{GbmDevice, GbmError, GBM_BO_USE_RENDERING};
|
||||
use crate::drm::{ModifiedFormat, INVALID_MODIFIER};
|
||||
|
|
@ -638,9 +635,12 @@ impl XBackendData {
|
|||
return;
|
||||
}
|
||||
|
||||
let image = &output.images[output.next_image.fetch_add(1) % output.images.len()];
|
||||
let serial = output.serial.fetch_add(1);
|
||||
|
||||
let image = &output.images[output.next_image.fetch_add(1) % output.images.len()];
|
||||
image.idle.set(false);
|
||||
image.last_serial.set(serial);
|
||||
|
||||
if let Some(node) = self.state.root.outputs.get(&output.id) {
|
||||
let fb = image.fb.get();
|
||||
fb.render(&*node, &self.state, Some(node.position.get()));
|
||||
|
|
@ -667,8 +667,6 @@ impl XBackendData {
|
|||
log::error!("Could not present image: {:?}", e);
|
||||
return;
|
||||
}
|
||||
image.idle.set(false);
|
||||
image.last_serial.set(serial);
|
||||
}
|
||||
|
||||
async fn handle_input_event(self: &Rc<Self>, event: &Event) -> Result<(), XBackendError> {
|
||||
|
|
@ -958,6 +956,13 @@ impl InputDevice for XSeatKeyboard {
|
|||
fn grab(&self, grab: bool) {
|
||||
self.0.backend.grab_requests.push((self.0.clone(), grab));
|
||||
}
|
||||
|
||||
fn has_capability(&self, cap: InputDeviceCapability) -> bool {
|
||||
match cap {
|
||||
InputDeviceCapability::Keyboard => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl InputDevice for XSeatMouse {
|
||||
|
|
@ -980,4 +985,11 @@ impl InputDevice for XSeatMouse {
|
|||
fn grab(&self, _grab: bool) {
|
||||
log::error!("Cannot grab xorg mouse");
|
||||
}
|
||||
|
||||
fn has_capability(&self, cap: InputDeviceCapability) -> bool {
|
||||
match cap {
|
||||
InputDeviceCapability::Pointer => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue