Gdk_window_set_geometry_hints ()

I tried to fix this issue:

Unfortunately all my attempts lead to crashes, so I finally fall back to plain C:

// gcc `pkg-config gtk+-3.0 --cflags` test.c -o test `pkg-config --libs gtk+-3.0`
#include <gtk/gtk.h>
int main(int argc, char *argv[]) {
    GdkGeometry geo; // dummy struct
    gtk_init(&argc, &argv);
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    GtkWidget *label = gtk_label_new("Label");
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    gtk_container_add(GTK_CONTAINER(window), label);
    gdk_window_set_geometry_hints(gtk_widget_get_window(window), NULL, 0);
    // gdk_window_set_geometry_hints(gtk_widget_get_window(window), &geo, 0);
$ ./test 
Segmentation fault (core dumped)

stefan@nuc /tmp $ emerge -pv gtk+
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild   R    ] x11-libs/gtk+-3.24.16:3::gentoo  USE="X cups introspection wayland (-aqua) -broadway -cloudprint -colord -examples -gtk-doc -test -vim-syntax -xinerama" 0 KiB
Total: 1 package (1 reinstall), Size of downloads: 0 KiB

But when I pass the dummy variable &geo instead of NULL it does not crash.

Well my customer is referring to which tells:

To unset all hints, use a geom_mask of 0 and a geometry of NULL .

On the other hand, there seems to be no [allow-none] mark for geometry from gobject introspection! So may Null just not be allowed for geometry? I tried to investigate source code at gitlab, but it is too nested to follow.

And on the other hand, there is a similar function called

and that one has

geometry struct containing geometry information or NULL. [allow-none]

Well, I think I will consider this a documentation bug.

Maybe only related to Wayland, and maybe it will vanish in GTK4.

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