mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 08:16:13 +03:00
apprt: window size limits
This commit is contained in:
@ -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
|
||||
|
@ -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();
|
||||
|
Reference in New Issue
Block a user