[vte] widget: Make resize-window signal cell based



commit 371f90d40fa9b3331c3e10bab91bec4a63809a0b
Author: Christian Persch <chpe gnome org>
Date:   Mon Apr 14 18:58:02 2014 +0200

    widget: Make resize-window signal cell based
    
    And don't report the padding down to the application.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=555662

 src/app.vala |   27 +++--------------------
 src/vte.c    |    4 +-
 src/vteseq.c |   67 +++++++++++++++++----------------------------------------
 src/window   |    5 ++++
 4 files changed, 31 insertions(+), 72 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index d6764f5..e18c03b 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -480,32 +480,13 @@ class Window : Gtk.ApplicationWindow
                queue_draw();
        }
 
-       private void resize_window_cb(Vte.Terminal terminal, uint width, uint height)
+       private void resize_window_cb(Vte.Terminal terminal, uint columns, uint rows)
        {
-        long char_width, char_height, columns, rows;
-               int owidth, oheight;
-               Gtk.Border padding;
-
-               /* Read the screen dimensions in cells. */
-               columns = terminal.get_column_count();
-               rows = terminal.get_column_count();
-
-               /* Take into account padding and border overhead. */
-               get_size(out owidth, out oheight);
-        char_width = terminal.get_char_width();
-        char_height = terminal.get_char_height();
-
-               if (width < 2 || height < 2)
+               if (columns < 2 || rows < 2)
                        return;
 
-               /* Take into account border overhead. */
-               padding = get_style_context().get_padding(get_state_flags());
-
-               owidth -= (int)(char_width * columns) + padding.left + padding.right;
-               oheight -= (int)(char_height * rows) + padding.top + padding.bottom;
-               // FIXMEchpe use resize_to_geometry
-               resize((int)(width + owidth),
-                          (int)(height + oheight));
+               terminal.set_size((int)columns, (int)rows);
+               resize_to_geometry((int)columns, (int)rows);
        }
 
        private void restore_window_cb(Vte.Terminal terminal)
diff --git a/src/vte.c b/src/vte.c
index a0fd639..db402a8 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -11335,8 +11335,8 @@ vte_terminal_class_init(VteTerminalClass *klass)
         /**
          * VteTerminal::resize-window:
          * @vteterminal: the object which received the signal
-         * @width: the desired width in pixels, including padding
-         * @height: the desired height in pixels, including padding
+         * @width: the desired number of columns
+         * @height: the desired number of rows
          *
          * Emitted at the child application's request.
          */
diff --git a/src/vteseq.c b/src/vteseq.c
index c0f676e..077ca4f 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -33,12 +33,8 @@
 #define BEL "\007"
 #define ST _VTE_CAP_ST
 
-
-
 /* FUNCTIONS WE USE */
 
-
-
 static void
 display_control_sequence(const char *name, GValueArray *params)
 {
@@ -251,14 +247,14 @@ vte_terminal_emit_move_window(VteTerminal *terminal, guint x, guint y)
        g_signal_emit_by_name(terminal, "move-window", x, y);
 }
 
-/* Emit a "resize-window" signal.  (Pixels.) */
+/* Emit a "resize-window" signal.  (Grid size.) */
 static void
 vte_terminal_emit_resize_window(VteTerminal *terminal,
-                               guint width, guint height)
+                               guint columns, guint rows)
 {
        _vte_debug_print(VTE_DEBUG_SIGNALS,
                        "Emitting `resize-window'.\n");
-       g_signal_emit_by_name(terminal, "resize-window", width, height);
+       g_signal_emit_by_name(terminal, "resize-window", columns, rows);
 }
 
 
@@ -894,14 +890,8 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
                 /* 3: DECCOLM set/reset to 132/80 columns mode */
                 if (terminal->pvt->deccolm_mode) {
                         vte_terminal_emit_resize_window(terminal,
-                                                        (set ? 132 : 80) *
-                                                        terminal->pvt->char_width +
-                                                        terminal->pvt->padding.left +
-                                                        terminal->pvt->padding.right,
-                                                        terminal->pvt->row_count *
-                                                        terminal->pvt->char_height +
-                                                        terminal->pvt->padding.top +
-                                                        terminal->pvt->padding.bottom);
+                                                        set ? 132 : 80,
+                                                        terminal->pvt->row_count);
                         /* Request a resize and redraw. */
                         _vte_invalidate_all(terminal);
                 }
