Skip to content

Commit

Permalink
simplify Wayland::poll
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxVerevkin committed Mar 18, 2024
1 parent c6626c9 commit e3718e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() -> anyhow::Result<()> {
state.dbus_server.poll(&mut state.wayland_state)?;
}
if fds[1].revents != 0 || state.wayland_state.color_changed() {
state = wayland.poll(state)?;
wayland.poll(&mut state)?;
}
}
} else {
Expand All @@ -72,7 +72,7 @@ fn main() -> anyhow::Result<()> {
state.dbus_server.poll(&mut state.wayland_state)?;
}
if fds[1].revents != 0 || state.wayland_state.color_changed() {
state = wayland.poll(state)?;
wayland.poll(&mut state)?;
}
if fds[2].revents != 0 {
dbus_client.run(false)?;
Expand Down
6 changes: 3 additions & 3 deletions src/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ impl Wayland {
Ok((Self { conn }, state))
}

pub fn poll(&mut self, mut state: State) -> Result<State> {
pub fn poll(&mut self, state: &mut State) -> Result<()> {
match self.conn.recv_events(IoMode::NonBlocking) {
Ok(()) => self.conn.dispatch_events(&mut state),
Ok(()) => self.conn.dispatch_events(state),
Err(e) if e.kind() == ErrorKind::WouldBlock => (),
Err(e) => return Err(e.into()),
}
Expand All @@ -61,7 +61,7 @@ impl Wayland {
}
}
self.conn.flush(IoMode::Blocking)?;
Ok(state)
Ok(())
}
}

Expand Down

0 comments on commit e3718e9

Please sign in to comment.