send frame after every pointer event to 'commit' it

This commit is contained in:
Ferdinand Schober
2022-09-19 18:04:43 +02:00
parent 35414059a8
commit 2cd522044a
3 changed files with 12 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
[client.left]
host_name = "iridium"
ip = "192.168.178.141"
host_name = "rubinium"
ip = "192.168.2.182"
port = 42069
[client.right]

View File

@@ -114,10 +114,10 @@ fn udp_loop(connection: &protocol::Connection, pointer: &Vp, keyboard: &Vk, q: E
loop {
if let Some(event) = connection.receive_event() {
match event {
protocol::Event::Mouse { t, x, y } => { pointer.motion(t, x, y); }
protocol::Event::Button { t, b, s } => { pointer.button(t, b, s); }
protocol::Event::Axis { t, a, v } => { pointer.axis(t, a, v); }
protocol::Event::Key { t, k, s } => { keyboard.key(t, k, u32::from(s)); },
protocol::Event::Mouse { t, x, y } => { pointer.motion(t, x, y); pointer.frame(); }
protocol::Event::Button { t, b, s } => { pointer.button(t, b, s); pointer.frame(); }
protocol::Event::Axis { t, a, v } => { pointer.axis(t, a, v); pointer.frame(); }
protocol::Event::Key { t, k, s } => { keyboard.key(t, k, u32::from(s)); pointer.frame(); },
protocol::Event::KeyModifier { mods_depressed, mods_latched, mods_locked, group } => {
keyboard.modifiers(mods_depressed, mods_latched, mods_locked, group);
},

View File

@@ -105,24 +105,6 @@ fn draw(f: &mut File, (width, height): (u32, u32)) {
}
}
impl App {
fn send_motion_event(&self, time: u32, x: f64, y: f64) {
let e = protocol::Event::Mouse { t: (time), x: (x), y: (y) };
self.connection.send_event(&e);
}
fn send_button_event(&self, t: u32, b: u32, s: ButtonState) {
let e = protocol::Event::Button { t, b, s };
self.connection.send_event(&e);
}
fn send_axis_event(&self, t: u32, a: Axis, v: f64) {
let e = protocol::Event::Axis { t, a, v };
self.connection.send_event(&e);
}
}
impl Dispatch<wl_registry::WlRegistry, ()> for App {
fn event(
app: &mut Self,
@@ -375,10 +357,12 @@ impl Dispatch<wl_pointer::WlPointer, ()> for App {
}
}
wl_pointer::Event::Button { serial:_, time, button, state } => {
app.send_button_event(time, button, state.into_result().unwrap());
let e = protocol::Event::Button { t: (time), b: button, s: (state.into_result().unwrap()) };
app.connection.send_event(&e);
}
wl_pointer::Event::Axis { time, axis, value } => {
app.send_axis_event(time, axis.into_result().unwrap(), value);
let e = protocol::Event::Axis { t: time, a: (axis.into_result().unwrap()), v: value };
app.connection.send_event(&e);
}
_ => (),
}
@@ -482,7 +466,8 @@ impl Dispatch<zwp_relative_pointer_v1::ZwpRelativePointerV1, ()> for App {
dy_unaccel,
} = event {
let time = ((utime_hi as u64) << 32 | utime_lo as u64) / 1000;
app.send_motion_event(time as u32, dx_unaccel, dy_unaccel);
let e = protocol::Event::Mouse { t: (time as u32), x: (dx_unaccel), y: (dy_unaccel) };
app.connection.send_event(&e);
}
}
}