From 51b13830afa67162b152cc71254a1a00d09e0f8e Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 15 Oct 2002 16:24:42 +0000 Subject: [PATCH] Use the appalling gnome-terminal hack for server-controlled resizes rather than the gtk_window_set_policy approach; the GNOME people say that the former is the Right Thing in spite of the latter looking obviously plausible. git-svn-id: svn://svn.tartarus.org/sgt/putty@2066 cda61777-01e9-0310-a592-d414129be87e --- unix/pterm.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/unix/pterm.c b/unix/pterm.c index 95a6fcc5..3ae931f4 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -858,9 +858,68 @@ void set_raw_mouse_mode(int activate) void request_resize(int w, int h) { - gtk_drawing_area_size(GTK_DRAWING_AREA(inst->area), - inst->font_width * w + 2*cfg.window_border, - inst->font_height * h + 2*cfg.window_border); + int large_x, large_y; + int offset_x, offset_y; + int area_x, area_y; + GtkRequisition inner, outer; + + /* + * This is a heinous hack dreamed up by the gnome-terminal + * people to get around a limitation in gtk. The problem is + * that in order to set the size correctly we really need to be + * calling gtk_window_resize - but that needs to know the size + * of the _whole window_, not the drawing area. So what we do + * is to set an artificially huge size request on the drawing + * area, recompute the resulting size request on the window, + * and look at the difference between the two. That gives us + * the x and y offsets we need to translate drawing area size + * into window size for real, and then we call + * gtk_window_resize. + */ + + /* + * We start by retrieving the current size of the whole window. + * Adding a bit to _that_ will give us a value we can use as a + * bogus size request which guarantees to be bigger than the + * current size of the drawing area. + */ + get_window_pixels(&large_x, &large_y); + large_x += 32; + large_y += 32; + +#if GTK_CHECK_VERSION(2,0,0) + gtk_widget_set_size_request(inst->area, large_x, large_y); +#else + gtk_widget_set_usize(inst->area, large_x, large_y); +#endif + gtk_widget_size_request(inst->area, &inner); + gtk_widget_size_request(inst->window, &outer); + + offset_x = outer.width - inner.width; + offset_y = outer.height - inner.height; + + area_x = inst->font_width * w + 2*cfg.window_border; + area_y = inst->font_height * h + 2*cfg.window_border; + + /* + * Now we must set the size request on the drawing area back to + * something sensible before we commit the real resize. Best + * way to do this, I think, is to set it to what the size is + * really going to end up being. + */ +#if GTK_CHECK_VERSION(2,0,0) + gtk_widget_set_size_request(inst->area, area_x, area_y); +#else + gtk_widget_set_usize(inst->area, area_x, area_y); +#endif + +#if GTK_CHECK_VERSION(2,0,0) + gtk_window_resize(GTK_WINDOW(inst->window), + area_x + offset_x, area_y + offset_y); +#else + gdk_window_resize(inst->window->window, + area_x + offset_x, area_y + offset_y); +#endif } void real_palette_set(int n, int r, int g, int b) @@ -1435,8 +1494,6 @@ int main(int argc, char **argv) if (cfg.scrollbar) gtk_box_pack_start(inst->hbox, inst->sbar, FALSE, FALSE, 0); - gtk_window_set_policy(GTK_WINDOW(inst->window), FALSE, TRUE, TRUE); - gtk_container_add(GTK_CONTAINER(inst->window), GTK_WIDGET(inst->hbox)); { -- 2.11.0