[vte/vte-0-36] widget: Initialize the color palette when the widget is initialized



commit 169eaa925561145ffbcb28de454af1fbedb4bb46
Author: Egmont Koblinger <egmont gmail com>
Date:   Mon Apr 14 17:19:02 2014 +0200

    widget: Initialize the color palette when the widget is initialized
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728051
    (cherry picked from commit f7a3c36cf36371bf0659f76cba6317c15d51a997)

 src/vte-private.h |    3 +--
 src/vte.c         |   25 ++++++++++++-------------
 2 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index af4edc3..1b5bb98 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -64,7 +64,7 @@ G_BEGIN_DECLS
  *   Colors set by SGR 256-color extension (38/48;5;index).
  *   These are direct indices into the color palette.
  *
- * 256 .. VTE_PALETTE_SIZE - 1 (261):
+ * 256 .. VTE_PALETTE_SIZE - 1 (262):
  *   Special values, such as default colors.
  *   These are direct indices into the color palette.
  *
@@ -367,7 +367,6 @@ struct _VteTerminalPrivate {
         * when realizing. */
        struct _vte_draw *draw;
 
-       gboolean palette_initialized;
        VtePaletteColor palette[VTE_PALETTE_SIZE];
 
        /* Mouse cursors. */
diff --git a/src/vte.c b/src/vte.c
index 3ffd572..f730f17 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -2480,7 +2480,11 @@ vte_terminal_new(void)
        return g_object_new(VTE_TYPE_TERMINAL, NULL);
 }
 
-/* Get the actually used color from the palette. */
+/*
+ * Get the actually used color from the palette.
+ * The return value can be NULL only if entry is one of VTE_CURSOR_BG,
+ * VTE_HIGHLIGHT_BG or VTE_HIGHLIGHT_FG.
+ */
 PangoColor *
 _vte_terminal_get_color(const VteTerminal *terminal, int entry)
 {
@@ -2901,12 +2905,7 @@ vte_terminal_set_colors(VteTerminal *terminal,
 
                /* Set up the color entry. */
                _vte_terminal_set_color_internal(terminal, i, VTE_COLOR_SOURCE_API, unset ? NULL : &color);
-               if (!terminal->pvt->palette_initialized)
-                       terminal->pvt->palette[i].sources[VTE_COLOR_SOURCE_ESCAPE].is_set = FALSE;
        }
-
-       /* Track that we had a color palette set. */
-       terminal->pvt->palette_initialized = TRUE;
 }
 
 static GdkColor *
@@ -8571,6 +8570,7 @@ vte_terminal_init(VteTerminal *terminal)
 {
        VteTerminalPrivate *pvt;
        GtkStyleContext *context;
+       int i;
 
        _vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_init()\n");
 
@@ -8618,6 +8618,11 @@ vte_terminal_init(VteTerminal *terminal)
        pvt->screen = &terminal->pvt->normal_screen;
        _vte_terminal_set_default_attributes(terminal);
 
+       /* Set up the desired palette. */
+       vte_terminal_set_default_colors(terminal);
+       for (i = 0; i < VTE_PALETTE_SIZE; i++)
+               terminal->pvt->palette[i].sources[VTE_COLOR_SOURCE_ESCAPE].is_set = FALSE;
+
        /* Set up I/O encodings. */
        pvt->iso2022 = _vte_iso2022_state_new(pvt->encoding,
                                              &_vte_terminal_codeset_changed_cb,
@@ -9295,11 +9300,6 @@ vte_terminal_realize(GtkWidget *widget)
        /* Set the realized flag. */
        gtk_widget_set_realized (widget, TRUE);
 
-       /* Set up the desired palette. */
-       if (!terminal->pvt->palette_initialized) {
-               vte_terminal_set_default_colors(terminal);
-       }
-
        /* Set up input method support.  FIXME: do we need to handle the
         * "retrieve-surrounding" and "delete-surrounding" events? */
        if (terminal->pvt->im_context != NULL) {
@@ -13908,8 +13908,7 @@ vte_terminal_reset(VteTerminal *terminal,
                g_hash_table_destroy(pvt->dec_saved);
                pvt->dec_saved = g_hash_table_new(NULL, NULL);
        }
-       /* Reset the color palette. Only the 256 indexed colors, not the special ones.
-        * (XTerm doesn't reset the cursor color, the others are not alterable by escapes in vte.) */
+       /* Reset the color palette. Only the 256 indexed colors, not the special ones, as per xterm. */
        for (i = 0; i < 256; i++)
                terminal->pvt->palette[i].sources[VTE_COLOR_SOURCE_ESCAPE].is_set = FALSE;
        /* Reset the default attributes.  Reset the alternate attribute because


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