Shrinking GtkAplication widget

If I use the mouse to drag and enlarge the GtkApplication window, the following code does not shrink it back until the application windows looses focus (say by using Alt-Tab or the mouse to select another program window).

gtk_window_set_default_size ( GTK_WINDOW( wApplication ), -1, -1 );
while (g_main_context_pending (g_main_context_default ()))
g_main_context_iteration (NULL, TRUE);

Is there a way to cause the GtkApplication to respond without having to loose focus? (I’m not even sure I can get the program to loose focus under Wayland.)

BTW if I programmatically make a widget inside the GtkApplication bigger, the application widget grows (as you would expect) but it also shrinks back when I make the inside widget smaller (and use the code above). It is only the use of the mouse to expand the widget that causes this issue.

Michael