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:
Ferdinand Schober
2023-09-28 13:01:38 +02:00
committed by GitHub
parent 06725f4b14
commit 851b6d60eb
2 changed files with 53 additions and 52 deletions

View File

@@ -165,64 +165,73 @@ enum VirtualInput {
impl VirtualInput { impl VirtualInput {
fn consume_event(&self, event: Event) -> Result<(),()> { fn consume_event(&self, event: Event) -> Result<(),()> {
match event { match event {
Event::Pointer(e) => match e { Event::Pointer(e) => {
PointerEvent::Motion { match e {
time, PointerEvent::Motion {
relative_x, time,
relative_y, relative_x,
} => match self { relative_y,
VirtualInput::Wlroots { } => match self {
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 {
VirtualInput::Wlroots { VirtualInput::Wlroots {
pointer, pointer,
keyboard: _, keyboard: _,
} => { } => {
pointer.button(time, button, state); pointer.motion(time, relative_x, relative_y);
} }
VirtualInput::Kde { fake_input } => { 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 } => {
PointerEvent::Axis { time, axis, value } => { let axis: Axis = (axis as u32).try_into()?;
let axis: Axis = (axis as u32).try_into()?; match self {
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 { VirtualInput::Wlroots {
pointer, pointer,
keyboard: _, keyboard: _,
} => { } => {
pointer.axis(time, axis, value);
pointer.frame(); pointer.frame();
} }
VirtualInput::Kde { fake_input } => { VirtualInput::Kde { fake_input: _ } => {}
fake_input.axis(axis as u32, value); },
}
}
} }
PointerEvent::Frame {} => match self { match self {
VirtualInput::Wlroots { VirtualInput::Wlroots { pointer, .. } => {
pointer, // insert a frame event after each mouse event
keyboard: _,
} => {
pointer.frame(); pointer.frame();
} }
VirtualInput::Kde { fake_input: _ } => {} _ => {},
}, }
}, },
Event::Keyboard(e) => match e { Event::Keyboard(e) => match e {
KeyboardEvent::Key { time, key, state } => match self { KeyboardEvent::Key { time, key, state } => match self {

View File

@@ -598,7 +598,6 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
surface_y: _, surface_y: _,
} => { } => {
// get client corresponding to the focused surface // get client corresponding to the focused surface
log::trace!("produce: enter()");
{ {
if let Some((window, client)) = app if let Some((window, client)) = app
.client_for_window .client_for_window
@@ -618,7 +617,6 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
app.pending_events.push((*client, Event::Release())); app.pending_events.push((*client, Event::Release()));
} }
wl_pointer::Event::Leave { .. } => { wl_pointer::Event::Leave { .. } => {
log::trace!("produce: leave()");
app.ungrab(); app.ungrab();
} }
wl_pointer::Event::Button { wl_pointer::Event::Button {
@@ -627,7 +625,6 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
button, button,
state, state,
} => { } => {
log::trace!("produce: button()");
let (_, client) = app.focused.as_ref().unwrap(); let (_, client) = app.focused.as_ref().unwrap();
app.pending_events.push(( app.pending_events.push((
*client, *client,
@@ -639,7 +636,6 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
)); ));
} }
wl_pointer::Event::Axis { time, axis, value } => { wl_pointer::Event::Axis { time, axis, value } => {
log::trace!("produce: scroll()");
let (_, client) = app.focused.as_ref().unwrap(); let (_, client) = app.focused.as_ref().unwrap();
app.pending_events.push(( app.pending_events.push((
*client, *client,
@@ -651,12 +647,9 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
)); ));
} }
wl_pointer::Event::Frame {} => { wl_pointer::Event::Frame {} => {
log::trace!("produce: frame()"); // TODO properly handle frame events
let (_, client) = app.focused.as_ref().unwrap(); // we simply insert a frame event on the client side
app.pending_events.push(( // after each event for now
*client,
Event::Pointer(PointerEvent::Frame {}),
));
} }
_ => {} _ => {}
} }
@@ -749,7 +742,6 @@ impl Dispatch<ZwpRelativePointerV1, ()> for State {
dy_unaccel: surface_y, dy_unaccel: surface_y,
} = event } = event
{ {
log::trace!("produce: motion()");
if let Some((_window, client)) = &app.focused { if let Some((_window, client)) = &app.focused {
let time = (((utime_hi as u64) << 32 | utime_lo as u64) / 1000) as u32; let time = (((utime_hi as u64) << 32 | utime_lo as u64) / 1000) as u32;
app.pending_events.push(( app.pending_events.push((