1
0
Fork 0
forked from wry/wry

config: allow handling switch events

This commit is contained in:
Julian Orth 2024-04-28 13:35:52 +02:00
parent 55d55bf161
commit cf233abb5a
21 changed files with 443 additions and 27 deletions

View file

@ -1,6 +1,6 @@
use {
crate::{
backend::KeyState,
backend::{InputDeviceId, KeyState},
client::Client,
fixed::Fixed,
ifs::wl_seat::{wl_pointer::PendingScroll, SeatId},
@ -220,6 +220,22 @@ impl JaySeatEvents {
cancelled: cancelled as _,
});
}
pub fn send_switch_event(
&self,
seat: SeatId,
input_device: InputDeviceId,
time_usec: u64,
event: jay_config::input::SwitchEvent,
) {
self.client.event(SwitchEvent {
self_id: self.id,
seat: seat.raw(),
time_usec,
input_device: input_device.raw(),
event: event as _,
});
}
}
impl JaySeatEventsRequestHandler for JaySeatEvents {

View file

@ -1,6 +1,6 @@
use {
crate::{
backend::{ConnectorId, InputEvent, KeyState, AXIS_120},
backend::{ConnectorId, InputDeviceId, InputEvent, KeyState, AXIS_120},
client::ClientId,
config::InvokedShortcut,
fixed::Fixed,
@ -37,9 +37,12 @@ use {
xkbcommon::{KeyboardState, XkbState, XKB_KEY_DOWN, XKB_KEY_UP},
},
isnt::std_1::primitive::{IsntSlice2Ext, IsntSliceExt},
jay_config::keyboard::{
mods::{Modifiers, CAPS, NUM, RELEASE},
syms::{KeySym, SYM_Escape},
jay_config::{
input::SwitchEvent,
keyboard::{
mods::{Modifiers, CAPS, NUM, RELEASE},
syms::{KeySym, SYM_Escape},
},
},
smallvec::SmallVec,
std::{cell::RefCell, collections::hash_map::Entry, rc::Rc},
@ -200,7 +203,8 @@ impl WlSeatGlobal {
| InputEvent::PinchUpdate { time_usec, .. }
| InputEvent::PinchEnd { time_usec, .. }
| InputEvent::HoldBegin { time_usec, .. }
| InputEvent::HoldEnd { time_usec, .. } => {
| InputEvent::HoldEnd { time_usec, .. }
| InputEvent::SwitchEvent { time_usec, .. } => {
self.last_input_usec.set(time_usec);
if self.idle_notifications.is_not_empty() {
for (_, notification) in self.idle_notifications.lock().drain() {
@ -299,6 +303,9 @@ impl WlSeatGlobal {
time_usec,
cancelled,
} => self.hold_end(time_usec, cancelled),
InputEvent::SwitchEvent { time_usec, event } => {
self.switch_event(dev.device.id(), time_usec, event)
}
}
}
@ -504,6 +511,15 @@ impl WlSeatGlobal {
self.gesture_owner.hold_end(self, time_usec, cancelled)
}
fn switch_event(self: &Rc<Self>, dev: InputDeviceId, time_usec: u64, event: SwitchEvent) {
self.state.for_each_seat_tester(|t| {
t.send_switch_event(self.id, dev, time_usec, event);
});
if let Some(config) = self.state.config.get() {
config.switch_event(self.id, dev, event);
}
}
pub(super) fn key_event<F>(
self: &Rc<Self>,
time_usec: u64,