gtk_window_set_resizable resets to default size.
Steps to reproduce
- call
gtk_window_set_default_size (GTK_WINDOW (window), 500, 500);
- start the app and resize the window manually to be smaller than 500x500
- call
gtk_window_set_resizable(GTK_WINDOW(window),0);
- window will be locked, and resize to default size which is 500x500
example:
int r = 0;
static void resize (GtkWidget *widget, gpointer data) {
gtk_window_set_resizable(GTK_WINDOW(data),r);
r = !r;
}
static void activate (GtkApplication *app, gpointer user_data) {
GtkWidget *window = gtk_application_window_new (app);
GtkWidget *button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
GtkWidget *button = gtk_button_new_with_label ("Hello World");
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 500, 500);
//gtk_window_resize(GTK_WINDOW (window), 500, 500); if this is commented out instead of the above, window will resize to smallest size
gtk_container_add (GTK_CONTAINER (window), button_box);
g_signal_connect (button, "clicked", G_CALLBACK (resize), window);
gtk_container_add (GTK_CONTAINER (button_box), button);
gtk_widget_show_all (window);
}
int main (int argc, char **argv){
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
int status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
Current behavior
when calling gtk_window_set_resizable(GTK_WINDOW(w), 0)
window will be locked and resize to default size if the current size is less than the default.
and will resize to the smallest size if gtk_window_resize
is called instead of gtk_window_set_default_size
Expected outcome
window should lock and not resize, it should stay at the current size.
Version information
GTK3 Tested on ubuntu 22.04 LTS with gtk package from official repos
Edited by mohad12211