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,7 +165,8 @@ 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) => {
match e {
PointerEvent::Motion { PointerEvent::Motion {
time, time,
relative_x, relative_x,
@@ -223,6 +224,14 @@ impl VirtualInput {
} }
VirtualInput::Kde { fake_input: _ } => {} VirtualInput::Kde { fake_input: _ } => {}
}, },
}
match self {
VirtualInput::Wlroots { pointer, .. } => {
// insert a frame event after each mouse event
pointer.frame();
}
_ => {},
}
}, },
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((