From 851b6d60ebcdeddec777f03c80a1e26773691b1f Mon Sep 17 00:00:00 2001 From: Ferdinand Schober Date: Thu, 28 Sep 2023 13:01:38 +0200 Subject: [PATCH] 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 --- src/backend/consumer/wlroots.rs | 91 ++++++++++++++++++--------------- src/backend/producer/wayland.rs | 14 ++--- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/backend/consumer/wlroots.rs b/src/backend/consumer/wlroots.rs index b7ea650..3066f03 100644 --- a/src/backend/consumer/wlroots.rs +++ b/src/backend/consumer/wlroots.rs @@ -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 { diff --git a/src/backend/producer/wayland.rs b/src/backend/producer/wayland.rs index fcae3a3..03f025d 100644 --- a/src/backend/producer/wayland.rs +++ b/src/backend/producer/wayland.rs @@ -598,7 +598,6 @@ impl Dispatch 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 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 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 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 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 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((