From a98b1cc03b4f6dd2d8fc42fd71008f113e484037 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 24 Aug 2015 18:59:13 +0100 Subject: [PATCH] Use new GTK3 API call for server-controlled window resize. gtk_window_resize_to_geometry() allows us to make use of the already- set-up WM resize hints to immediately figure out how to resize the window to a particular character cell size, and hence makes a much simpler implementation of request_resize() than the previous hackery. --- unix/gtkwin.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/unix/gtkwin.c b/unix/gtkwin.c index bb71089b..90e7d52b 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -1747,6 +1747,9 @@ void set_raw_mouse_mode(void *frontend, int activate) void request_resize(void *frontend, int w, int h) { struct gui_data *inst = (struct gui_data *)frontend; + +#if !GTK_CHECK_VERSION(3,0,0) + int large_x, large_y; int offset_x, offset_y; int area_x, area_y; @@ -1819,6 +1822,20 @@ void request_resize(void *frontend, int w, int h) gdk_window_resize(gtk_widget_get_window(inst->window), area_x + offset_x, area_y + offset_y); #endif + +#else /* GTK_CHECK_VERSION(3,0,0) */ + + /* + * In GTK3, we can do this by using gtk_window_resize_to_geometry, + * which uses the fact that we've already set up the main window's + * WM hints to reflect the terminal drawing area's resize + * increment (i.e. character cell) and the fixed amount of stuff + * round the edges. + */ + gtk_window_resize_to_geometry(GTK_WINDOW(inst->window), w, h); + +#endif + } static void real_palette_set(struct gui_data *inst, int n, int r, int g, int b)