diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rs index 9c2a11c4f..b0b8fc984 100644 --- a/window/src/os/wayland/window.rs +++ b/window/src/os/wayland/window.rs @@ -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.