aboutsummaryrefslogtreecommitdiff
path: root/src/view.zig
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-04-22 23:42:07 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2020-04-22 23:42:07 +0200
commit53ec8f74c3302ccb392ce608447d8f433b97a718 (patch)
treef363952f0bbdcbef772b2b8f054da2fd91fd2165 /src/view.zig
parentd6d30a7ab34ad5d90123a705a58dd9bc0d491c01 (diff)
downloadriver-53ec8f74c3302ccb392ce608447d8f433b97a718.tar.gz
river-53ec8f74c3302ccb392ce608447d8f433b97a718.tar.xz
Fix crash if floating view doesn't fit
Diffstat (limited to 'src/view.zig')
-rw-r--r--src/view.zig6
1 files 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,
};