mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
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.
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user