How can a GtkGlArea's size be 0 x 0 during the realize signal? [GTK4]

So, my code for creating the widget is…

viewer = gtk_gl_area_new();
gtk_widget_set_hexpand(viewer, 1);
gtk_widget_set_vexpand(viewer, 1);
gtk_widget_set_size_request(viewer, 1, 350);
g_signal_connect(viewer, "realize", G_CALLBACK(viewer_realize_callback), NULL);
g_signal_connect(viewer, "render", G_CALLBACK(viewer_render_callback), NULL);
gtk_box_append(GTK_BOX(v_box2), viewer);

… where v_box is a vertically-oriented GtkBox. In my viewer_realize_callback I have:

static void viewer_realize_callback(GtkWidget *self, gpointer user_data) {
    int width = gtk_widget_get_width(self);
    int height = gtk_widget_get_height(self);
    int scale_factor = gtk_widget_get_scale_factor(self);

For some reason, width and height are both zero. Same if I use viewer directly instead. This doesn’t look right; where could have I screwed up?

Edit: when running the code, the widget looks a normally-assigned size, it’s just that initialization fails and no OpenGL operations can be performed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.