From 9648dc7872c0fa2e36e556196c904b55d99247ac Mon Sep 17 00:00:00 2001 From: Squibid Date: Sat, 22 Nov 2025 18:27:41 -0500 Subject: [PATCH] fix crashing when a view is resized too small this is done by limiting to a minimum of 10x10 pixels, we may make this configurable using lua in the future --- src/cursor.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cursor.zig b/src/cursor.zig index 0a076f8..9beee6b 100644 --- a/src/cursor.zig +++ b/src/cursor.zig @@ -100,8 +100,9 @@ pub fn processCursorMotion(self: *Cursor, time_msec: u32) void { if(focused_view) |view| { _ = view.xdg_toplevel.setSize( - @intCast(@as(c_int, @intFromFloat(self.wlr_cursor.x)) - view.scene_tree.node.x), - @intCast(@as(c_int, @intFromFloat(self.wlr_cursor.y)) - view.scene_tree.node.y) + // TODO: configure the min and max using lua? + std.math.clamp(@as(c_int, @as(i32, @intFromFloat(self.wlr_cursor.x)) - view.scene_tree.node.x), 10, std.math.maxInt(i32)), + std.math.clamp(@as(c_int, @as(i32, @intFromFloat(self.wlr_cursor.y)) - view.scene_tree.node.y), 10, std.math.maxInt(i32)) ); } },