aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/apprt/gtk/class/window.zig
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-07-16 23:28:05 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-16 23:29:28 +0300
commit4a3302d19a2baa3a33e910e0088c24e780905b90 (patch)
treedcaf76fae1c82102d933c9225b17ca7ac5d3a847 /vendor/libghostty-vt/src/apprt/gtk/class/window.zig
parent550e9f8cc085f428429f5cf2da0bb2dba897e8b8 (diff)
chore: update vendored libghostty-vt
refs #276
Diffstat (limited to 'vendor/libghostty-vt/src/apprt/gtk/class/window.zig')
-rw-r--r--vendor/libghostty-vt/src/apprt/gtk/class/window.zig42
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/apprt/gtk/class/window.zig b/vendor/libghostty-vt/src/apprt/gtk/class/window.zig
index 2a1a5435..c34f2cb4 100644
--- a/vendor/libghostty-vt/src/apprt/gtk/class/window.zig
+++ b/vendor/libghostty-vt/src/apprt/gtk/class/window.zig
@@ -1156,6 +1156,38 @@ pub const Window = extern struct {
};
}
+ fn toplevelComputeSize(
+ _: *gdk.Toplevel,
+ size: *gdk.ToplevelSize,
+ self: *Self,
+ ) callconv(.c) void {
+ // The compositor/quick terminal own the size in these states.
+ if (self.isMaximized() or
+ self.isFullscreen() or
+ self.isQuickTerminal()) return;
+
+ // If there's no GdkSurface yet these dimensions will be zero size which
+ // will make the window start out as small as possible. These checks ensure
+ // we don't start with a 0, 0 window size.
+ const gdk_surface = self.as(gtk.Native).getSurface() orelse return;
+ const w = gdk_surface.getWidth();
+ const h = gdk_surface.getHeight();
+ if (w <= 0 or h <= 0) return;
+
+ // GTK clamps the requested size to the compositor-reported bounds, which
+ // go stale when the window moves to a larger monitor. Only re-assert the
+ // current size when it exceeds those bounds; otherwise let GTK's default
+ // sizing win so a freshly-mapped window isn't forced to a tiny size.
+ var bounds_w: c_int = undefined;
+ var bounds_h: c_int = undefined;
+ size.getBounds(&bounds_w, &bounds_h);
+
+ if (bounds_w <= 0 or bounds_h <= 0) return;
+ if (w <= bounds_w and h <= bounds_h) return;
+
+ size.setSize(w, h);
+ }
+
fn propFullscreened(
_: *adw.ApplicationWindow,
_: *gobject.ParamSpec,
@@ -1330,6 +1362,16 @@ pub const Window = extern struct {
self,
.{ .detail = "height" },
);
+ // Connect after GTK's compute-size handler so our size wins.
+ if (gobject.ext.cast(gdk.Toplevel, gdk_surface)) |toplevel| {
+ _ = gdk.Toplevel.signals.compute_size.connect(
+ toplevel,
+ *Self,
+ toplevelComputeSize,
+ self,
+ .{ .after = true },
+ );
+ }
}
// When we are realized we always setup our appearance since this