1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-25 22:33:52 +03:00

wayland: set scale factor without wegl_surface (for WebGpu)

This fixes wrong scale with the WebGpu backend.
This commit is contained in:
Val Packett 2022-12-24 02:05:36 -03:00 committed by Wez Furlong
parent 71ec5ac0a8
commit 6a47bbaf32

View File

@ -682,36 +682,36 @@ impl WaylandWindowInner {
// assume no. // assume no.
live_resizing: false, live_resizing: false,
}); });
// Avoid blurring by matching the scaling factor of the
// compositor; if it is going to double the size then
// we render at double the size anyway and tell it that
// the buffer is already doubled.
// Take care to detach the current buffer (managed by EGL),
// so that the compositor doesn't get annoyed by it not
// having dimensions that match the scale.
// The wegl_surface.resize won't take effect until
// we paint later on.
// We do this only if the scale has actually changed,
// otherwise interactive window resize will keep removing
// the window contents!
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);
// Avoid blurring by matching the scaling factor of the }
// compositor; if it is going to double the size then if self.surface_factor != factor {
// we render at double the size anyway and tell it that let wayland_conn = Connection::get().unwrap().wayland();
// the buffer is already doubled. let mut pool = wayland_conn.mem_pool.borrow_mut();
// Take care to detach the current buffer (managed by EGL), // Make a "fake" buffer with the right dimensions, as
// so that the compositor doesn't get annoyed by it not // simply detaching the buffer can cause wlroots-derived
// having dimensions that match the scale. // compositors consider the window to be unconfigured.
// The wegl_surface.resize won't take effect until if let Ok((_bytes, buffer)) = pool.buffer(
// we paint later on. factor,
// We do this only if the scale has actually changed, factor,
// otherwise interactive window resize will keep removing factor * 4,
// the window contents! wayland_client::protocol::wl_shm::Format::Argb8888,
if self.surface_factor != factor { ) {
let wayland_conn = Connection::get().unwrap().wayland(); self.surface.attach(Some(&buffer), 0, 0);
let mut pool = wayland_conn.mem_pool.borrow_mut(); self.surface.set_buffer_scale(factor);
// Make a "fake" buffer with the right dimensions, as self.surface_factor = factor;
// simply detaching the buffer can cause wlroots-derived
// compositors consider the window to be unconfigured.
if let Ok((_bytes, buffer)) = pool.buffer(
factor,
factor,
factor * 4,
wayland_client::protocol::wl_shm::Format::Argb8888,
) {
self.surface.attach(Some(&buffer), 0, 0);
self.surface.set_buffer_scale(factor);
self.surface_factor = factor;
}
} }
} }
} }