git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commit612843cad6a2dfd5f396f05a74d3f99ba16d13fc
parentb737cbea70
authorLucas Galante <[email protected]>
date2026-07-05 01:14
Introduce delegate_wl_callback macro helper to streamline frame callback throttling in custom window event loops

 src/wayland.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/wayland.rs b/src/wayland.rs
index c2aa580..b0adf03 100644
--- a/src/wayland.rs
+++ b/src/wayland.rs
@@ -52,3 +52,23 @@ pub fn scale_pointer_pos(pos: (f64, f64), scale: f64) -> (f32, f32) {
     ((pos.0 * scale) as f32, (pos.1 * scale) as f32)
 }
 
+#[macro_export]
+macro_rules! delegate_wl_callback {
+    ($name:ty) => {
+        impl wayland_client::Dispatch<wayland_client::protocol::wl_callback::WlCallback, ()> for $name {
+            fn event(
+                state: &mut Self,
+                _proxy: &wayland_client::protocol::wl_callback::WlCallback,
+                event: wayland_client::protocol::wl_callback::Event,
+                _data: &(),
+                _conn: &wayland_client::Connection,
+                _qh: &wayland_client::QueueHandle<Self>,
+            ) {
+                if let wayland_client::protocol::wl_callback::Event::Done { .. } = event {
+                    state.frame_callback_pending = false;
+                }
+            }
+        }
+    };
+}
+