And got rid of message pumping in unix/window.c. Woo! Gotta clean it up a bit first though...

This commit is contained in:
Pietro Gagliardi 2016-10-24 14:39:10 -04:00
parent e17e69f2ad
commit 3f1540b84a
1 changed files with 27 additions and 7 deletions

View File

@ -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");
}