mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-19 03:00:55 +03:00
Avoid sending frame events (#29)
* Avoid sending frame events Frame events are now implicit - each network event implies a frame event TODO: Accumulate correctly * remove trace logs from producer
This commit is contained in:
committed by
GitHub
parent
06725f4b14
commit
851b6d60eb
@@ -165,64 +165,73 @@ enum VirtualInput {
|
||||
impl VirtualInput {
|
||||
fn consume_event(&self, event: Event) -> Result<(),()> {
|
||||
match event {
|
||||
Event::Pointer(e) => match e {
|
||||
PointerEvent::Motion {
|
||||
time,
|
||||
relative_x,
|
||||
relative_y,
|
||||
} => match self {
|
||||
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 {
|
||||
time,
|
||||
button,
|
||||
state,
|
||||
} => {
|
||||
let state: ButtonState = state.try_into()?;
|
||||
match self {
|
||||
Event::Pointer(e) => {
|
||||
match e {
|
||||
PointerEvent::Motion {
|
||||
time,
|
||||
relative_x,
|
||||
relative_y,
|
||||
} => match self {
|
||||
VirtualInput::Wlroots {
|
||||
pointer,
|
||||
keyboard: _,
|
||||
} => {
|
||||
pointer.button(time, button, state);
|
||||
pointer.motion(time, relative_x, relative_y);
|
||||
}
|
||||
VirtualInput::Kde { fake_input } => {
|
||||
fake_input.button(button, state as u32);
|
||||
fake_input.pointer_motion(relative_y, relative_y);
|
||||
}
|
||||
},
|
||||
PointerEvent::Button {
|
||||
time,
|
||||
button,
|
||||
state,
|
||||
} => {
|
||||
let state: ButtonState = state.try_into()?;
|
||||
match self {
|
||||
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 } => {
|
||||
let axis: Axis = (axis as u32).try_into()?;
|
||||
match self {
|
||||
PointerEvent::Axis { time, axis, value } => {
|
||||
let axis: Axis = (axis as u32).try_into()?;
|
||||
match self {
|
||||
VirtualInput::Wlroots {
|
||||
pointer,
|
||||
keyboard: _,
|
||||
} => {
|
||||
pointer.axis(time, axis, value);
|
||||
pointer.frame();
|
||||
}
|
||||
VirtualInput::Kde { fake_input } => {
|
||||
fake_input.axis(axis as u32, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
PointerEvent::Frame {} => match self {
|
||||
VirtualInput::Wlroots {
|
||||
pointer,
|
||||
keyboard: _,
|
||||
} => {
|
||||
pointer.axis(time, axis, value);
|
||||
pointer.frame();
|
||||
}
|
||||
VirtualInput::Kde { fake_input } => {
|
||||
fake_input.axis(axis as u32, value);
|
||||
}
|
||||
}
|
||||
VirtualInput::Kde { fake_input: _ } => {}
|
||||
},
|
||||
}
|
||||
PointerEvent::Frame {} => match self {
|
||||
VirtualInput::Wlroots {
|
||||
pointer,
|
||||
keyboard: _,
|
||||
} => {
|
||||
match self {
|
||||
VirtualInput::Wlroots { pointer, .. } => {
|
||||
// insert a frame event after each mouse event
|
||||
pointer.frame();
|
||||
}
|
||||
VirtualInput::Kde { fake_input: _ } => {}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
},
|
||||
Event::Keyboard(e) => match e {
|
||||
KeyboardEvent::Key { time, key, state } => match self {
|
||||
|
||||
@@ -598,7 +598,6 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
|
||||
surface_y: _,
|
||||
} => {
|
||||
// get client corresponding to the focused surface
|
||||
log::trace!("produce: enter()");
|
||||
{
|
||||
if let Some((window, client)) = app
|
||||
.client_for_window
|
||||
@@ -618,7 +617,6 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
|
||||
app.pending_events.push((*client, Event::Release()));
|
||||
}
|
||||
wl_pointer::Event::Leave { .. } => {
|
||||
log::trace!("produce: leave()");
|
||||
app.ungrab();
|
||||
}
|
||||
wl_pointer::Event::Button {
|
||||
@@ -627,7 +625,6 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
|
||||
button,
|
||||
state,
|
||||
} => {
|
||||
log::trace!("produce: button()");
|
||||
let (_, client) = app.focused.as_ref().unwrap();
|
||||
app.pending_events.push((
|
||||
*client,
|
||||
@@ -639,7 +636,6 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
|
||||
));
|
||||
}
|
||||
wl_pointer::Event::Axis { time, axis, value } => {
|
||||
log::trace!("produce: scroll()");
|
||||
let (_, client) = app.focused.as_ref().unwrap();
|
||||
app.pending_events.push((
|
||||
*client,
|
||||
@@ -651,12 +647,9 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
|
||||
));
|
||||
}
|
||||
wl_pointer::Event::Frame {} => {
|
||||
log::trace!("produce: frame()");
|
||||
let (_, client) = app.focused.as_ref().unwrap();
|
||||
app.pending_events.push((
|
||||
*client,
|
||||
Event::Pointer(PointerEvent::Frame {}),
|
||||
));
|
||||
// TODO properly handle frame events
|
||||
// we simply insert a frame event on the client side
|
||||
// after each event for now
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -749,7 +742,6 @@ impl Dispatch<ZwpRelativePointerV1, ()> for State {
|
||||
dy_unaccel: surface_y,
|
||||
} = event
|
||||
{
|
||||
log::trace!("produce: motion()");
|
||||
if let Some((_window, client)) = &app.focused {
|
||||
let time = (((utime_hi as u64) << 32 | utime_lo as u64) / 1000) as u32;
|
||||
app.pending_events.push((
|
||||
|
||||
Reference in New Issue
Block a user