gnome-terminal r3321 - trunk/src



Author: chpe
Date: Sat Feb 21 22:00:11 2009
New Revision: 3321
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=3321&view=rev

Log:
Bug 570591 â running 'reset' shrinks the terminal window
Correctly use the broken vte_terminal_get_padding() API.

Modified:
   trunk/src/terminal-screen.c
   trunk/src/terminal-window.c

Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c	(original)
+++ trunk/src/terminal-screen.c	Sat Feb 21 22:00:11 2009
@@ -1581,19 +1581,19 @@
   TerminalScreenPrivate *priv = screen->priv;
   gboolean (* button_press_event) (GtkWidget*, GdkEventButton*) =
     GTK_WIDGET_CLASS (terminal_screen_parent_class)->button_press_event;
-  int char_width, char_height, x, y, xpad, ypad;
+  int char_width, char_height, row, col, xpad_total, ypad_total;
   char *matched_string;
   int matched_flavor = 0;
   guint state;
 
   state = event->state & gtk_accelerator_get_default_mod_mask ();
 
-  vte_terminal_get_padding (VTE_TERMINAL (screen), &xpad, &ypad);
   terminal_screen_get_cell_size (screen, &char_width, &char_height);
+  vte_terminal_get_padding (VTE_TERMINAL (screen), &xpad_total, &ypad_total);
 
-  x = (event->x - xpad) / char_width;
-  y = (event->y - ypad) / char_height;
-  matched_string = terminal_screen_check_match (screen, x, y, &matched_flavor);
+  row = (event->x - xpad_total / 2) / char_width;
+  col = (event->y - ypad_total / 2) / char_height;
+  matched_string = terminal_screen_check_match (screen, row, col, &matched_flavor);
   
   if (matched_string != NULL &&
       (event->button == 1 || event->button == 2) &&

Modified: trunk/src/terminal-window.c
==============================================================================
--- trunk/src/terminal-window.c	(original)
+++ trunk/src/terminal-window.c	Sat Feb 21 22:00:11 2009
@@ -963,17 +963,25 @@
 {
   TerminalWindowPrivate *priv = window->priv;
   VteTerminal *terminal = VTE_TERMINAL (screen);
+  GtkWidget *widget = GTK_WIDGET (screen);
   guint grid_width, grid_height;
-  int xpad, ypad, char_width, char_height;
+  int xpad_total, ypad_total, char_width, char_height;
+
+  /* NOTE: width and height already include the VteTerminal's padding! */
+
+  /* Short-circuit */
+  if (((int) width) == widget->allocation.width &&
+      ((int) height) == widget->allocation.height)
+    return;
 
   /* The resize-window signal sucks. Re-compute grid widths */
 
-  vte_terminal_get_padding (terminal, &xpad, &ypad);
+  vte_terminal_get_padding (terminal, &xpad_total, &ypad_total);
   char_width = vte_terminal_get_char_width (terminal);
   char_height = vte_terminal_get_char_height (terminal);
 
-  grid_width = (width - 2 * xpad) / char_width;
-  grid_height = (height - 2 * ypad) / char_height;
+  grid_width = (width - xpad_total) / char_width;
+  grid_height = (height - ypad_total) / char_height;
 
   vte_terminal_set_size (terminal, grid_width, grid_height);
 
@@ -2305,8 +2313,8 @@
   int char_height;
   int grid_width;
   int grid_height;
-  int xpad;
-  int ypad;
+  int xpad_total;
+  int ypad_total;
 
   /* be sure our geometry is up-to-date */
   terminal_window_update_geometry (window);
@@ -2335,10 +2343,10 @@
   if (force_grid_height >= 0)
     grid_height = force_grid_height;
   
-  vte_terminal_get_padding (VTE_TERMINAL (screen), &xpad, &ypad);
+  vte_terminal_get_padding (VTE_TERMINAL (screen), &xpad_total, &ypad_total);
 
-  w += xpad * 2 + char_width * grid_width;
-  h += ypad * 2 + char_height * grid_height;
+  w += xpad_total + char_width * grid_width;
+  h += ypad_total + char_height * grid_height;
 
   _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY,
                          "[window %p] set size: grid %dx%d force %dx%d setting %dx%d pixels\n",
@@ -2694,15 +2702,15 @@
       char_height != priv->old_char_height ||
       widget != (GtkWidget*) priv->old_geometry_widget)
     {
-      int xpad, ypad;
+      int xpad_total, ypad_total;
       
       /* FIXME Since we're using xthickness/ythickness to compute
        * padding we need to change the hints when the theme changes.
        */
-      vte_terminal_get_padding (VTE_TERMINAL (priv->active_screen), &xpad, &ypad);
+      vte_terminal_get_padding (VTE_TERMINAL (priv->active_screen), &xpad_total, &ypad_total);
       
-      hints.base_width = xpad;
-      hints.base_height = ypad;
+      hints.base_width = xpad_total;
+      hints.base_height = ypad_total;
 
 #define MIN_WIDTH_CHARS 4
 #define MIN_HEIGHT_CHARS 2



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