increase max fps to 60 by default, improve coalesce

* Trigger a paint immediately from invalidate if not throttled
* Otherwise defer the other events until we're about to sleep for xcb
  events, which should maximize the coalesce around resize/expose events

refs: #1051
This commit is contained in:
Wez Furlong committed 2021-09-02 08:53:03 -07:00
1 parent 367797c1ae
commit b53a6059de
3 files changed
+14 -5

No files matched your search

+7
View File
@@ -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<String> {
[
"bash",
+1 -1
View File
@@ -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(());
}
+6 -4
View File
@@ -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) {