[gnome-terminal] Use new GTK+ 3 facilities to fix resizing



commit 8e6454b0efc01cf212f338c76d5d0557575f9513
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Oct 9 22:48:16 2010 -0400

    Use new GTK+ 3 facilities to fix resizing
    
    The old sizing hacks don't work at all with GTK+ 3 because GTK+
    no longer deals with underallocation (allocation smaller than the
    minimum size) gracefully. However, GTK+ 3 has now been fixed so that
    the geometry widget feature of gtk_window_set_geometry_hints() works
    without hacks.
    
    For GTK+ 3, we use the new gtk_window_resize_to_geometry() function
    to replace the hacks we were doing to determine the minimum size.
    (The same hacks also did a dual purpose of making GTK+'s
    computation for the geometry widget work correctly.)
    
    GTK+ required version is bumped for the new function; VTE required
    version is bumped for a fix to the minimum size it reports in its
    GTK+ 3 build.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=631797

 configure.ac          |    4 ++--
 src/terminal-window.c |   38 +++++++++++++++++++++++++-------------
 2 files changed, 27 insertions(+), 15 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fd43270..10e7da6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,7 +42,7 @@ AM_GLIB_GNU_GETTEXT
 GLIB_REQUIRED=2.25.0
 GIO_REQUIRED=2.25.12
 GCONF_REQUIRED=2.31.3
-VTE_REQUIRED=0.26.0
+VTE_REQUIRED=0.27.1
 
 AC_MSG_CHECKING([which gtk+ version to compile against])
 AC_ARG_WITH([gtk],
@@ -60,7 +60,7 @@ case "$with_gtk" in
        VTE_PC_VERSION=
        ;;
   3.0) GTK_API_VERSION=3.0
-       GTK_REQUIRED=2.91.0
+       GTK_REQUIRED=2.91.1
        VTE_PC_VERSION=-2.90
        ;;
 esac
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 8fefcac..546b6be 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -2603,17 +2603,10 @@ terminal_window_set_size_force_grid (TerminalWindow *window,
                                      int             force_grid_width,
                                      int             force_grid_height)
 {
-  /* Owen's hack from gnome-terminal */
   GtkWidget *widget;
   GtkWidget *app;
-  GtkRequisition toplevel_request;
-  GtkRequisition widget_request;
-  int w, h;
-  int char_width;
-  int char_height;
   int grid_width;
   int grid_height;
-  GtkBorder *inner_border = NULL;
 
   /* be sure our geometry is up-to-date */
   terminal_window_update_geometry (window);
@@ -2623,6 +2616,29 @@ terminal_window_set_size_force_grid (TerminalWindow *window,
   app = gtk_widget_get_toplevel (widget);
   g_assert (app != NULL);
 
+  terminal_screen_get_size (screen, &grid_width, &grid_height);
+
+  if (force_grid_width >= 0)
+    grid_width = force_grid_width;
+  if (force_grid_height >= 0)
+    grid_height = force_grid_height;
+
+#if GTK_CHECK_VERSION (2, 91, 0)
+  if (even_if_mapped && gtk_widget_get_mapped (app))
+    gtk_window_resize_to_geometry (GTK_WINDOW (app), grid_width, grid_height);
+  else
+    gtk_window_set_default_geometry (GTK_WINDOW (app), grid_width, grid_height);
+#else
+{
+  /* Owen's hack from gnome-terminal */
+
+  GtkBorder *inner_border = NULL;
+  GtkRequisition toplevel_request;
+  GtkRequisition widget_request;
+  int char_width;
+  int char_height;
+  int w, h;
+
   /* This set_size_request hack is because the extra size above base
    * size should only include the width of widgets to the side of the
    * terminal and the height of widgets above and below the terminal.
@@ -2644,7 +2660,6 @@ terminal_window_set_size_force_grid (TerminalWindow *window,
   gtk_widget_size_request (widget, &widget_request);
 
   terminal_screen_get_cell_size (screen, &char_width, &char_height);
-  terminal_screen_get_size (screen, &grid_width, &grid_height);
 
   _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,
                          "[window %p] set size: toplevel %dx%d widget %dx%d grid %dx%d char-cell %dx%d\n",
@@ -2656,11 +2671,6 @@ terminal_window_set_size_force_grid (TerminalWindow *window,
   w = toplevel_request.width - widget_request.width;
   h = toplevel_request.height - widget_request.height;
 
-  if (force_grid_width >= 0)
-    grid_width = force_grid_width;
-  if (force_grid_height >= 0)
-    grid_height = force_grid_height;
-  
   gtk_widget_style_get (widget, "inner-border", &inner_border, NULL);
   w += (inner_border ? (inner_border->left + inner_border->right) : 0) + char_width * grid_width;
   h += (inner_border ? (inner_border->top + inner_border->bottom) : 0) + char_height * grid_height;
@@ -2678,6 +2688,8 @@ terminal_window_set_size_force_grid (TerminalWindow *window,
     gtk_window_set_default_size (GTK_WINDOW (app), w, h);
   }
 }
+#endif
+}
 
 void
 terminal_window_switch_screen (TerminalWindow *window,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]