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



commit ba28429a692ab8f42f543c844862f66177b2003e
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 e154d72..fdb9c0b 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -7933,6 +7933,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)
 {
@@ -8420,9 +8430,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 0247950..579d83b 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -361,6 +361,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;
@@ -620,6 +630,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 2939b0c..3a8acfc 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -651,6 +651,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]