[vte] a11y: Move code into the only caller



commit 3a86becb089d62dac838d0068d5a161ec0f1a25b
Author: Christian Persch <chpe gnome org>
Date:   Sun Jan 31 15:08:44 2016 +0100

    a11y: Move code into the only caller
    
    No need for a function when these few lines are just called in this one place.

 src/vte-private.h |    6 ------
 src/vte.cc        |   33 ---------------------------------
 src/vteaccess.cc  |   17 +++++++++++------
 3 files changed, 11 insertions(+), 45 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 5df8814..ef49a3c 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -58,12 +58,6 @@ VteTerminalPrivate *_vte_terminal_get_impl(VteTerminal *terminal);
 VteRowData *_vte_terminal_ensure_row(VteTerminal *terminal);
 VteRowData * _vte_new_row_data(VteTerminal *terminal);
 
-gboolean _vte_terminal_size_to_grid_size(VteTerminal *terminal,
-                                         long w,
-                                         long h,
-                                         long *cols,
-                                         long *rows);
-
 static inline bool
 _vte_double_equal(double a,
                   double b)
diff --git a/src/vte.cc b/src/vte.cc
index 157a03e..b5ba656 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -5479,39 +5479,6 @@ VteTerminalPrivate::widget_paste_received(char const* text)
         g_free(paste);
 }
 
-/*
- * _vte_terminal_size_to_grid_size:
- * @w: the width in px
- * @h: the height in px
- * @col: return location to store the column count
- * @row: return location to store the row count
- *
- * Translates from widget size to grid size.
- *
- * If the given width or height are insufficient to show even
- * one column or row (i.e due to padding), returns %FALSE.
- */
-gboolean
-_vte_terminal_size_to_grid_size(VteTerminal *terminal,
-                                long w,
-                                long h,
-                                long *cols,
-                                long *rows)
-{
-        VteTerminalPrivate *pvt = terminal->pvt;
-        long n_cols, n_rows;
-
-        n_cols = (w - pvt->m_padding.left - pvt->m_padding.right) / pvt->char_width;
-        n_rows = (h - pvt->m_padding.top -pvt->m_padding.bottom) / pvt->char_height;
-
-        if (n_cols <= 0 || n_rows <= 0)
-                return FALSE;
-
-        *cols = n_cols;
-        *rows = n_rows;
-        return TRUE;
-}
-
 bool
 VteTerminalPrivate::feed_mouse_event(vte::grid::coords const& rowcol /* confined */,
                                      int button,
diff --git a/src/vteaccess.cc b/src/vteaccess.cc
index 4561af6..8b7e77e 100644
--- a/src/vteaccess.cc
+++ b/src/vteaccess.cc
@@ -1569,19 +1569,24 @@ vte_terminal_accessible_set_size(AtkComponent *component,
                                 gint width, gint height)
 {
         VteTerminalAccessible *accessible = VTE_TERMINAL_ACCESSIBLE(component);
-       VteTerminal *terminal;
-       long columns, rows;
        GtkWidget *widget;
 
        widget = gtk_accessible_get_widget (GTK_ACCESSIBLE(accessible));
-       if (widget == NULL) {
+       if (widget == NULL)
                return FALSE;
-       }
-       terminal = VTE_TERMINAL(widget);
+
+        VteTerminal *terminal = VTE_TERMINAL(widget);
+        auto impl = IMPL(terminal);
 
         /* If the size is an exact multiple of the cell size, use that,
          * otherwise round down. */
-        (void) _vte_terminal_size_to_grid_size(terminal, width, height, &columns, &rows);
+        width -= impl->m_padding.left + impl->m_padding.right;
+        height -= impl->m_padding.top + impl->m_padding.bottom;
+
+        auto columns = width / impl->m_char_width;
+        auto rows = height / impl->m_char_height;
+        if (columns <= 0 || rows <= 0)
+                return FALSE;
 
        vte_terminal_set_size(terminal, columns, rows);
        return (vte_terminal_get_row_count (terminal) == rows) &&


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