From c7dd111ae8eb367aa895758a59299294b5b20ed5 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Mon, 2 Dec 2024 12:42:16 -0800 Subject: [PATCH] subsurface: Add `width`/`height` methods to `SubsuraceBuffer` This is potentially useful. Other properties are specific to shm/dmabuf, and not meaningful in general. --- .../platform_specific/wayland/subsurface_widget.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/winit/src/platform_specific/wayland/subsurface_widget.rs b/winit/src/platform_specific/wayland/subsurface_widget.rs index 4f201350..c29a82b7 100644 --- a/winit/src/platform_specific/wayland/subsurface_widget.rs +++ b/winit/src/platform_specific/wayland/subsurface_widget.rs @@ -158,6 +158,20 @@ impl SubsurfaceBuffer { (subsurface_buffer, SubsurfaceBufferRelease(receiver)) } + pub fn width(&self) -> i32 { + match &*self.0.source { + BufferSource::Dma(dma) => dma.width, + BufferSource::Shm(shm) => shm.width, + } + } + + pub fn height(&self) -> i32 { + match &*self.0.source { + BufferSource::Dma(dma) => dma.height, + BufferSource::Shm(shm) => shm.height, + } + } + // Behavior of `wl_buffer::released` is undefined if attached to multiple surfaces. To allow // things like that, create a new `wl_buffer` each time. fn create_buffer(