mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 03:25:50 +00:00
gtk: update some comments/function names, take min sizes into account
This commit is contained in:
@@ -46,8 +46,8 @@ const Renderer = rendererpkg.Renderer;
|
||||
/// being resized to a size that is too small to be useful. These defaults
|
||||
/// are chosen to match the default size of Mac's Terminal.app, but is
|
||||
/// otherwise somewhat arbitrary.
|
||||
const min_window_width_cells: u32 = 10;
|
||||
const min_window_height_cells: u32 = 4;
|
||||
pub const min_window_width_cells: u32 = 10;
|
||||
pub const min_window_height_cells: u32 = 4;
|
||||
|
||||
/// The maximum number of key tables that can be active at any
|
||||
/// given time. `activate_key_table` calls after this are ignored.
|
||||
|
||||
@@ -2182,10 +2182,10 @@ const Action = struct {
|
||||
// Create a new tab with window context (first tab in new window)
|
||||
win.newTabForWindow(parent);
|
||||
|
||||
// Compute the initial window size before presenting so the window
|
||||
// Estimate the initial window size before presenting so the window
|
||||
// manager can position it correctly.
|
||||
if (win.getActiveSurface()) |surface| {
|
||||
surface.computeInitialSize();
|
||||
surface.estimateInitialSize();
|
||||
if (surface.getDefaultSize()) |size| {
|
||||
win.as(gtk.Window).setDefaultSize(
|
||||
@intCast(size.width),
|
||||
|
||||
@@ -2005,11 +2005,12 @@ pub const Surface = extern struct {
|
||||
self.as(gobject.Object).notifyByPspec(properties.@"default-size".impl.param_spec);
|
||||
}
|
||||
|
||||
/// Compute and set the initial window size from config and font metrics.
|
||||
/// Estimate and set the initial window size from config and font metrics.
|
||||
/// This can be called before the core surface exists to set up the window
|
||||
/// size before presenting.
|
||||
pub fn computeInitialSize(self: *Self) void {
|
||||
const priv = self.private();
|
||||
/// size before presenting. This is an estimate because it does not take
|
||||
/// into account any padding that may need to be added to the window.
|
||||
pub fn estimateInitialSize(self: *Self) void {
|
||||
const priv: *Private = self.private();
|
||||
const config_obj = priv.config orelse return;
|
||||
const config = config_obj.get();
|
||||
|
||||
@@ -2042,11 +2043,8 @@ pub const Surface = extern struct {
|
||||
|
||||
const cell = font_grid.cellSize();
|
||||
|
||||
// Calculate size: "best guess"; Padding unavailable pre-init.
|
||||
// We do not need to @max here because the surface init will set
|
||||
// size_limit which enforces minimums defined in src/Surface.zig
|
||||
const width = config.@"window-width" * cell.width;
|
||||
const height = config.@"window-height" * cell.height;
|
||||
const width = @max(CoreSurface.min_window_width_cells, config.@"window-width") * cell.width;
|
||||
const height = @max(CoreSurface.min_window_height_cells, config.@"window-height") * cell.height;
|
||||
const width_f32: f32 = @floatFromInt(width);
|
||||
const height_f32: f32 = @floatFromInt(height);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user