diff --git a/CHANGES.md b/CHANGES.md index f0902da0..480372a7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ - linux: wayland: Fix the serial number of input_method events - linux: wayland: Correct whitespace and nullbyte at the end of the keymap - linux: wayland: Send messages in the correct order and make sure Wayland objects are created before they are used +- linux: wayland: Flush the Wayland queue when moving the mouse and simulating a scroll instead of waiting for a roundtrip # 0.3.0 ## Changed diff --git a/src/linux/wayland.rs b/src/linux/wayland.rs index 51dfa389..4b56854d 100644 --- a/src/linux/wayland.rs +++ b/src/linux/wayland.rs @@ -305,16 +305,14 @@ impl Con { if direction == Direction::Press || direction == Direction::Click { trace!("vk.key({time}, {keycode}, 1)"); vk.key(time, keycode, 1); - self.event_queue - .flush() - .map_err(|_| InputError::Simulate("Flushing Wayland queue failed"))?; + + self.flush()?; } if direction == Direction::Release || direction == Direction::Click { trace!("vk.key({time}, {keycode}, 0)"); vk.key(time, keycode, 0); - self.event_queue - .flush() - .map_err(|_| InputError::Simulate("Flushing Wayland queue failed"))?; + + self.flush()?; } Ok(()) } @@ -337,9 +335,7 @@ impl Con { // Send the modifier event vk.modifiers(modifiers, 0, 0, 0); - self.event_queue - .flush() - .map_err(|_| InputError::Simulate("Flushing Wayland queue failed"))?; + self.flush()?; Ok(()) } @@ -686,9 +682,7 @@ impl Keyboard for Con { im.commit_string(text.to_string()); im.commit(self.state.im_serial.0); - self.event_queue - .flush() - .map_err(|_| InputError::Simulate("Flushing Wayland queue failed"))?; + self.flush()?; Ok(Some(())) } @@ -766,9 +760,8 @@ impl Mouse for Con { vp.button(time, button, wl_pointer::ButtonState::Released); vp.frame(); // TODO: Check if this is needed } - self.event_queue - .flush() - .map_err(|_| InputError::Simulate("Flushing Wayland queue failed")) + + self.flush() } fn move_mouse(&mut self, x: i32, y: i32, coordinate: Coordinate) -> InputResult<()> { @@ -803,11 +796,7 @@ impl Mouse for Con { } vp.frame(); // TODO: Check if this is needed - // TODO: Change to flush() - self.event_queue - .roundtrip(&mut self.state) - .map_err(|_| InputError::Simulate("The roundtrip on Wayland failed")) - .map(|_| ()) + self.flush() } fn scroll(&mut self, length: i32, axis: Axis) -> InputResult<()> { @@ -827,11 +816,7 @@ impl Mouse for Con { vp.axis(time, axis, length.into()); vp.frame(); // TODO: Check if this is needed - // TODO: Change to flush() - self.event_queue - .roundtrip(&mut self.state) - .map_err(|_| InputError::Simulate("The roundtrip on Wayland failed")) - .map(|_| ()) + self.flush() } fn main_display(&self) -> InputResult<(i32, i32)> {