Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/apprt/gtk/class/window.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Loading