1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-28 07:55:03 +03:00

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 2021-09-01 17:06:45 -07:00
parent 367797c1ae
commit b53a6059de
3 changed files with 14 additions and 5 deletions

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",

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(());
}

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) {