diff --git a/config/src/lib.rs b/config/src/lib.rs index 7fc9dad6f..b7dc6157b 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -1219,9 +1219,16 @@ pub struct Config { #[serde(default)] pub pane_focus_follows_mouse: bool, + + #[serde(default = "default_max_fps")] + pub max_fps: u8, } impl_lua_conversion!(Config); +fn default_max_fps() -> u8 { + 60 +} + fn default_stateless_process_list() -> Vec { [ "bash", diff --git a/window/src/os/x11/connection.rs b/window/src/os/x11/connection.rs index a4eaac62b..2bab0d69e 100644 --- a/window/src/os/x11/connection.rs +++ b/window/src/os/x11/connection.rs @@ -220,6 +220,7 @@ impl ConnectionOps for XConnection { continue; } + self.dispatch_pending_events()?; if let Err(err) = poll.poll(&mut events, None) { bail!("polling for events: {:?}", err); } @@ -287,7 +288,6 @@ impl XConnection { loop { match self.conn.poll_for_queued_event() { None => { - self.dispatch_pending_events()?; self.conn.flush(); return Ok(()); } diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rs index fcbfc352b..6f7186902 100644 --- a/window/src/os/x11/window.rs +++ b/window/src/os/x11/window.rs @@ -180,13 +180,13 @@ impl XWindowInner { match event { WindowEvent::NeedRepaint => { if need_paint { - log::info!("coalesce a repaint"); + log::trace!("coalesce a repaint"); } need_paint = true; } e @ WindowEvent::Resized { .. } => { if resize.is_some() { - log::info!("coalesce a resize"); + log::trace!("coalesce a resize"); } resize.replace(e); } @@ -209,9 +209,10 @@ impl XWindowInner { self.paint_throttled = true; let window_id = self.window_id; + let max_fps = self.config.max_fps; promise::spawn::spawn(async move { - // Don't try to paint more frequently than 30 fps - async_io::Timer::after(std::time::Duration::from_millis(1000 / 30)).await; + async_io::Timer::after(std::time::Duration::from_millis(1000 / max_fps as u64)) + .await; XConnection::with_window_inner(window_id, |inner| { inner.paint_throttled = false; if inner.invalidated { @@ -901,6 +902,7 @@ impl XWindowInner { fn invalidate(&mut self) { self.queue_pending(WindowEvent::NeedRepaint); + self.dispatch_pending_events().ok(); } fn toggle_fullscreen(&mut self) {