diff --git a/src/Window.zig b/src/Window.zig index 1729ced23..4e88fb77e 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -379,11 +379,10 @@ pub fn create(alloc: Allocator, app: *App, config: *const Config) !*Window { // Set a minimum size that is cols=10 h=4. This matches Mac's Terminal.app // but is otherwise somewhat arbitrary. - // TODO: - // try window.setSizeLimits(.{ - // .width = @floatToInt(u32, cell_size.width * 10), - // .height = @floatToInt(u32, cell_size.height * 4), - // }, .{ .width = null, .height = null }); + try window.setSizeLimits(.{ + .width = @floatToInt(u32, cell_size.width * 10), + .height = @floatToInt(u32, cell_size.height * 4), + }, null); // Call our size callback which handles all our retina setup // Note: this shouldn't be necessary and when we clean up the window diff --git a/src/apprt/glfw.zig b/src/apprt/glfw.zig index 53c28a4a9..d48939191 100644 --- a/src/apprt/glfw.zig +++ b/src/apprt/glfw.zig @@ -149,6 +149,23 @@ pub const Window = struct { } } + /// Set the size limits of the window. + /// Note: this interface is not good, we should redo it if we plan + /// to use this more. i.e. you can't set max width but no max height, + /// or no mins. + pub fn setSizeLimits(self: *Window, min: apprt.WindowSize, max_: ?apprt.WindowSize) !void { + try self.window.setSizeLimits(.{ + .width = min.width, + .height = min.height, + }, if (max_) |max| .{ + .width = max.width, + .height = max.height, + } else .{ + .width = null, + .height = null, + }); + } + /// Returns the content scale for the created window. pub fn getContentScale(self: *const Window) !apprt.ContentScale { const scale = try self.window.getContentScale();