Package: gnome-terminal
Version: 3.20.0-1
Severity: normal
Tags: upstream patch
Forwarded: https://bugzilla.gnome.org/show_bug.cgi?id=760944

Since upgrading to gnome-terminal 3.20 and Gtk 3.20, nothing I do within
Terminal resizes the window: Ctrl-plus, Ctrl-minus, and the 80x24, 80x43,
etc. menu options do not trigger a resize.

This is particularly annoying if you are running something that assumes 80x24
and breaks its layout in differently-sized terminals, such as vi in
a serial console (with no way to pass SIGWINCH through the serial line).

There was a partial patch upstream already; I've added the missing bit.

-- System Information:
Debian Release: stretch/sid
  APT prefers buildd-unstable
  APT policy: (500, 'buildd-unstable'), (500, 'unstable'), (500, 'testing'), 
(500, 'stable'), (1, 'buildd-experimental'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.5.0-trunk-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages gnome-terminal depends on:
ii  dconf-gsettings-backend [gsettings-backend]  0.24.0-2
ii  gconf-service                                3.2.6-3
ii  gnome-terminal-data                          3.20.0-2
ii  gsettings-desktop-schemas                    3.20.0-1
ii  libatk1.0-0                                  2.18.0-1
ii  libc6                                        2.22-5
ii  libcairo-gobject2                            1.14.6-1
ii  libcairo2                                    1.14.6-1
ii  libdconf1                                    0.24.0-2
ii  libgconf-2-4                                 3.2.6-3
ii  libgdk-pixbuf2.0-0                           2.32.3-1.2
ii  libglib2.0-0                                 2.48.0-1
ii  libgtk-3-0                                   3.20.1-2
ii  libnautilus-extension1a                      3.19.93-1
ii  libpango-1.0-0                               1.38.1-1
ii  libpangocairo-1.0-0                          1.38.1-1
ii  libuuid1                                     2.27.1-6
ii  libvte-2.91-0                                0.44.0-1
ii  libx11-6                                     2:1.6.3-1

Versions of packages gnome-terminal recommends:
ii  dbus-x11  1.11.2-1
ii  gvfs      1.27.92-1
ii  yelp      3.16.1-1

gnome-terminal suggests no packages.

-- no debconf information
From: Sorokin Alexei <[email protected]>
Date: Mon, 7 Mar 2016 21:45:46 +0000
Subject: Fix chunked resize and --geometry option

Was caused by https://git.gnome.org/browse/gtk+/commit/?id=08974a1

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=760944
---
 src/terminal-options.c |  4 ----
 src/terminal-window.c  | 19 +++++++++++++------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/terminal-options.c b/src/terminal-options.c
index cc51cf6..723ecfe 100644
--- a/src/terminal-options.c
+++ b/src/terminal-options.c
@@ -583,10 +583,6 @@ option_geometry_callback (const gchar *option_name,
 {
   TerminalOptions *options = data;
 
-  /* See https://bugzilla.gnome.org/show_bug.cgi?id=760944 */
-  if (gtk_check_version (3, 19, 5) == NULL)
-    return unsupported_option_callback (option_name, value, data, error);
-
   if (options->initial_windows)
     {
       InitialWindow *iw;
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 8b78849..ccfceaa 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -3562,8 +3562,9 @@ terminal_window_update_geometry (TerminalWindow *window)
   GtkWidget *widget;
   GdkGeometry hints;
   GtkBorder padding;
-  int char_width;
-  int char_height;
+  GtkRequisition toplevel_request, widget_request;
+  int base_width, base_height;
+  int char_width, char_height;
   
   if (priv->active_screen == NULL)
     return;
@@ -3587,8 +3588,14 @@ terminal_window_update_geometry (TerminalWindow *window)
       padding.top + padding.bottom != priv->old_base_height ||
       widget != (GtkWidget*) priv->old_geometry_widget)
     {
-      hints.base_width = padding.left + padding.right;
-      hints.base_height = padding.top + padding.bottom;
+      gtk_widget_get_preferred_size (GTK_WIDGET (window), NULL, &toplevel_request);
+      gtk_widget_get_preferred_size (widget, NULL, &widget_request);
+
+      base_width = toplevel_request.width - widget_request.width;
+      base_height = toplevel_request.height - widget_request.height;
+
+      hints.base_width = base_width + padding.left + padding.right;
+      hints.base_height = base_height + padding.top + padding.bottom;
 
 #define MIN_WIDTH_CHARS 4
 #define MIN_HEIGHT_CHARS 1
@@ -3596,12 +3603,12 @@ terminal_window_update_geometry (TerminalWindow *window)
       hints.width_inc = char_width;
       hints.height_inc = char_height;
 
-      /* min size is min size of just the geometry widget, remember. */
+      /* min size is min size of the whole window, remember. */
       hints.min_width = hints.base_width + hints.width_inc * MIN_WIDTH_CHARS;
       hints.min_height = hints.base_height + hints.height_inc * MIN_HEIGHT_CHARS;
       
       gtk_window_set_geometry_hints (GTK_WINDOW (window),
-                                     widget,
+                                     NULL,
                                      &hints,
                                      GDK_HINT_RESIZE_INC |
                                      GDK_HINT_MIN_SIZE |
From: Simon McVittie <[email protected]>
Date: Fri, 1 Apr 2016 08:22:31 +0100
Subject: Replace no-op gtk_window_resize_to_geometry by calculating
 new size

Together with the previous commit, this fixes a regression in
GNOME 3.20: anything that would alter the Terminal size, for example
a font size change or the 80x24, 80x43 etc. menu items, did nothing.

Signed-off-by: Simon McVittie <[email protected]>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=760944
---
 src/terminal-window.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/terminal-window.c b/src/terminal-window.c
index ccfceaa..646e01a 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -3200,13 +3200,18 @@ terminal_window_update_size (TerminalWindow *window)
 {
   TerminalWindowPrivate *priv = window->priv;
   int grid_width, grid_height;
+  int pixel_width, pixel_height;
 
   /* be sure our geometry is up-to-date */
   terminal_window_update_geometry (window);
 
   terminal_screen_get_size (priv->active_screen, &grid_width, &grid_height);
 
-  gtk_window_resize_to_geometry (GTK_WINDOW (window), grid_width, grid_height);
+  /* the "old" struct members were updated by update_geometry */
+  pixel_width = priv->old_base_width + grid_width * priv->old_char_width;
+  pixel_height = priv->old_base_height + grid_height * priv->old_char_height;
+
+  gtk_window_resize (GTK_WINDOW (window), pixel_width, pixel_height);
 }
 
 void

Reply via email to