diff options
| author | Leah Amelia Chen <hi@pluie.me> | 2025-08-20 03:23:35 +0800 |
|---|---|---|
| committer | Leah Amelia Chen <hi@pluie.me> | 2025-08-20 03:29:15 +0800 |
| commit | 7977b3695ab04f96e83581a481f035a4cd6c60ef (patch) | |
| tree | 31fbce3a754bbf4624c0b890232fa89b5244aea5 | |
| parent | 0930b2daff95c3550282b567c90d4c370fcd329b (diff) | |
gtk-ng: attach surface size callbacks AFTER realize
The `gdk.Surface` is only ever available *after* the window had been
first presented and mapped. Trying to get the surface during `init`
like what we had previously done will **always** return null.
| -rw-r--r-- | src/apprt/gtk-ng/class/window.zig | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/apprt/gtk-ng/class/window.zig b/src/apprt/gtk-ng/class/window.zig index 18e9178ac..a513fd287 100644 --- a/src/apprt/gtk-ng/class/window.zig +++ b/src/apprt/gtk-ng/class/window.zig @@ -301,24 +301,6 @@ 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" }, - ); - } - // Start states based on config. if (priv.config) |config_obj| { const config = config_obj.get(); @@ -1124,6 +1106,25 @@ pub const Window = extern struct { return; } + // We need to setup resize notifications on our surface, + // which is only available after the window had been realized. + 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" }, + ); + } + // When we are realized we always setup our appearance since this // calls some winproto functions. self.syncAppearance(); |
