From de40550d2f906c76c44b44c309e316f2e939da66 Mon Sep 17 00:00:00 2001 From: lbonn Date: Wed, 22 Apr 2020 11:22:23 +0200 Subject: [PATCH] Hide the small window before percent resizing --- src/wofi.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wofi.c b/src/wofi.c index 2e65aa9..c8745e2 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -1416,6 +1416,7 @@ static gboolean do_percent_size(gpointer data) { bool width_percent = strchr(geo_str[0], '%') != NULL; bool height_percent = strchr(geo_str[1], '%') != NULL && lines == 0; GdkMonitor* monitor = gdk_display_get_monitor_at_window(gdk_display_get_default(), gtk_widget_get_window(window)); + GdkRectangle rect; gdk_monitor_get_geometry(monitor, &rect); if(width_percent) { @@ -1425,7 +1426,8 @@ static gboolean do_percent_size(gpointer data) { height = (height / 100.f) * rect.height; } update_surface_size(); - free(geo_str); + + gtk_widget_show_all(window); return G_SOURCE_REMOVE; } @@ -1628,13 +1630,14 @@ void wofi_init(struct map* _config) { gdk_threads_add_timeout(filter_rate, do_search, NULL); - + bool delay_show = false; bool width_percent = strchr(width_str, '%') != NULL; bool height_percent = strchr(height_str, '%') != NULL && lines == 0; if(width_percent || height_percent) { - char** geo_str = malloc(sizeof(char*) * 2); + static char* geo_str[2]; geo_str[0] = width_str; geo_str[1] = height_str; + delay_show = true; gdk_threads_add_timeout(70, do_percent_size, geo_str); } @@ -1655,5 +1658,7 @@ void wofi_init(struct map* _config) { gdk_threads_add_idle(insert_all_widgets, modes); gtk_window_set_title(GTK_WINDOW(window), prompt); - gtk_widget_show_all(window); + if (!delay_show) { + gtk_widget_show_all(window); + } }