diff --git a/unix/window.c b/unix/window.c index c4455d27..2a469874 100644 --- a/unix/window.c +++ b/unix/window.c @@ -165,15 +165,35 @@ void uiWindowContentSize(uiWindow *w, int *width, int *height) // TODO can't reduce the size this way void uiWindowSetContentSize(uiWindow *w, int width, int height) { + GtkAllocation childAlloc; + gint winWidth, winHeight; + dbgPrintSizes(w, "BEFORE SET"); - w->changingSize = TRUE; - gtk_widget_set_size_request(w->childHolderWidget, width, height); - // MAJOR TODO REMOVE THIS. - while (w->changingSize) - if (!uiMainStep(1)) - break; // stop early if uiQuit() called - gtk_widget_set_size_request(w->childHolderWidget, -1, -1); + // we need to resize the child holder widget to the given size + // we can't resize that without running the event loop + // but we can do gtk_window_set_size() + // so how do we deal with the differences in sizes? + // simple arithmetic, of course! + + // from what I can tell, the return from gtk_widget_get_allocation(w->window) and gtk_window_get_size(w->window) will be the same + // this is not affected by Wayland and not affected by GTK+ builtin CSD + // so we can safely juse use them to get the real window size! + // since we're using gtk_window_resize(), use the latter + gtk_window_get_size(w->window, &winWidth, &winHeight); + + // now get the child holder widget's current allocation + gtk_widget_get_allocation(w->childHolderWidget, &childAlloc); + // and punch that out of the window size + winWidth -= childAlloc.width; + winHeight -= childAlloc.height; + + // now we just need to add the new size back in + winWidth += width; + winHeight += height; + // and set it + // TODO will this move the window? + gtk_window_resize(w->window, width, height); dbgPrintSizes(w, "AFTER SET"); }