git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit6a55ab15ddcc2b8d626f676b5678b629ff1ce66b
parent22ae4ce421
authorLucas Galante <[email protected]>
date2026-06-25 10:10
feat: implement desktop zoom via super+control+scrolling

 src/server/cursor.rs | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/server/cursor.rs b/src/server/cursor.rs
index 2382d6a..d1ba139 100644
--- a/src/server/cursor.rs
+++ b/src/server/cursor.rs
@@ -889,6 +889,35 @@ unsafe extern "C" fn handle_axis(listener: *mut ffi::wl_listener, data: *mut std
         0
     };
 
+    if (modifiers & 0x44) == 0x44 {
+        if (*event).orientation == ffi::wl_pointer_axis_WL_POINTER_AXIS_VERTICAL_SCROLL {
+            if delta != 0.0 {
+                let wm = &mut (*seat.server).wm;
+                wm.stop_panning_animation();
+                let zoom_factor = 1.005_f64.powf(-delta);
+                let old_zoom = wm.desk_zoom;
+                let new_zoom = (old_zoom * zoom_factor).clamp(0.1, 10.0);
+                if new_zoom != old_zoom {
+                    let cx = cursor.x();
+                    let cy = cursor.y();
+                    let wlr_output = (*(*seat).server).om.output_at(cx, cy);
+                    let (phys_x, phys_y) = if !wlr_output.is_null() {
+                        let mut output_box = ffi::wlr_box { x: 0, y: 0, width: 0, height: 0 };
+                        ffi::wlr_output_layout_get_box((*(*seat).server).om.output_layout, wlr_output, &mut output_box);
+                        (output_box.x as f64, output_box.y as f64)
+                    } else {
+                        (0.0, 0.0)
+                    };
+                    wm.desk_pan_x += (cx - phys_x) * (1.0 / old_zoom - 1.0 / new_zoom);
+                    wm.desk_pan_y += (cy - phys_y) * (1.0 / old_zoom - 1.0 / new_zoom);
+                    wm.desk_zoom = new_zoom;
+                    wm.dirty_windowing();
+                }
+            }
+        }
+        return;
+    }
+
     if (modifiers & 0x40) != 0 {
         let wm = &mut (*seat.server).wm;
         wm.stop_panning_animation();