[vte/vte-0-46] widget: Fix initial size in presence of non-default padding



commit c89159924c16dae0a447829dd194317c41eccf5d
Author: Egmont Koblinger <egmont gmail com>
Date:   Fri Sep 29 14:26:40 2017 +0200

    widget: Fix initial size in presence of non-default padding
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787710
    (cherry picked from commit 41f55bc1c2a978491b3fa3d23cb4aeb0c900e2b1)

 src/vte.cc         |   13 ++++++++++---
 src/vtegtk.cc      |   11 +++++++++++
 src/vteinternal.hh |    1 +
 3 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 536cec2..8fba821 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -7920,6 +7920,16 @@ VteTerminalPrivate::VteTerminalPrivate(VteTerminal *t) :
 }
 
 void
+VteTerminalPrivate::widget_constructed()
+{
+        /* Set the style as early as possible, before GTK+ starts
+         * invoking various callbacks. This is needed in order to
+         * compute the initial geometry correctly in presence of
+         * non-default padding, see bug 787710. */
+        widget_style_updated();
+}
+
+void
 VteTerminalPrivate::widget_get_preferred_width(int *minimum_width,
                                                int *natural_width)
 {
@@ -8409,9 +8419,6 @@ VteTerminalPrivate::widget_realize()
        /* Clear modifiers. */
        m_modifiers = 0;
 
-        /* Make sure the style is set, bug 727614. */
-        widget_style_updated();
-
        ensure_font();
 }
 
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 924b5a0..291fd2d 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -360,6 +360,16 @@ vte_terminal_screen_changed (GtkWidget *widget,
 }
 
 static void
+vte_terminal_constructed (GObject *object)
+{
+        VteTerminal *terminal = VTE_TERMINAL (object);
+
+        G_OBJECT_CLASS (vte_terminal_parent_class)->constructed (object);
+
+        IMPL(terminal)->widget_constructed();
+}
+
+static void
 vte_terminal_init(VteTerminal *terminal)
 {
         void *place;
@@ -619,6 +629,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
        widget_class = GTK_WIDGET_CLASS(klass);
 
        /* Override some of the default handlers. */
+        gobject_class->constructed = vte_terminal_constructed;
        gobject_class->finalize = vte_terminal_finalize;
         gobject_class->get_property = vte_terminal_get_property;
         gobject_class->set_property = vte_terminal_set_property;
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 4c6a240..a0fa801 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -650,6 +650,7 @@ public:
 
         GdkCursor *widget_cursor_new(GdkCursorType cursor_type) const;
 
+        void widget_constructed();
         void widget_realize();
         void widget_unrealize();
         void widget_map();


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