wayland: fix protocol error when buffer size isn't a multiple of buffer_scale (#7746)

ref: #7333
This commit is contained in:
crimist authored and GitHub committed 2026-06-22 12:01:02 +02:00
1 parent 9edc0c09fc
commit 6ff5492866
1 file changed
+16 -5
+16 -5
View File
@@ -653,11 +653,15 @@ impl WaylandWindowInner {
.ok_or(anyhow!("Window does not exist"))?;
let object_id = window.wl_surface().id();
wegl_surface = Some(WlEglSurface::new(
object_id,
self.dimensions.pixel_width as i32,
self.dimensions.pixel_height as i32,
)?);
// Align pixel dimensions to the integer buffer scale factor
// to satisfy the Wayland protocol requirement that buffer
// dimensions must be an integer multiple of the buffer_scale.
let surface_udata = SurfaceUserData::from_wl(window.wl_surface());
let scale = surface_udata.surface_data.scale_factor();
let pixel_width = (self.dimensions.pixel_width as i32 / scale) * scale;
let pixel_height = (self.dimensions.pixel_height as i32 / scale) * scale;
wegl_surface = Some(WlEglSurface::new(object_id, pixel_width, pixel_height)?);
log::trace!("WEGL Surface here {:?}", wegl_surface);
@@ -885,6 +889,13 @@ impl WaylandWindowInner {
}
}
// Align pixel dimensions to the integer buffer scale factor
// to satisfy the Wayland protocol requirement that buffer
// dimensions must be an integer multiple of the buffer_scale.
let scale = factor as i32;
pixel_width = (pixel_width / scale) * scale;
pixel_height = (pixel_height / scale) * scale;
log::trace!("Resizing frame");
if !self.window_frame.is_hidden() {
// Clamp the size to at least one surface heigh/width.