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:

// https://stackoverflow.com/questions/30791670/how-to-style-a-gtklabel-with-css
// 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);
    gtk_widget_show_all(window);
    gdk_window_set_geometry_hints(gtk_widget_get_window(window), NULL, 0);
    // gdk_window_set_geometry_hints(gtk_widget_get_window(window), &geo, 0);
    gtk_main();
}
$ ./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 https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#gdk-window-set-geometry-hints 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

https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-set-geometry-hints

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.