From 81ba188df00bf12b6290a61e8ddae3f43b8949c6 Mon Sep 17 00:00:00 2001 From: tiosgz Date: Wed, 2 Mar 2022 19:24:20 +0000 Subject: [PATCH] view: stop enforcing custom minimum size I have encountered a crash (failing assert) if a view specified a fixed size less than this minimum, and according to ifreund this behavior was planned to be removed, anyway. --- river/Root.zig | 8 -------- river/View.zig | 8 -------- river/XdgToplevel.zig | 4 ++-- river/XwaylandView.zig | 12 ++++++------ 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/river/Root.zig b/river/Root.zig index 9c3154f..5796421 100644 --- a/river/Root.zig +++ b/river/Root.zig @@ -31,14 +31,6 @@ const ViewStack = @import("view_stack.zig").ViewStack; const XwaylandUnmanaged = @import("XwaylandUnmanaged.zig"); const DragIcon = @import("DragIcon.zig"); -// Minimum effective width/height for outputs. -// This is needed, to prevent integer overflows caused by the output effective -// resolution beeing too small to fit clients that can't get scaled more and -// thus will be bigger than the output resolution. -// The value is totally arbitrary and low enough, that it should never be -// encountered during normal usage. -const min_size = 50; - new_output: wl.Listener(*wlr.Output) = wl.Listener(*wlr.Output).init(handleNewOutput), output_layout: *wlr.OutputLayout, diff --git a/river/View.zig b/river/View.zig index d61c5b4..99996c9 100644 --- a/river/View.zig +++ b/river/View.zig @@ -43,14 +43,6 @@ pub const Constraints = struct { max_height: u32, }; -// Minimum width/height for surfaces. -// This is needed, because external layouts and large padding and border sizes -// may cause surfaces so small, that bugs in client applications are encountered, -// or even surfaces of zero or negative size,which are a protocol error and would -// likely cause river to crash. The value is totally arbitrary and low enough, -// that it should never be encountered during normal usage. -pub const min_size = 50; - const Impl = union(enum) { xdg_toplevel: XdgToplevel, xwayland_view: XwaylandView, diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig index d6b8c8a..19cfe9b 100644 --- a/river/XdgToplevel.zig +++ b/river/XdgToplevel.zig @@ -143,9 +143,9 @@ pub fn getAppId(self: Self) ?[*:0]const u8 { pub fn getConstraints(self: Self) View.Constraints { const state = &self.xdg_surface.role_data.toplevel.current; return .{ - .min_width = math.max(state.min_width, View.min_size), + .min_width = math.max(state.min_width, 1), .max_width = if (state.max_width > 0) state.max_width else math.maxInt(u32), - .min_height = math.max(state.min_height, View.min_size), + .min_height = math.max(state.min_height, 1), .max_height = if (state.max_height > 0) state.max_height else math.maxInt(u32), }; } diff --git a/river/XwaylandView.zig b/river/XwaylandView.zig index e879201..0fbc25a 100644 --- a/river/XwaylandView.zig +++ b/river/XwaylandView.zig @@ -141,22 +141,22 @@ pub fn getAppId(self: Self) ?[*:0]const u8 { /// Return bounds on the dimensions of the view pub fn getConstraints(self: Self) View.Constraints { const hints = self.xwayland_surface.size_hints orelse return .{ - .min_width = View.min_size, - .min_height = View.min_size, + .min_width = 1, + .min_height = 1, .max_width = math.maxInt(u32), .max_height = math.maxInt(u32), }; return .{ - .min_width = @intCast(u32, math.max(hints.min_width, View.min_size)), - .min_height = @intCast(u32, math.max(hints.min_height, View.min_size)), + .min_width = @intCast(u32, math.max(hints.min_width, 1)), + .min_height = @intCast(u32, math.max(hints.min_height, 1)), .max_width = if (hints.max_width > 0) - math.max(@intCast(u32, hints.max_width), View.min_size) + @intCast(u32, hints.max_width) else math.maxInt(u32), .max_height = if (hints.max_height > 0) - math.max(@intCast(u32, hints.max_height), View.min_size) + @intCast(u32, hints.max_height) else math.maxInt(u32), };