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
This commit is contained in:
Squibid 2025-11-22 18:27:41 -05:00
parent 47bcce621d
commit e142b6027f
Signed by: squibid
GPG key ID: BECE5684D3C4005D

View file

@ -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))
);
}
},