diff --git a/src/gtkutil.c b/src/gtkutil.c index d57627f152f..f5022411dab 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -1129,11 +1129,45 @@ xg_set_geometry (struct frame *f) } } +static struct frame *last_resize_frame = NULL; +static int last_resize_height = -1; +static int last_resize_width = -1; +static int last_resize_count = 0; + /** Function to handle resize of native frame F to WIDTH and HEIGHT pixels after we got a ConfigureNotify event. */ void xg_frame_resized (struct frame *f, int width, int height) { +#ifndef HAVE_PGTK + if (f == last_resize_frame + && (width != last_resize_width + || height != last_resize_height) + && last_resize_count <= 3) + /* We did not get what we wanted, retry. */ + { + if (CONSP (frame_size_history)) + frame_size_history_extra + (f, build_string ("xg_frame_resized, rejected"), + FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f), width, height, + last_resize_width, last_resize_height); + + gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), + last_resize_width, last_resize_height); + + last_resize_count++; + + return; + } + else + /* We either got what we asked for or lost the battle. */ + { + last_resize_frame = NULL; + last_resize_height = -1; + last_resize_width = -1; + last_resize_count = 0; + } +#endif /* Ignore case where size of native rectangle didn't change. */ if (width != FRAME_PIXEL_WIDTH (f) || height != FRAME_PIXEL_HEIGHT (f) @@ -1297,19 +1331,20 @@ xg_frame_set_char_size (struct frame *f, int width, int height) else { #ifndef HAVE_PGTK + last_resize_frame = f; + last_resize_height = height; + last_resize_width = width; + last_resize_count = 0; + gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), outer_width, outer_height); #else if (FRAME_GTK_OUTER_WIDGET (f)) - { - gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), - outer_width, outer_height); - } + gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), + outer_width, outer_height); else - { - gtk_widget_set_size_request (FRAME_GTK_WIDGET (f), - outer_width, outer_height); - } + gtk_widget_set_size_request (FRAME_GTK_WIDGET (f), + outer_width, outer_height); #endif fullscreen = Qnil; }