Skip to content

Commit

Permalink
libei: bump ashpd from 0.9.1 to 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
pentamassiv committed Nov 5, 2024
1 parent 018ec0d commit 88ed6b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- macOS: Switched keycodes of `Key::Launchpad` and `Key::MissionControl`
- macOS: `CapsLock` works ([#163](https://github.com/enigo-rs/enigo/issues/163))
- macOS: Moving the mouse works also if it is the only function ([#182](https://github.com/enigo-rs/enigo/issues/182))
- linux: libei: Typing is much faster now

# 0.2.1
## Changed
Expand Down
15 changes: 12 additions & 3 deletions src/linux/libei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,17 @@ impl Con {

#[allow(clippy::too_many_lines)]
fn update(&mut self, libei_name: &str) -> InputResult<()> {
// TODO: Don't blindly do it 50 times but check if it is needed
for _ in 0..50 {
let mut had_pending_events = true;

loop {
debug!("update");
if self.context.read().is_err() {
error!("err reading");
return Err(InputError::Simulate("Failed to update libei context"));
}

while let Some(result) = self.context.pending_event() {
had_pending_events = true;
trace!("found pending_event");

let request = match result {
Expand Down Expand Up @@ -449,7 +451,7 @@ impl Con {

trace!("devices: {:?}", self.devices);

if let Ok(()) = self.context.flush() {
if self.context.flush().is_ok() {
trace!("flush success");
} else {
error!("flush fail");
Expand All @@ -459,6 +461,13 @@ impl Con {
std::thread::sleep(std::time::Duration::from_millis(10));
trace!("update flush");
trace!("update done");

// We can stop looking for updates if there was no event to be handled
// previously
if !had_pending_events {
break;
}
had_pending_events = false;
}
Ok(())
}
Expand Down

0 comments on commit 88ed6b0

Please sign in to comment.