From 53ec8f74c3302ccb392ce608447d8f433b97a718 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 22 Apr 2020 23:42:07 +0200 Subject: [PATCH] Fix crash if floating view doesn't fit --- src/view.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/view.zig b/src/view.zig index 875293f..8e84066 100644 --- a/src/view.zig +++ b/src/view.zig @@ -136,8 +136,10 @@ pub const View = struct { if (float and !self.floating) { self.floating = true; self.pending_box = Box{ - .x = @intCast(i32, (self.output.usable_box.width - self.natural_width) / 2), - .y = @intCast(i32, (self.output.usable_box.height - self.natural_height) / 2), + .x = std.math.max(0, @divTrunc(@intCast(i32, self.output.usable_box.width) - + @intCast(i32, self.natural_width), 2)), + .y = std.math.max(0, @divTrunc(@intCast(i32, self.output.usable_box.height) - + @intCast(i32, self.natural_height), 2)), .width = self.natural_width, .height = self.natural_height, };