Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
user827 committed Oct 17, 2021
1 parent ec7befb commit 514016b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,7 @@ impl<'a> XContext<'a> {
}
// We handled an event/reply
if state.is_some() {
// Once again the xcb might queue something
self.xcb_events_queued = true;
self.xcb_our_cookies_queued = true;
// TODO do not draw if the window is not exposed at all
self.config.backbuffer.commit(dialog)?;
self.conn().flush()?;
self.flush(dialog)?;
}
Ok(state)
}
Expand All @@ -268,10 +263,19 @@ impl<'a> XContext<'a> {
!self.xfd_eagain || self.xcb_our_cookies_queued || self.xcb_events_queued
}

fn flush(&mut self, dialog: &mut Dialog) -> Result<()> {
// Xcb might queue something on flush and other commands
self.xcb_events_queued = true;
self.xcb_our_cookies_queued = true;
// TODO do not draw if the window is not exposed at all
self.config.backbuffer.commit(dialog)?;
self.conn().flush()?;
Ok(())
}

pub async fn run_events(&mut self, mut dialog: Dialog) -> Result<Option<Passphrase>> {
dialog.init_events();
self.config.backbuffer.commit(&mut dialog)?;
self.conn().flush()?;
self.flush(&mut dialog)?;
// Need to see if flush something else caused xcb to queue any events, to handle them
// before waiting for fd to become readable again.
let mut state = State::Continue;
Expand All @@ -286,10 +290,7 @@ impl<'a> XContext<'a> {
while matches!(state, State::Continue) {
tokio::select! {
action = dialog.handle_events() => {
self.xcb_our_cookies_queued = true;
self.xcb_events_queued = true;
self.config.backbuffer.commit(&mut dialog)?;
self.conn().flush()?;
self.flush(&mut dialog)?;
if matches!(action, Action::Cancel) {
state = State::Cancelled;
}
Expand Down

0 comments on commit 514016b

Please sign in to comment.