Fix crash if floating view doesn't fit

This commit is contained in:
Isaac Freund 2020-04-22 23:42:07 +02:00
parent d6d30a7ab3
commit 53ec8f74c3
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11

View file

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