From 7054c872e37f70b0cfda777d21f2df4bd5335cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Gibrowski=20Fa=C3=A9?= Date: Thu, 11 Apr 2024 12:21:21 -0300 Subject: [PATCH] accept and process buffer transform events --- daemon/src/main.rs | 13 +++++++++++-- daemon/src/wallpaper.rs | 11 ++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/daemon/src/main.rs b/daemon/src/main.rs index e7d96033..b697fc11 100644 --- a/daemon/src/main.rs +++ b/daemon/src/main.rs @@ -558,8 +558,17 @@ impl Dispatch for Daemon { } warn!("received new scale factor for non-existing surface") } - wl_surface::Event::PreferredBufferTransform { .. } => { - warn!("Received transform. We currently ignore those") + wl_surface::Event::PreferredBufferTransform { transform } => { + if let wayland_client::WEnum::Value(transform) = transform { + for wallpaper in state.wallpapers.iter_mut() { + if wallpaper.has_surface(proxy) { + wallpaper.set_transform(transform); + wallpaper.commit_surface_changes(); + return; + } + } + warn!("received new transform for non-existing surface") + } } e => error!("unrecognized WlSurface event: {e:?}"), } diff --git a/daemon/src/wallpaper.rs b/daemon/src/wallpaper.rs index fb692693..4b0cac17 100644 --- a/daemon/src/wallpaper.rs +++ b/daemon/src/wallpaper.rs @@ -10,7 +10,11 @@ use std::{ }; use wayland_client::{ - protocol::{wl_output::WlOutput, wl_shm::WlShm, wl_surface::WlSurface}, + protocol::{ + wl_output::{Transform, WlOutput}, + wl_shm::WlShm, + wl_surface::WlSurface, + }, Proxy, QueueHandle, }; @@ -189,6 +193,11 @@ impl Wallpaper { } } + #[inline] + pub fn set_transform(&self, transform: Transform) { + self.wl_surface.set_buffer_transform(transform); + } + #[inline] pub fn commit_surface_changes(&self) { let mut inner = self.inner.write().unwrap();