diff --git a/src/apprt/gtk/class/window.zig b/src/apprt/gtk/class/window.zig index 2a1a5435a2b..61a4adf09c9 100644 --- a/src/apprt/gtk/class/window.zig +++ b/src/apprt/gtk/class/window.zig @@ -1156,6 +1156,27 @@ pub const Window = extern struct { }; } + fn toplevelComputeSize( + _: *gdk.Toplevel, + size: *gdk.ToplevelSize, + self: *Self, + ) callconv(.c) void { + // GTK clamps the requested size to stale monitor bounds. Re-assert the + // current surface size so an interactive resize isn't clamped. Skip the + // initial map (size still 0), and cases the compositor/quick terminal + // own (maximized, fullscreen, quick terminal). + if (self.isMaximized() or + self.isFullscreen() or + self.isQuickTerminal()) return; + + 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; + + size.setSize(w, h); + } + fn propFullscreened( _: *adw.ApplicationWindow, _: *gobject.ParamSpec, @@ -1330,6 +1351,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