1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 22:01:47 +03:00

wayland: fix spurious resize event on focus change

The resize event would be fine except that it happens to trigger
the scroll position to reset to the bottom.
This commit is contained in:
Wez Furlong 2020-01-02 11:01:41 -08:00
parent ce5e69cb8f
commit 0db15ecaf4
2 changed files with 13 additions and 8 deletions

View File

@ -48,7 +48,7 @@ pub enum Operator {
MultiplyThenOver(Color), MultiplyThenOver(Color),
} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Dimensions { pub struct Dimensions {
pub pixel_width: usize, pub pixel_width: usize,
pub pixel_height: usize, pub pixel_height: usize,

View File

@ -454,18 +454,23 @@ impl WaylandWindowInner {
// Update the window decoration size // Update the window decoration size
self.window.as_mut().unwrap().resize(w, h); self.window.as_mut().unwrap().resize(w, h);
// Store the new pixel dimensions // Compute the new pixel dimensions
self.dimensions = Dimensions { let new_dimensions = Dimensions {
pixel_width: pixel_width.try_into().unwrap(), pixel_width: pixel_width.try_into().unwrap(),
pixel_height: pixel_height.try_into().unwrap(), pixel_height: pixel_height.try_into().unwrap(),
dpi: factor as usize * 96, dpi: factor as usize * 96,
}; };
// Only trigger a resize if the new dimensions are different;
// this makes things more efficient and a little more smooth
if new_dimensions != self.dimensions {
self.dimensions = new_dimensions;
self.callbacks.resize(self.dimensions); self.callbacks.resize(self.dimensions);
#[cfg(feature = "opengl")] #[cfg(feature = "opengl")]
{ {
if let Some(wegl_surface) = self.wegl_surface.as_mut() { if let Some(wegl_surface) = self.wegl_surface.as_mut() {
wegl_surface.resize(pixel_width, pixel_height, 0, 0); wegl_surface.resize(pixel_width, pixel_height, 0, 0);
}
} }
} }