gtk-ng: attach surface size callbacks AFTER realize (#8287)
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.pull/8288/head
commit
f2de485cae
|
|
@ -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();
|
||||
|
|
@ -1163,6 +1145,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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue