# HG changeset patch # User Olaf Wintermann # Date 1757786030 -7200 # Node ID 258ec399fbe66bda917660183ab30b86e9136c81 # Parent 9452eccfc0f0e5f81cb886b277866f97f8cb8783 remember app window size (GTK) diff -r 9452eccfc0f0 -r 258ec399fbe6 ui/common/properties.c --- a/ui/common/properties.c Sat Sep 13 19:52:18 2025 +0200 +++ b/ui/common/properties.c Sat Sep 13 19:53:50 2025 +0200 @@ -204,9 +204,9 @@ void ui_set_property(const char *name, const char *value) { if(value) { - cxMapRemove(application_properties, name); + cxMapPut(application_properties, name, strdup(value)); } else { - cxMapPut(application_properties, name, strdup(value)); + cxMapRemove(application_properties, name); } } diff -r 9452eccfc0f0 -r 258ec399fbe6 ui/gtk/window.c --- a/ui/gtk/window.c Sat Sep 13 19:52:18 2025 +0200 +++ b/ui/gtk/window.c Sat Sep 13 19:53:50 2025 +0200 @@ -77,6 +77,36 @@ } static gboolean ui_window_close_request(UiObject *obj) { + if(obj->widget) { + void *appwindow = g_object_get_data(G_OBJECT(obj->widget), "ui.appwindow"); + if(appwindow) { + int width = 0; + int height = 0; +#if GTK_CHECK_VERSION(4, 10, 0) + graphene_rect_t bounds; + if(gtk_widget_compute_bounds(obj->widget, obj->widget, &bounds)) { + width = bounds.size.width; + height = bounds.size.height; + } +#elif GTK_CHECK_VERSION(4, 0, 0) + GtkAllocation alloc; + gtk_widget_get_allocation(GTK_WIDGET(obj->widget), &alloc); + width = alloc.width; + height = alloc.height; +#else + gtk_window_get_size(GTK_WINDOW(obj->widget), &width, &height); +#endif + if(width > 0 && height > 0) { + char width_str[32]; + char height_str[32]; + snprintf(width_str, 32, "%d", width); + snprintf(height_str, 32, "%d", height); + ui_set_property("ui.window.width", width_str); + ui_set_property("ui.window.height", height_str); + } + } + } + uic_context_prepare_close(obj->ctx); obj->ref--; if(obj->ref > 0) { @@ -122,6 +152,10 @@ gtk_window_set_title(GTK_WINDOW(obj->widget), title); } + if(!simple) { + g_object_set_data(G_OBJECT(obj->widget), "ui.appwindow", obj); + } + const char *width = ui_get_property("ui.window.width"); const char *height = ui_get_property("ui.window.height"); if(width && height) {