From 523799a45f40ed9d0c48c75f8daeffc69c063f09 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 1 Aug 2025 21:05:07 -0700 Subject: [PATCH] apprt/gtk-ng: winproto resizeEvent --- src/apprt/gtk-ng/class/window.zig | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/apprt/gtk-ng/class/window.zig b/src/apprt/gtk-ng/class/window.zig index 0b73f6b13..d74c2656f 100644 --- a/src/apprt/gtk-ng/class/window.zig +++ b/src/apprt/gtk-ng/class/window.zig @@ -2,6 +2,7 @@ const std = @import("std"); const build_config = @import("../../../build_config.zig"); const assert = std.debug.assert; const adw = @import("adw"); +const gdk = @import("gdk"); const gio = @import("gio"); const glib = @import("glib"); const gobject = @import("gobject"); @@ -302,6 +303,24 @@ pub const Window = extern struct { // Initialize our actions self.initActionMap(); + // We need to setup resize notifications on our surface + if (self.as(gtk.Native).getSurface()) |gdk_surface| { + _ = gobject.Object.signals.notify.connect( + gdk_surface, + *Self, + propGdkSurfaceWidth, + self, + .{ .detail = "width" }, + ); + _ = gobject.Object.signals.notify.connect( + gdk_surface, + *Self, + propGdkSurfaceHeight, + self, + .{ .detail = "height" }, + ); + } + // We always sync our appearance at the end because loading our // config and such can affect our bindings which ar setup initially // in initTemplate. @@ -726,6 +745,36 @@ pub const Window = extern struct { self.syncAppearance(); } + fn propGdkSurfaceHeight( + _: *gdk.Surface, + _: *gobject.ParamSpec, + self: *Self, + ) callconv(.c) void { + // X11 needs to fix blurring on resize, but winproto implementations + // could do anything. + self.private().winproto.resizeEvent() catch |err| { + log.warn( + "winproto resize event failed error={}", + .{err}, + ); + }; + } + + fn propGdkSurfaceWidth( + _: *gdk.Surface, + _: *gobject.ParamSpec, + self: *Self, + ) callconv(.c) void { + // X11 needs to fix blurring on resize, but winproto implementations + // could do anything. + self.private().winproto.resizeEvent() catch |err| { + log.warn( + "winproto resize event failed error={}", + .{err}, + ); + }; + } + fn propFullscreened( _: *adw.ApplicationWindow, _: *gobject.ParamSpec,