`Gtk.Window.set_default_size()` / `:default-(width|height)` does not work to resize window / restore natural size on X11 (does on Wayland)
Setting the default size to a value <= 0 will cause it to be ignored and the natural size request will be used instead. It is possible to do this while the window is showing to “reset” it to its initial size.
This works on Wayland, but not on X.org (not a typo, despite most things being the other way around)
On X, the default size appears to be ignored, at least once the window is presented. Same for size > 0. Resizing the window manually updates the properties, but setting them appears to do nothing at all.
Test case: Expand the window beyond its natural size, then click the button. On Wayland, it shrinks back down, as required. On X11, it does nothing.
I presume this is supposed to work on both? It is pretty important to be able to restore natural size, or otherwise update the size while the window is visible.
#include <gtk/gtk.h>
static void
on_button_clicked (GtkButton *button, void *user_data)
{
GtkWindow *window = GTK_WINDOW (user_data);
gtk_window_set_default_size (window, -1, -1);
}
static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window = gtk_application_window_new (app);
GtkWidget *button = gtk_button_new_with_label ("Reset default sizes");
g_signal_connect (button, "clicked", G_CALLBACK (on_button_clicked), window);
gtk_window_set_child (GTK_WINDOW (window), button);
gtk_window_present (GTK_WINDOW (window));
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}