mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-13 10:51:27 +03:00
remove kde-fake-input backend
This commit is contained in:
committed by
Ferdinand Schober
parent
06c4e92d43
commit
a6ab109fae
14
Cargo.lock
generated
14
Cargo.lock
generated
@@ -1162,7 +1162,6 @@ dependencies = [
|
|||||||
"wayland-client",
|
"wayland-client",
|
||||||
"wayland-protocols",
|
"wayland-protocols",
|
||||||
"wayland-protocols-misc",
|
"wayland-protocols-misc",
|
||||||
"wayland-protocols-plasma",
|
|
||||||
"wayland-protocols-wlr",
|
"wayland-protocols-wlr",
|
||||||
"winapi",
|
"winapi",
|
||||||
"x11",
|
"x11",
|
||||||
@@ -2197,19 +2196,6 @@ dependencies = [
|
|||||||
"wayland-scanner",
|
"wayland-scanner",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wayland-protocols-plasma"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1890b691b97cc8485c0c2b05791af10ee4cdec9773bb60f1c1aa958b9db00ae4"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
"wayland-backend",
|
|
||||||
"wayland-client",
|
|
||||||
"wayland-protocols",
|
|
||||||
"wayland-scanner",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-protocols-wlr"
|
name = "wayland-protocols-wlr"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ wayland-client = { version="0.30.2", optional = true }
|
|||||||
wayland-protocols = { version="0.30.0", features=["client", "staging", "unstable"], optional = true }
|
wayland-protocols = { version="0.30.0", features=["client", "staging", "unstable"], optional = true }
|
||||||
wayland-protocols-wlr = { version="0.1.0", features=["client"], optional = true }
|
wayland-protocols-wlr = { version="0.1.0", features=["client"], optional = true }
|
||||||
wayland-protocols-misc = { version="0.1.0", features=["client"], optional = true }
|
wayland-protocols-misc = { version="0.1.0", features=["client"], optional = true }
|
||||||
wayland-protocols-plasma = { version="0.1.0", features=["client"], optional = true }
|
|
||||||
x11 = { version = "2.21.0", features = ["xlib", "xtest"], optional = true }
|
x11 = { version = "2.21.0", features = ["xlib", "xtest"], optional = true }
|
||||||
ashpd = { version = "0.6.2", default-features = false, features = ["tokio"], optional = true }
|
ashpd = { version = "0.6.2", default-features = false, features = ["tokio"], optional = true }
|
||||||
reis = { git = "https://github.com/ids1024/reis", features = [ "tokio" ], optional = true }
|
reis = { git = "https://github.com/ids1024/reis", features = [ "tokio" ], optional = true }
|
||||||
@@ -54,7 +53,7 @@ glib-build-tools = "0.18.0"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["wayland", "x11", "xdg_desktop_portal", "libei", "gtk"]
|
default = ["wayland", "x11", "xdg_desktop_portal", "libei", "gtk"]
|
||||||
wayland = ["dep:wayland-client", "dep:wayland-protocols", "dep:wayland-protocols-wlr", "dep:wayland-protocols-misc", "dep:wayland-protocols-plasma"]
|
wayland = ["dep:wayland-client", "dep:wayland-protocols", "dep:wayland-protocols-wlr", "dep:wayland-protocols-misc" ]
|
||||||
x11 = ["dep:x11"]
|
x11 = ["dep:x11"]
|
||||||
xdg_desktop_portal = ["dep:ashpd"]
|
xdg_desktop_portal = ["dep:ashpd"]
|
||||||
libei = ["dep:reis", "dep:ashpd", "dep:libc" ]
|
libei = ["dep:reis", "dep:ashpd", "dep:libc" ]
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use wayland_client::backend::WaylandError;
|
|||||||
use wayland_client::WEnum;
|
use wayland_client::WEnum;
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use wayland_client::globals::BindError;
|
|
||||||
use wayland_client::protocol::wl_keyboard::{self, WlKeyboard};
|
use wayland_client::protocol::wl_keyboard::{self, WlKeyboard};
|
||||||
use wayland_client::protocol::wl_pointer::{Axis, ButtonState};
|
use wayland_client::protocol::wl_pointer::{Axis, ButtonState};
|
||||||
use wayland_client::protocol::wl_seat::WlSeat;
|
use wayland_client::protocol::wl_seat::WlSeat;
|
||||||
@@ -23,8 +22,6 @@ use wayland_protocols_misc::zwp_virtual_keyboard_v1::client::{
|
|||||||
zwp_virtual_keyboard_v1::ZwpVirtualKeyboardV1 as Vk,
|
zwp_virtual_keyboard_v1::ZwpVirtualKeyboardV1 as Vk,
|
||||||
};
|
};
|
||||||
|
|
||||||
use wayland_protocols_plasma::fake_input::client::org_kde_kwin_fake_input::OrgKdeKwinFakeInput;
|
|
||||||
|
|
||||||
use wayland_client::{
|
use wayland_client::{
|
||||||
delegate_noop,
|
delegate_noop,
|
||||||
globals::{registry_queue_init, GlobalListContents},
|
globals::{registry_queue_init, GlobalListContents},
|
||||||
@@ -34,17 +31,13 @@ use wayland_client::{
|
|||||||
|
|
||||||
use crate::event::{Event, KeyboardEvent, PointerEvent};
|
use crate::event::{Event, KeyboardEvent, PointerEvent};
|
||||||
|
|
||||||
enum VirtualInputManager {
|
|
||||||
Wlroots { vpm: VpManager, vkm: VkManager },
|
|
||||||
Kde { fake_input: OrgKdeKwinFakeInput },
|
|
||||||
}
|
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
keymap: Option<(u32, OwnedFd, u32)>,
|
keymap: Option<(u32, OwnedFd, u32)>,
|
||||||
input_for_client: HashMap<ClientHandle, VirtualInput>,
|
input_for_client: HashMap<ClientHandle, VirtualInput>,
|
||||||
seat: wl_seat::WlSeat,
|
seat: wl_seat::WlSeat,
|
||||||
virtual_input_manager: VirtualInputManager,
|
|
||||||
qh: QueueHandle<Self>,
|
qh: QueueHandle<Self>,
|
||||||
|
vpm: VpManager,
|
||||||
|
vkm: VkManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
// App State, implements Dispatch event handlers
|
// App State, implements Dispatch event handlers
|
||||||
@@ -65,30 +58,8 @@ impl WlrootsConsumer {
|
|||||||
Err(_) => return Err(anyhow!("wl_seat >= v7 not supported")),
|
Err(_) => return Err(anyhow!("wl_seat >= v7 not supported")),
|
||||||
};
|
};
|
||||||
|
|
||||||
let vpm: Result<VpManager, BindError> = globals.bind(&qh, 1..=1, ());
|
let vpm: VpManager = globals.bind(&qh, 1..=1, ())?;
|
||||||
let vkm: Result<VkManager, BindError> = globals.bind(&qh, 1..=1, ());
|
let vkm: VkManager = globals.bind(&qh, 1..=1, ())?;
|
||||||
let fake_input: Result<OrgKdeKwinFakeInput, BindError> = globals.bind(&qh, 4..=4, ());
|
|
||||||
|
|
||||||
let virtual_input_manager = match (vpm, vkm, fake_input) {
|
|
||||||
(Ok(vpm), Ok(vkm), _) => VirtualInputManager::Wlroots { vpm, vkm },
|
|
||||||
(_, _, Ok(fake_input)) => {
|
|
||||||
fake_input.authenticate(
|
|
||||||
"lan-mouse".into(),
|
|
||||||
"Allow remote clients to control this device".into(),
|
|
||||||
);
|
|
||||||
VirtualInputManager::Kde { fake_input }
|
|
||||||
}
|
|
||||||
(Err(e1), Err(e2), Err(e3)) => {
|
|
||||||
log::warn!("zwlr_virtual_pointer_v1: {e1}");
|
|
||||||
log::warn!("zwp_virtual_keyboard_v1: {e2}");
|
|
||||||
log::warn!("org_kde_kwin_fake_input: {e3}");
|
|
||||||
log::error!("neither wlroots nor kde input emulation protocol supported!");
|
|
||||||
return Err(anyhow!("could not create event consumer"));
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
panic!()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let input_for_client: HashMap<ClientHandle, VirtualInput> = HashMap::new();
|
let input_for_client: HashMap<ClientHandle, VirtualInput> = HashMap::new();
|
||||||
|
|
||||||
@@ -98,7 +69,8 @@ impl WlrootsConsumer {
|
|||||||
keymap: None,
|
keymap: None,
|
||||||
input_for_client,
|
input_for_client,
|
||||||
seat,
|
seat,
|
||||||
virtual_input_manager,
|
vpm,
|
||||||
|
vkm,
|
||||||
qh,
|
qh,
|
||||||
},
|
},
|
||||||
queue,
|
queue,
|
||||||
@@ -118,29 +90,19 @@ impl WlrootsConsumer {
|
|||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
fn add_client(&mut self, client: ClientHandle) {
|
fn add_client(&mut self, client: ClientHandle) {
|
||||||
// create virtual input devices
|
let pointer: Vp = self.vpm.create_virtual_pointer(None, &self.qh, ());
|
||||||
match &self.virtual_input_manager {
|
let keyboard: Vk = self.vkm.create_virtual_keyboard(&self.seat, &self.qh, ());
|
||||||
VirtualInputManager::Wlroots { vpm, vkm } => {
|
|
||||||
let pointer: Vp = vpm.create_virtual_pointer(None, &self.qh, ());
|
|
||||||
let keyboard: Vk = vkm.create_virtual_keyboard(&self.seat, &self.qh, ());
|
|
||||||
|
|
||||||
// TODO: use server side keymap
|
// TODO: use server side keymap
|
||||||
if let Some((format, fd, size)) = self.keymap.as_ref() {
|
if let Some((format, fd, size)) = self.keymap.as_ref() {
|
||||||
keyboard.keymap(*format, fd.as_raw_fd(), *size);
|
keyboard.keymap(*format, fd.as_raw_fd(), *size);
|
||||||
} else {
|
} else {
|
||||||
panic!("no keymap");
|
panic!("no keymap");
|
||||||
}
|
|
||||||
|
|
||||||
let vinput = VirtualInput::Wlroots { pointer, keyboard };
|
|
||||||
|
|
||||||
self.input_for_client.insert(client, vinput);
|
|
||||||
}
|
|
||||||
VirtualInputManager::Kde { fake_input } => {
|
|
||||||
let fake_input = fake_input.clone();
|
|
||||||
let vinput = VirtualInput::Kde { fake_input };
|
|
||||||
self.input_for_client.insert(client, vinput);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let vinput = VirtualInput{ pointer, keyboard };
|
||||||
|
|
||||||
|
self.input_for_client.insert(client, vinput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,9 +156,9 @@ impl EventConsumer for WlrootsConsumer {
|
|||||||
async fn destroy(&mut self) {}
|
async fn destroy(&mut self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum VirtualInput {
|
struct VirtualInput {
|
||||||
Wlroots { pointer: Vp, keyboard: Vk },
|
pointer: Vp,
|
||||||
Kde { fake_input: OrgKdeKwinFakeInput },
|
keyboard: Vk,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VirtualInput {
|
impl VirtualInput {
|
||||||
@@ -208,93 +170,35 @@ impl VirtualInput {
|
|||||||
time,
|
time,
|
||||||
relative_x,
|
relative_x,
|
||||||
relative_y,
|
relative_y,
|
||||||
} => match self {
|
} => self.pointer.motion(time, relative_x, relative_y),
|
||||||
VirtualInput::Wlroots {
|
|
||||||
pointer,
|
|
||||||
keyboard: _,
|
|
||||||
} => {
|
|
||||||
pointer.motion(time, relative_x, relative_y);
|
|
||||||
}
|
|
||||||
VirtualInput::Kde { fake_input } => {
|
|
||||||
fake_input.pointer_motion(relative_y, relative_y);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
PointerEvent::Button {
|
PointerEvent::Button {
|
||||||
time,
|
time,
|
||||||
button,
|
button,
|
||||||
state,
|
state,
|
||||||
} => {
|
} => {
|
||||||
let state: ButtonState = state.try_into()?;
|
let state: ButtonState = state.try_into()?;
|
||||||
match self {
|
self.pointer.button(time, button, state);
|
||||||
VirtualInput::Wlroots {
|
|
||||||
pointer,
|
|
||||||
keyboard: _,
|
|
||||||
} => {
|
|
||||||
pointer.button(time, button, state);
|
|
||||||
}
|
|
||||||
VirtualInput::Kde { fake_input } => {
|
|
||||||
fake_input.button(button, state as u32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PointerEvent::Axis { time, axis, value } => {
|
PointerEvent::Axis { time, axis, value } => {
|
||||||
let axis: Axis = (axis as u32).try_into()?;
|
let axis: Axis = (axis as u32).try_into()?;
|
||||||
match self {
|
self.pointer.axis(time, axis, value);
|
||||||
VirtualInput::Wlroots {
|
self.pointer.frame();
|
||||||
pointer,
|
|
||||||
keyboard: _,
|
|
||||||
} => {
|
|
||||||
pointer.axis(time, axis, value);
|
|
||||||
pointer.frame();
|
|
||||||
}
|
|
||||||
VirtualInput::Kde { fake_input } => {
|
|
||||||
fake_input.axis(axis as u32, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PointerEvent::Frame {} => match self {
|
PointerEvent::Frame {} => self.pointer.frame(),
|
||||||
VirtualInput::Wlroots {
|
|
||||||
pointer,
|
|
||||||
keyboard: _,
|
|
||||||
} => {
|
|
||||||
pointer.frame();
|
|
||||||
}
|
|
||||||
VirtualInput::Kde { fake_input: _ } => {}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
match self {
|
|
||||||
VirtualInput::Wlroots { pointer, .. } => {
|
|
||||||
// insert a frame event after each mouse event
|
|
||||||
pointer.frame();
|
|
||||||
}
|
|
||||||
VirtualInput::Kde { .. } => {}
|
|
||||||
}
|
}
|
||||||
|
self.pointer.frame();
|
||||||
}
|
}
|
||||||
Event::Keyboard(e) => match e {
|
Event::Keyboard(e) => match e {
|
||||||
KeyboardEvent::Key { time, key, state } => match self {
|
KeyboardEvent::Key { time, key, state } => {
|
||||||
VirtualInput::Wlroots {
|
self.keyboard.key(time, key, state as u32);
|
||||||
pointer: _,
|
|
||||||
keyboard,
|
|
||||||
} => {
|
|
||||||
keyboard.key(time, key, state as u32);
|
|
||||||
}
|
|
||||||
VirtualInput::Kde { fake_input } => {
|
|
||||||
fake_input.keyboard_key(key, state as u32);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
KeyboardEvent::Modifiers {
|
KeyboardEvent::Modifiers {
|
||||||
mods_depressed,
|
mods_depressed,
|
||||||
mods_latched,
|
mods_latched,
|
||||||
mods_locked,
|
mods_locked,
|
||||||
group,
|
group,
|
||||||
} => match self {
|
} => {
|
||||||
VirtualInput::Wlroots {
|
self.keyboard.modifiers(mods_depressed, mods_latched, mods_locked, group);
|
||||||
pointer: _,
|
|
||||||
keyboard,
|
|
||||||
} => {
|
|
||||||
keyboard.modifiers(mods_depressed, mods_latched, mods_locked, group);
|
|
||||||
}
|
|
||||||
VirtualInput::Kde { fake_input: _ } => {}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -307,7 +211,6 @@ delegate_noop!(State: Vp);
|
|||||||
delegate_noop!(State: Vk);
|
delegate_noop!(State: Vk);
|
||||||
delegate_noop!(State: VpManager);
|
delegate_noop!(State: VpManager);
|
||||||
delegate_noop!(State: VkManager);
|
delegate_noop!(State: VkManager);
|
||||||
delegate_noop!(State: OrgKdeKwinFakeInput);
|
|
||||||
|
|
||||||
impl Dispatch<wl_registry::WlRegistry, GlobalListContents> for State {
|
impl Dispatch<wl_registry::WlRegistry, GlobalListContents> for State {
|
||||||
fn event(
|
fn event(
|
||||||
|
|||||||
Reference in New Issue
Block a user