Skip to content

Commit

Permalink
x11: allow configuration of repaint delay
Browse files Browse the repository at this point in the history
Adds a configuration option, `focus_change_repaint_delay` to allow customisation of the delay added in 9b6329b.

The default delay remains 100ms, and can be disabled by setting it to `0`, if the workaround is not required on the user's system.

refs: wez#2063
refs: wez#1992
  • Loading branch information
patrickjonesuk committed Jun 12, 2022
1 parent dc947ed commit 2d6fa5b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
7 changes: 7 additions & 0 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,9 @@ pub struct Config {

#[dynamic(default)]
pub quote_dropped_files: DroppedFileQuoting,

#[dynamic(default = "default_focus_change_repaint_delay")]
pub focus_change_repaint_delay: u64,
}
impl_lua_conversion_dynamic!(Config);

Expand Down Expand Up @@ -1346,6 +1349,10 @@ fn default_inactive_pane_hsb() -> HsbTransform {
}
}

fn default_focus_change_repaint_delay() -> u64 {
100
}

#[derive(FromDynamic, ToDynamic, Clone, Copy, Debug)]
pub enum DefaultCursorStyle {
BlinkingBlock,
Expand Down
8 changes: 8 additions & 0 deletions docs/config/lua/config/focus_change_repaint_delay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## `focus_change_repaint_delay = 100`

*Since: nightly builds only*

When not set to `0`, WezTerm will wait the specified delay (in milliseconds) before invalidating the geometry and repainting the window after losing or gaining focus.

Using the proprietry NVIDIA drivers and EGL rendering on X11, the `CONFIGURE_NOTIFY` event is sometimes missed. This workaround ensures that the window correctly resizes in these cases.

23 changes: 13 additions & 10 deletions window/src/os/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,16 +557,19 @@ impl XWindowInner {
// the window a short time after the focus event is processed in the
// hope that it can observe the changed window properties and update
// without the human needing to interact with the window.
let window_id = self.window_id;
promise::spawn::spawn(async move {
async_io::Timer::after(std::time::Duration::from_millis(100)).await;
XConnection::with_window_inner(window_id, |inner| {
inner.sure_about_geometry = false;
inner.invalidate();
Ok(())
});
})
.detach();
let delay = self.config.focus_change_repaint_delay;
if delay != 0 {
let window_id = self.window_id;
promise::spawn::spawn(async move {
async_io::Timer::after(std::time::Duration::from_millis(delay)).await;
XConnection::with_window_inner(window_id, |inner| {
inner.sure_about_geometry = false;
inner.invalidate();
Ok(())
});
})
.detach();
}
}

pub fn dispatch_ime_compose_status(&mut self, status: DeadKeyStatus) {
Expand Down

0 comments on commit 2d6fa5b

Please sign in to comment.