@@ -3330,7 +3320,6 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
        long param, arg1, arg2;
        gint width, height;
        guint i;
-       GtkAllocation allocation;
 
        widget = &terminal->widget;
 
@@ -3378,15 +3367,13 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
                        if ((arg1 != -1) && (arg2 != -1)) {
                                _vte_debug_print(VTE_DEBUG_PARSE,
                                                "Resizing window "
-                                               "(to %ldx%ld pixels).\n",
-                                               arg2, arg1);
+                                               "(to %ldx%ld pixels, grid size %ldx%ld).\n",
+                                                 arg2, arg1,
+                                                 arg2 / terminal->pvt->char_width,
+                                                 arg1 / terminal->pvt->char_height);
                                vte_terminal_emit_resize_window(terminal,
-                                                               arg2 +
-                                                               terminal->pvt->padding.left +
-                                                               terminal->pvt->padding.right,
-                                                               arg1 +
-                                                               terminal->pvt->padding.top +
-                                                               terminal->pvt->padding.bottom);
+                                                                arg2 / terminal->pvt->char_width,
+                                                                arg1 / terminal->pvt->char_height);
                                i += 2;
                        }
                        break;
@@ -3410,13 +3397,7 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
                                                "Resizing window "
                                                "(to %ld columns, %ld rows).\n",
                                                arg2, arg1);
-                               vte_terminal_emit_resize_window(terminal,
-                                                               arg2 * terminal->pvt->char_width +
-                                                               terminal->pvt->padding.left +
-                                                               terminal->pvt->padding.right,
-                                                               arg1 * terminal->pvt->char_height +
-                                                               terminal->pvt->padding.top +
-                                                               terminal->pvt->padding.bottom);
+                               vte_terminal_emit_resize_window(terminal, arg2, arg1);
                                i += 2;
                        }
                        break;
@@ -3464,20 +3445,16 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
                        break;
                case 14:
                        /* Send window size, in pixels. */
-                       gtk_widget_get_allocation(widget, &allocation);
                        g_snprintf(buf, sizeof(buf),
                                   _VTE_CAP_CSI "4;%d;%dt",
-                                  allocation.height -
-                                       (terminal->pvt->padding.top +
-                                        terminal->pvt->padding.bottom),
-                                  allocation.width -
-                                       (terminal->pvt->padding.left +
-                                        terminal->pvt->padding.right));
+                                   (int)(terminal->pvt->row_count * terminal->pvt->char_height),
+                                   (int)(terminal->pvt->column_count * terminal->pvt->char_width));
                        _vte_debug_print(VTE_DEBUG_PARSE,
                                        "Reporting window size "
-                                       "(%dx%dn",
-                                       width - (terminal->pvt->padding.left + terminal->pvt->padding.right),
-                                       height - (terminal->pvt->padding.top + 
terminal->pvt->padding.bottom));
+                                       "(%dx%d)\n",
+                                         (int)(terminal->pvt->row_count * terminal->pvt->char_height),
+                                         (int)(terminal->pvt->column_count * terminal->pvt->char_width));
+
                        vte_terminal_feed_child(terminal, buf, -1);
                        break;
                case 18:
@@ -3536,12 +3513,8 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
                                /* Resize to the specified number of
                                 * rows. */
                                vte_terminal_emit_resize_window(terminal,
-                                                               terminal->pvt->column_count * 
terminal->pvt->char_width +
-                                                                terminal->pvt->padding.left +
-                                                                terminal->pvt->padding.right,
-                                                               param * terminal->pvt->char_height +
-                                                               terminal->pvt->padding.top +
-                                                                terminal->pvt->padding.bottom);
+                                                               terminal->pvt->column_count,
+                                                               param);
                        }
                        break;
                }
diff --git a/src/window b/src/window
index 563b030..60e3f45 100755
--- a/src/window
+++ b/src/window
@@ -15,6 +15,11 @@ if [ "$#" -eq 0 ] ; then
        echo "  8 h w   resize text area to (w, h) cells"
        echo "  9 0     unmaximize"
        echo "  9 1     maximize"
+        echo " 11      report iconified state"
+        echo " 13      report window location in (y, x) pixels"
+        echo " 14      report window size in (h, w) pixels"
+        echo " 18      report window size in (h, w) cells"
+        echo " 19      report screen size in (h, w) cells"
        exit
 fi
 args=


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