[vte/vte-next: 46/47] Remove GdkColor APIs



commit 2ac6cb2e917a2c5c67be65b2c36fdd4f23e8ad4e
Author: Christian Persch <chpe gnome org>
Date:   Tue May 3 01:47:07 2011 +0200

    Remove GdkColor APIs
    
    ... and use GdkRGBA throughout.

 doc/reference/vte-sections.txt |    7 -
 src/vte-private.h              |    2 +-
 src/vte.c                      |  562 ++++++++++++++--------------------------
 src/vte.h                      |   33 +--
 src/vtebg.c                    |    2 +-
 src/vtedraw.c                  |   57 ++---
 src/vtedraw.h                  |    9 +-
 src/vteseq.c                   |   41 ++--
 8 files changed, 245 insertions(+), 468 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index c23e98f..e898478 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -28,19 +28,12 @@ vte_terminal_set_allow_bold
 vte_terminal_get_allow_bold
 vte_terminal_set_scroll_on_output
 vte_terminal_set_scroll_on_keystroke
-vte_terminal_set_color_bold
 vte_terminal_set_color_bold_rgba
-vte_terminal_set_color_foreground
 vte_terminal_set_color_foreground_rgba
-vte_terminal_set_color_background
 vte_terminal_set_color_background_rgba
-vte_terminal_set_color_dim
 vte_terminal_set_color_dim_rgba
-vte_terminal_set_color_cursor
 vte_terminal_set_color_cursor_rgba
-vte_terminal_set_color_highlight
 vte_terminal_set_color_highlight_rgba
-vte_terminal_set_colors
 vte_terminal_set_colors_rgba
 vte_terminal_set_default_colors
 vte_terminal_set_background_image
diff --git a/src/vte-private.h b/src/vte-private.h
index e1afe13..c4a92a0 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -332,7 +332,7 @@ struct _VteTerminalPrivate {
 	gboolean palette_initialized;
 	gboolean highlight_color_set;
 	gboolean cursor_color_set;
-	PangoColor palette[VTE_PALETTE_SIZE];
+	GdkRGBA palette[VTE_PALETTE_SIZE];
 
 	/* Mouse cursors. */
 	gboolean mouse_cursor_visible;
diff --git a/src/vte.c b/src/vte.c
index be43124..d589100 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -2162,26 +2162,20 @@ vte_terminal_new(void)
 /* Set up a palette entry with a more-or-less match for the requested color. */
 static void
 vte_terminal_set_color_internal(VteTerminal *terminal, int entry,
-				const GdkColor *proposed)
+				const GdkRGBA *proposed)
 {
-	PangoColor *color;
+        GdkRGBA *color;
 
 	color = &terminal->pvt->palette[entry];
-
-	if (color->red == proposed->red &&
-	    color->green == proposed->green &&
-	    color->blue == proposed->blue) {
+        if (gdk_rgba_equal(color, proposed))
 		return;
-	}
 
 	_vte_debug_print(VTE_DEBUG_MISC,
-			"Set color[%d] to (%04x,%04x,%04x).\n", entry,
-			proposed->red, proposed->green, proposed->blue);
+			"Set color[%d] to rgba(%.3f,%.3f,%.3f,%.3f).\n", entry,
+			proposed->red, proposed->green, proposed->blue, proposed->alpha);
 
 	/* Save the requested color. */
-	color->red = proposed->red;
-	color->green = proposed->green;
-	color->blue = proposed->blue;
+        *color = *proposed;
 
 	/* If we're not realized yet, there's nothing else to do. */
 	if (! gtk_widget_get_realized (&terminal->widget)) {
@@ -2202,12 +2196,12 @@ vte_terminal_set_color_internal(VteTerminal *terminal, int entry,
 }
 
 static void
-vte_terminal_generate_bold(const PangoColor *foreground,
-			   const PangoColor *background,
+vte_terminal_generate_bold(const GdkRGBA *foreground,
+			   const GdkRGBA *background,
 			   double factor,
-			   GdkColor *bold)
+			   GdkRGBA *bold)
 {
-	double fy, fcb, fcr, by, bcb, bcr, r, g, b;
+	double fy, fcb, fcr, by, bcb, bcr, r, g, b, a;
 	g_assert(foreground != NULL);
 	g_assert(background != NULL);
 	g_assert(bold != NULL);
@@ -2235,171 +2229,27 @@ vte_terminal_generate_bold(const PangoColor *foreground,
 	r = fy + 1.402 * fcr;
 	g = fy + 0.34414 * fcb - 0.71414 * fcr;
 	b = fy + 1.722 * fcb;
+        a = (factor * foreground->alpha) + ((1.0 - factor) * background->alpha);
 	_vte_debug_print(VTE_DEBUG_MISC,
-			"Calculated bold (%d, %d, %d) = (%lf,%lf,%lf)",
-			foreground->red, foreground->green, foreground->blue,
-			r, g, b);
-	bold->pixel = 0;
-	bold->red = CLAMP(r, 0, 0xffff);
-	bold->green = CLAMP(g, 0, 0xffff);
-	bold->blue = CLAMP(b, 0, 0xffff);
-	_vte_debug_print(VTE_DEBUG_MISC,
-			"= (%04x,%04x,%04x).\n",
-			bold->red, bold->green, bold->blue);
-}
-
-/**
- * vte_terminal_set_color_bold:
- * @terminal: a #VteTerminal
- * @bold: the new bold color
- *
- * Sets the color used to draw bold text in the default foreground color.
- */
-void
-vte_terminal_set_color_bold(VteTerminal *terminal, const GdkColor *bold)
-{
-	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-	g_return_if_fail(bold != NULL);
-
-	_vte_debug_print(VTE_DEBUG_MISC,
-			"Set bold color to (%04x,%04x,%04x).\n",
-			bold->red, bold->green, bold->blue);
-	vte_terminal_set_color_internal(terminal, VTE_BOLD_FG, bold);
-}
-
-/**
- * vte_terminal_set_color_dim:
- * @terminal: a #VteTerminal
- * @dim: the new dim color
- *
- * Sets the color used to draw dim text in the default foreground color.
- */
-void
-vte_terminal_set_color_dim(VteTerminal *terminal, const GdkColor *dim)
-{
-	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-	g_return_if_fail(dim != NULL);
-
-	_vte_debug_print(VTE_DEBUG_MISC,
-			"Set dim color to (%04x,%04x,%04x).\n",
-			dim->red, dim->green, dim->blue);
-	vte_terminal_set_color_internal(terminal, VTE_DIM_FG, dim);
-}
-
-/**
- * vte_terminal_set_color_foreground:
- * @terminal: a #VteTerminal
- * @foreground: the new foreground color
- *
- * Sets the foreground color used to draw normal text
- */
-void
-vte_terminal_set_color_foreground(VteTerminal *terminal,
-				  const GdkColor *foreground)
-{
-	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-	g_return_if_fail(foreground != NULL);
-
-	_vte_debug_print(VTE_DEBUG_MISC,
-			"Set foreground color to (%04x,%04x,%04x).\n",
-			foreground->red, foreground->green, foreground->blue);
-	vte_terminal_set_color_internal(terminal, VTE_DEF_FG, foreground);
-}
-
-/**
- * vte_terminal_set_color_background:
- * @terminal: a #VteTerminal
- * @background: the new background color
- *
- * Sets the background color for text which does not have a specific background
- * color assigned.  Only has effect when no background image is set and when
- * the terminal is not transparent.
- */
-void
-vte_terminal_set_color_background(VteTerminal *terminal,
-				  const GdkColor *background)
-{
-	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-	g_return_if_fail(background != NULL);
-
+                         "Calculated bold for fg(%.3f,%.3f,%.3f,%.3f) bg(%.3f,%.3f,%.3f,%.3f) is rgba(%.3f,%.3f,%.3f,%.3f) ",
+			foreground->red, foreground->green, foreground->blue, foreground->alpha,
+                        background->red, background->green, background->blue, background->alpha,
+			r, g, b, a);
+        bold->red = CLAMP (r, 0., 1.);
+        bold->green = CLAMP (g, 0., 1.);
+        bold->blue = CLAMP (b, 0., 1.);
+        bold->alpha = CLAMP (a, 0., 1.);
 	_vte_debug_print(VTE_DEBUG_MISC,
-			"Set background color to (%04x,%04x,%04x).\n",
-			background->red, background->green, background->blue);
-	vte_terminal_set_color_internal(terminal, VTE_DEF_BG, background);
-}
-
-/**
- * vte_terminal_set_color_cursor:
- * @terminal: a #VteTerminal
- * @cursor_background: (allow-none): the new color to use for the text cursor, or %NULL
- *
- * Sets the background color for text which is under the cursor.  If %NULL, text
- * under the cursor will be drawn with foreground and background colors
- * reversed.
- *
- * Since: 0.11.11
- */
-void
-vte_terminal_set_color_cursor(VteTerminal *terminal,
-			      const GdkColor *cursor_background)
-{
-	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-
-	if (cursor_background != NULL) {
-		_vte_debug_print(VTE_DEBUG_MISC,
-				"Set cursor color to (%04x,%04x,%04x).\n",
-				cursor_background->red,
-				cursor_background->green,
-				cursor_background->blue);
-		vte_terminal_set_color_internal(terminal, VTE_CUR_BG,
-						cursor_background);
-		terminal->pvt->cursor_color_set = TRUE;
-	} else {
-		_vte_debug_print(VTE_DEBUG_MISC,
-				"Cleared cursor color.\n");
-		terminal->pvt->cursor_color_set = FALSE;
-	}
-}
-
-/**
- * vte_terminal_set_color_highlight:
- * @terminal: a #VteTerminal
- * @highlight_background: (allow-none): the new color to use for highlighted text, or %NULL
- *
- * Sets the background color for text which is highlighted.  If %NULL,
- * highlighted text (which is usually highlighted because it is selected) will
- * be drawn with foreground and background colors reversed.
- *
- * Since: 0.11.11
- */
-void
-vte_terminal_set_color_highlight(VteTerminal *terminal,
-				 const GdkColor *highlight_background)
-{
-	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-
-	if (highlight_background != NULL) {
-		_vte_debug_print(VTE_DEBUG_MISC,
-				"Set highlight color to (%04x,%04x,%04x).\n",
-				highlight_background->red,
-				highlight_background->green,
-				highlight_background->blue);
-		vte_terminal_set_color_internal(terminal, VTE_DEF_HL,
-						highlight_background);
-		terminal->pvt->highlight_color_set = TRUE;
-	} else {
-		_vte_debug_print(VTE_DEBUG_MISC,
-				"Cleared highlight color.\n");
-		terminal->pvt->highlight_color_set = FALSE;
-	}
+			"normed rgba(%.3f,%.3f,%.3f,%.3f).\n",
+			bold->red, bold->green, bold->blue, bold->alpha);
 }
 
 /**
- * vte_terminal_set_colors:
+ * vte_terminal_set_colors_rgba:
  * @terminal: a #VteTerminal
  * @foreground: (allow-none): the new foreground color, or %NULL
  * @background: (allow-none): the new background color, or %NULL
- * @palette: (array length=palette_size zero-terminated=0) (element-type Gdk.Color): the color palette
+ * @palette: (array length=palette_size zero-terminated=0) (element-type Gdk.RGBA): the color palette
  * @palette_size: the number of entries in @palette
  *
  * The terminal widget uses a 28-color model comprised of the default foreground
@@ -2415,20 +2265,20 @@ vte_terminal_set_color_highlight(VteTerminal *terminal,
  * @palette_size is 8 or 16, the third (dim) and possibly the second (bold)
  * 8-color palettes are extrapolated from the new background color and the items
  * in @palette.
+ *
+ * Since: 0.28
  */
 void
-vte_terminal_set_colors(VteTerminal *terminal,
-			const GdkColor *foreground,
-			const GdkColor *background,
-			const GdkColor *palette,
-			glong palette_size)
+vte_terminal_set_colors_rgba(VteTerminal *terminal,
+                             const GdkRGBA *foreground,
+                             const GdkRGBA *background,
+                             const GdkRGBA *palette,
+                             gsize palette_size)
 {
-	guint i;
-	GdkColor color;
+	gsize i;
 
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
 
-	g_return_if_fail(palette_size >= 0);
 	g_return_if_fail((palette_size == 0) ||
 			 (palette_size == 8) ||
 			 (palette_size == 16) ||
@@ -2436,7 +2286,7 @@ vte_terminal_set_colors(VteTerminal *terminal,
 			 (palette_size > 24 && palette_size < 256));
 
 	_vte_debug_print(VTE_DEBUG_MISC,
-			"Set color palette [%ld elements].\n",
+			"Set color palette [%" G_GSIZE_FORMAT " elements].\n",
 			palette_size);
 
 	/* Accept NULL as the default foreground and background colors if we
@@ -2448,19 +2298,27 @@ vte_terminal_set_colors(VteTerminal *terminal,
 		background = &palette[0];
 	}
 
-	memset(&color, 0, sizeof(color));
-
 	/* Initialize each item in the palette if we got any entries to work
 	 * with. */
 	for (i=0; i < G_N_ELEMENTS(terminal->pvt->palette); i++) {
+                GdkRGBA color;
+
+                /* Take the supplied palette if there is one. */
+                if (i < palette_size) {
+                        vte_terminal_set_color_internal(terminal, i, &palette[i]);
+                        continue;
+                }
+
+                /* Create default color */
 		if (i < 16) {
-			color.blue = (i & 4) ? 0xc000 : 0;
-			color.green = (i & 2) ? 0xc000 : 0;
-			color.red = (i & 1) ? 0xc000 : 0;
+			color.blue = (i & 4) ? 0.75 : 0.;
+			color.green = (i & 2) ? 0.75 : 0.;
+			color.red = (i & 1) ? 0.75 : 0.;
+                        color.alpha = 1.0;
 			if (i > 7) {
-				color.blue += 0x3fff;
-				color.green += 0x3fff;
-				color.red += 0x3fff;
+				color.blue += 0.25;
+				color.green += 0.25;
+				color.red += 0.25;
 			}
 		}
 		else if (i < 232) {
@@ -2469,30 +2327,30 @@ vte_terminal_set_colors(VteTerminal *terminal,
 			int red =   (r == 0) ? 0 : r * 40 + 55;
 			int green = (g == 0) ? 0 : g * 40 + 55;
 			int blue =  (b == 0) ? 0 : b * 40 + 55;
-			color.red   = red | red << 8  ;
-			color.green = green | green << 8;
-			color.blue  = blue | blue << 8;
+			color.red   = (red | red << 8) / 65535.;
+			color.green = (green | green << 8) / 65535.;
+			color.blue  = (blue | blue << 8) / 65535.;
+                        color.alpha = 1.;
 		} else if (i < 256) {
 			int shade = 8 + (i - 232) * 10;
-			color.red = color.green = color.blue = shade | shade << 8;
+			color.red = color.green = color.blue = (shade | shade << 8) / 65535.;
+                        color.alpha = 1.;
 		}
 		else switch (i) {
 			case VTE_DEF_BG:
 				if (background != NULL) {
 					color = *background;
 				} else {
-					color.red = 0;
-					color.blue = 0;
-					color.green = 0;
+					color.red = color.green = color.blue = 0.;
+                                        color.alpha = 1.;
 				}
 				break;
 			case VTE_DEF_FG:
 				if (foreground != NULL) {
 					color = *foreground;
 				} else {
-					color.red = 0xc000;
-					color.blue = 0xc000;
-					color.green = 0xc000;
+                                        color.red= color.green = color.blue = 0.75;
+                                        color.alpha = 1.;
 				}
 				break;
 			case VTE_BOLD_FG:
@@ -2506,23 +2364,16 @@ vte_terminal_set_colors(VteTerminal *terminal,
 							   &terminal->pvt->palette[VTE_DEF_BG],
 							   0.5,
 							   &color);
-				break;
+                                break;
 			case VTE_DEF_HL:
-				color.red = 0xc000;
-				color.blue = 0xc000;
-				color.green = 0xc000;
+                                color.red = color.green = color.blue = 0.75;
+                                color.alpha = 1.;
 				break;
 			case VTE_CUR_BG:
-				color.red = 0x0000;
-				color.blue = 0x0000;
-				color.green = 0x0000;
+                                color.red = color.green = color.blue = 0.;
+                                color.alpha = 1.;
 				break;
-			}
-
-		/* Override from the supplied palette if there is one. */
-		if ((glong) i < palette_size) {
-			color = palette[i];
-		}
+                }
 
 		/* Set up the color entry. */
 		vte_terminal_set_color_internal(terminal, i, &color);
@@ -2532,21 +2383,6 @@ vte_terminal_set_colors(VteTerminal *terminal,
 	terminal->pvt->palette_initialized = TRUE;
 }
 
-static GdkColor *
-gdk_color_from_rgba (GdkColor *color,
-                     const GdkRGBA *rgba)
-{
-        if (rgba == NULL)
-                return NULL;
-
-        color->red = rgba->red * 65535.;
-        color->green = rgba->green * 65535.;
-        color->blue = rgba->blue * 65535.;
-        color->pixel = 0;
-
-	return color;
-}
-
 /**
  * vte_terminal_set_color_bold_rgba:
  * @terminal: a #VteTerminal
@@ -2557,23 +2393,24 @@ gdk_color_from_rgba (GdkColor *color,
  */
 void
 vte_terminal_set_color_bold_rgba(VteTerminal *terminal,
-                                 const GdkRGBA *bold)
+                                 const GdkRGBA *rgba)
 {
-	GdkColor color;
+        GdkRGBA mixed;
 
-	if (bold == NULL)
-	{
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+	if (rgba == NULL) {
 		vte_terminal_generate_bold(&terminal->pvt->palette[VTE_DEF_FG],
 					   &terminal->pvt->palette[VTE_DEF_BG],
 					   1.8,
-					   &color);
-	}
-	else
-	{
-		gdk_color_from_rgba(&color, bold);
+					   &mixed);
+                rgba = &mixed;
 	}
 
-	vte_terminal_set_color_bold(terminal, &color);
+        _vte_debug_print(VTE_DEBUG_MISC,
+                        "Set bold color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
+                        rgba->red, rgba->green, rgba->blue, rgba->alpha);
+        vte_terminal_set_color_internal(terminal, VTE_BOLD_FG, rgba);
 }
 
 /**
@@ -2588,23 +2425,24 @@ vte_terminal_set_color_bold_rgba(VteTerminal *terminal,
  */
 void
 vte_terminal_set_color_dim_rgba(VteTerminal *terminal,
-                                const GdkRGBA *dim)
+                                const GdkRGBA *rgba)
 {
-	GdkColor color;
+        GdkRGBA mixed;
 
-	if (dim == NULL)
-	{
-		vte_terminal_generate_bold(&terminal->pvt->palette[VTE_DEF_FG],
-					   &terminal->pvt->palette[VTE_DEF_BG],
-					   0.5,
-					   &color);
-	}
-	else
-	{
-		gdk_color_from_rgba(&color, dim);
-	}
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
 
-	vte_terminal_set_color_dim(terminal, &color);
+        if (rgba == NULL) {
+                vte_terminal_generate_bold(&terminal->pvt->palette[VTE_DEF_FG],
+                                           &terminal->pvt->palette[VTE_DEF_BG],
+                                           0.5,
+                                           &mixed);
+                rgba = &mixed;
+        }
+
+        _vte_debug_print(VTE_DEBUG_MISC,
+                        "Set dim color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
+                        rgba->red, rgba->green, rgba->blue, rgba->alpha);
+        vte_terminal_set_color_internal(terminal, VTE_DIM_FG, rgba);
 }
 
 /**
@@ -2618,12 +2456,15 @@ vte_terminal_set_color_dim_rgba(VteTerminal *terminal,
  */
 void
 vte_terminal_set_color_foreground_rgba(VteTerminal *terminal,
-				       const GdkRGBA *foreground)
+				       const GdkRGBA *rgba)
 {
-	GdkColor color;
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+        g_return_if_fail(rgba != NULL);
 
-	vte_terminal_set_color_foreground(terminal,
-                                          gdk_color_from_rgba(&color, foreground));
+        _vte_debug_print(VTE_DEBUG_MISC,
+                        "Set foreground color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
+                        rgba->red, rgba->green, rgba->blue, rgba->alpha);
+        vte_terminal_set_color_internal(terminal, VTE_DEF_FG, rgba);
 }
 
 /**
@@ -2639,12 +2480,15 @@ vte_terminal_set_color_foreground_rgba(VteTerminal *terminal,
  */
 void
 vte_terminal_set_color_background_rgba(VteTerminal *terminal,
-				       const GdkRGBA *background)
+				       const GdkRGBA *rgba)
 {
-	GdkColor color;
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+        g_return_if_fail(rgba != NULL);
 
-	vte_terminal_set_color_background(terminal,
-                                          gdk_color_from_rgba (&color, background));
+        _vte_debug_print(VTE_DEBUG_MISC,
+                        "Set background color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
+                        rgba->red, rgba->green, rgba->blue, rgba->alpha);
+        vte_terminal_set_color_internal(terminal, VTE_DEF_BG, rgba);
 }
 
 /**
@@ -2660,12 +2504,21 @@ vte_terminal_set_color_background_rgba(VteTerminal *terminal,
  */
 void
 vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
-				   const GdkRGBA *cursor_background)
+				   const GdkRGBA *rgba)
 {
-        GdkColor color;
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
 
-	vte_terminal_set_color_cursor(terminal,
-                                      gdk_color_from_rgba(&color, cursor_background));
+        if (rgba != NULL) {
+                _vte_debug_print(VTE_DEBUG_MISC,
+                                "Set cursor color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
+                                rgba->red, rgba->green, rgba->blue, rgba->alpha);
+                vte_terminal_set_color_internal(terminal, VTE_CUR_BG, rgba);
+                terminal->pvt->cursor_color_set = TRUE;
+        } else {
+                _vte_debug_print(VTE_DEBUG_MISC,
+                                "Cleared cursor color.\n");
+                terminal->pvt->cursor_color_set = FALSE;
+        }
 }
 
 /**
@@ -2681,58 +2534,21 @@ vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
  */
 void
 vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
-				      const GdkRGBA *highlight_background)
-{
-	GdkColor color;
-
-	vte_terminal_set_color_highlight(terminal,
-                                         gdk_color_from_rgba(&color, highlight_background));
-}
-
-/**
- * vte_terminal_set_colors_rgba:
- * @terminal: a #VteTerminal
- * @foreground: (allow-none): the new foreground color, or %NULL
- * @background: (allow-none): the new background color, or %NULL
- * @palette: (array length=palette_size zero-terminated=0) (element-type Gdk.RGBA): the color palette
- * @palette_size: the number of entries in @palette
- *
- * The terminal widget uses a 28-color model comprised of the default foreground
- * and background colors, the bold foreground color, the dim foreground
- * color, an eight color palette, bold versions of the eight color palette,
- * and a dim version of the the eight color palette.
- *
- * @palette_size must be either 0, 8, 16, or 24, or between 25 and 255 inclusive.
- * If @foreground is %NULL and
- * @palette_size is greater than 0, the new foreground color is taken from
- * @palette[7].  If @background is %NULL and @palette_size is greater than 0,
- * the new background color is taken from @palette[0].  If
- * @palette_size is 8 or 16, the third (dim) and possibly the second (bold)
- * 8-color palettes are extrapolated from the new background color and the items
- * in @palette.
- *
- * Since: 0.28
- */
-void
-vte_terminal_set_colors_rgba(VteTerminal *terminal,
-			     const GdkRGBA *foreground,
-			     const GdkRGBA *background,
-			     const GdkRGBA *palette,
-			     gsize palette_size)
+				      const GdkRGBA *rgba)
 {
-	GdkColor fg, bg, *pal;
-	gsize i;
-
-	pal = g_new (GdkColor, palette_size);
-	for (i = 0; i < palette_size; ++i)
-                gdk_color_from_rgba(&pal[i], &palette[i]);
-
-	vte_terminal_set_colors(terminal,
-                                gdk_color_from_rgba(&fg, foreground),
-                                gdk_color_from_rgba(&bg, background),
-	                        pal, palette_size);
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
 
-	g_free (pal);
+        if (rgba != NULL) {
+                _vte_debug_print(VTE_DEBUG_MISC,
+                                "Set highlight color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
+                                rgba->red, rgba->green, rgba->blue, rgba->alpha);
+                vte_terminal_set_color_internal(terminal, VTE_DEF_HL, rgba);
+                terminal->pvt->highlight_color_set = TRUE;
+        } else {
+                _vte_debug_print(VTE_DEBUG_MISC,
+                                "Cleared highlight color.\n");
+                terminal->pvt->highlight_color_set = TRUE;
+        }
 }
 
 /**
@@ -2745,7 +2561,7 @@ void
 vte_terminal_set_default_colors(VteTerminal *terminal)
 {
 	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-	vte_terminal_set_colors(terminal, NULL, NULL, NULL, 0);
+	vte_terminal_set_colors_rgba(terminal, NULL, NULL, NULL, 0);
 }
 
 
@@ -4538,7 +4354,7 @@ _vte_terminal_visible_beep(VteTerminal *terminal)
 	GtkWidget *widget;
 	GtkAllocation allocation;
 	GtkStyle *style;
-	PangoColor color;
+	GdkRGBA color;
 
 	widget = &terminal->widget;
 
@@ -4546,15 +4362,16 @@ _vte_terminal_visible_beep(VteTerminal *terminal)
 
 		style = gtk_widget_get_style (widget);
 		gtk_widget_get_allocation (widget, &allocation);
-		color.red = style->fg[gtk_widget_get_state (widget)].red;
-		color.green = style->fg[gtk_widget_get_state (widget)].green;
-		color.blue = style->fg[gtk_widget_get_state (widget)].blue;
+		color.red = style->fg[gtk_widget_get_state (widget)].red / 65535.;
+                color.green = style->fg[gtk_widget_get_state (widget)].green / 65535.;
+                color.blue = style->fg[gtk_widget_get_state (widget)].blue / 65535.;
+                color.alpha = 1.0;
 
 		_vte_draw_start(terminal->pvt->draw);
 		_vte_draw_fill_rectangle(terminal->pvt->draw,
 					 0, 0,
 					 allocation.width, allocation.height,
-					 &color, VTE_DRAW_OPAQUE);
+					 &color);
 		_vte_draw_end(terminal->pvt->draw);
 
 		/* Force the repaint, max delay of UPDATE_REPEAT_TIMEOUT */
@@ -5722,7 +5539,7 @@ vte_terminal_get_text_range_maybe_wrapped(VteTerminal *terminal,
 	const VteCell *pcell = NULL;
 	GString *string;
 	struct _VteCharAttributes attr;
-	PangoColor fore, back, *palette;
+	GdkRGBA fore, back, *palette;
 
 	if (!is_selected)
 		is_selected = always_selected;
@@ -8335,8 +8152,7 @@ vte_terminal_realize(GtkWidget *widget)
 	VteTerminal *terminal;
 	GdkWindowAttr attributes;
 	GtkAllocation allocation;
-        GdkColor color;
-	guint attributes_mask = 0, i;
+	guint attributes_mask = 0;
 
 	_vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_realize()\n");
 
@@ -8396,15 +8212,6 @@ vte_terminal_realize(GtkWidget *widget)
 		vte_terminal_set_default_colors(terminal);
 	}
 
-	/* Allocate colors. */
-	for (i = 0; i < G_N_ELEMENTS(terminal->pvt->palette); i++) {
-		color.red = terminal->pvt->palette[i].red;
-		color.green = terminal->pvt->palette[i].green;
-		color.blue = terminal->pvt->palette[i].blue;
-		color.pixel = 0;
-		vte_terminal_set_color_internal(terminal, i, &color);
-	}
-
 	/* Set up input method support.  FIXME: do we need to handle the
 	 * "retrieve-surrounding" and "delete-surrounding" events? */
 	if (terminal->pvt->im_context != NULL) {
@@ -8600,7 +8407,7 @@ vte_terminal_unichar_is_local_graphic(VteTerminal *terminal, vteunistr c, gboole
 
 static void
 vte_terminal_fill_rectangle(VteTerminal *terminal,
-			    const PangoColor *color,
+			    const GdkRGBA *color,
 			    gint x,
 			    gint y,
 			    gint width,
@@ -8611,13 +8418,13 @@ vte_terminal_fill_rectangle(VteTerminal *terminal,
 				 x + terminal->pvt->inner_border.left,
                                  y + terminal->pvt->inner_border.top,
 				 width, height,
-				 color, VTE_DRAW_OPAQUE);
+				 color);
 	_vte_draw_end(terminal->pvt->draw);
 }
 
 static void
 vte_terminal_draw_line(VteTerminal *terminal,
-		       const PangoColor *color,
+		       const GdkRGBA *color,
 		       gint x,
 		       gint y,
 		       gint xp,
@@ -8630,7 +8437,7 @@ vte_terminal_draw_line(VteTerminal *terminal,
 
 static void
 vte_terminal_draw_rectangle(VteTerminal *terminal,
-			    const PangoColor *color,
+			    const GdkRGBA *color,
 			    gint x,
 			    gint y,
 			    gint width,
@@ -8641,13 +8448,13 @@ vte_terminal_draw_rectangle(VteTerminal *terminal,
 				 x + terminal->pvt->inner_border.left,
                                  y + terminal->pvt->inner_border.top,
 				 width, height,
-				 color, VTE_DRAW_OPAQUE);
+				 color);
 	_vte_draw_end(terminal->pvt->draw);
 }
 
 static void
 vte_terminal_draw_point(VteTerminal *terminal,
-			const PangoColor *color,
+			const GdkRGBA *color,
 			gint x,
 			gint y)
 {
@@ -8685,7 +8492,7 @@ vte_terminal_draw_graphic(VteTerminal *terminal, vteunistr c,
 	}
 
 	if (_vte_draw_char(terminal->pvt->draw, &request,
-			   &terminal->pvt->palette[fore], VTE_DRAW_OPAQUE, bold)) {
+			   &terminal->pvt->palette[fore], bold)) {
 		/* We were able to draw with actual fonts. */
 		return TRUE;
 	}
@@ -9427,7 +9234,7 @@ vte_terminal_draw_cells(VteTerminal *terminal,
 {
 	int i, x, y, ascent;
 	gint columns = 0;
-	PangoColor *fg, *bg, *defbg;
+	const GdkRGBA *fg, *bg, *defbg;
 
 	g_assert(n > 0);
 	_VTE_DEBUG_IF(VTE_DEBUG_CELLS) {
@@ -9467,12 +9274,12 @@ vte_terminal_draw_cells(VteTerminal *terminal,
                                         y + terminal->pvt->inner_border.top,
 					columns * column_width + bold,
 					row_height,
-					bg, VTE_DRAW_OPAQUE);
+					bg);
 		}
 	} while (i < n);
 	_vte_draw_text(terminal->pvt->draw,
 			items, n,
-			fg, VTE_DRAW_OPAQUE, bold);
+			fg, bold);
 	for (i = 0; i < n; i++) {
 		/* Deadjust for the border. */
 		items[i].x -= terminal->pvt->inner_border.left;
@@ -9523,23 +9330,33 @@ vte_terminal_draw_cells(VteTerminal *terminal,
 	}
 }
 
-/* Try to map a PangoColor to a palette entry and return its index. */
+/* Try to map a GdkRGBA to a palette entry and return its index. */
 static guint
-_vte_terminal_map_pango_color(VteTerminal *terminal, PangoColor *color)
+_vte_terminal_map_pango_color(VteTerminal *terminal, const PangoColor *pcolor)
 {
-	long distance[G_N_ELEMENTS(terminal->pvt->palette)];
+	double distance[G_N_ELEMENTS(terminal->pvt->palette)];
 	guint i, ret;
+        GdkRGBA color;
+
+        color.red = pcolor->red / 65535.;
+        color.green = pcolor->green / 65535.;
+        color.blue = pcolor->blue / 65535.;
+        color.alpha = 1.0;
 
-	/* Calculate a "distance" value.  Could stand to be improved a bit. */
+        /* Calculate a "distance" value.  Could stand to be improved a bit. */
 	for (i = 0; i < G_N_ELEMENTS(distance); i++) {
-		const PangoColor *entry = &terminal->pvt->palette[i];
-		distance[i] = 0;
-		distance[i] += ((entry->red >> 8) - (color->red >> 8)) *
-			       ((entry->red >> 8) - (color->red >> 8));
-		distance[i] += ((entry->blue >> 8) - (color->blue >> 8)) *
-			       ((entry->blue >> 8) - (color->blue >> 8));
-		distance[i] += ((entry->green >> 8) - (color->green >> 8)) *
-			       ((entry->green >> 8) - (color->green >> 8));
+                const GdkRGBA *entry = &terminal->pvt->palette[i];
+                GdkRGBA d;
+
+                d.red = entry->red - color.red;
+                d.green = entry->green - color.green;
+                d.blue = entry->blue - color.blue;
+                d.alpha = entry->alpha - color.alpha;
+
+                distance[i] = (d.red * d.red) +
+                              (d.green * d.green) +
+                              (d.blue * d.blue) +
+                              (d.alpha * d.alpha);
 	}
 
 	/* Find the index of the minimum value. */
@@ -9551,12 +9368,13 @@ _vte_terminal_map_pango_color(VteTerminal *terminal, PangoColor *color)
 	}
 
 	_vte_debug_print(VTE_DEBUG_UPDATES,
-			"mapped PangoColor(%04x,%04x,%04x) to "
-			"palette entry (%04x,%04x,%04x)\n",
-			color->red, color->green, color->blue,
+			"mapped rgba(%.3f,%.3f,%.3f,%.3f) to "
+                        "palette entry rgba(%.3f,%.3f,%.3f,%.3f)\n",
+			color.red, color.green, color.blue, color.alpha,
 			terminal->pvt->palette[ret].red,
 			terminal->pvt->palette[ret].green,
-			terminal->pvt->palette[ret].blue);
+                        terminal->pvt->palette[ret].blue,
+                        terminal->pvt->palette[ret].alpha);
 
 	return ret;
 }
@@ -9870,7 +9688,7 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 							y,
 							(j - i) * column_width + bold,
 							row_height,
-							&terminal->pvt->palette[back], VTE_DRAW_OPAQUE);
+							&terminal->pvt->palette[back]);
 				}
 				/* We'll need to continue at the first cell which didn't
 				 * match the first one in this set. */
@@ -9894,7 +9712,7 @@ vte_terminal_draw_rows(VteTerminal *terminal,
 								  y,
 								  (j - i)  * column_width,
 								  row_height,
-								  &terminal->pvt->palette[back], VTE_DRAW_OPAQUE);
+								  &terminal->pvt->palette[back]);
 				}
 				i = j;
 			} while (i < end_column);
@@ -12290,9 +12108,9 @@ static gboolean
 vte_terminal_background_update(VteTerminal *terminal)
 {
         double saturation;
-	const PangoColor *entry;
-	GdkColor color;
+	const GdkRGBA *entry;
         GdkRGBA rgba;
+        GdkColor color;
 
 	/* If we're not realized yet, don't worry about it, because we get
 	 * called when we realize. */
@@ -12308,21 +12126,19 @@ vte_terminal_background_update(VteTerminal *terminal)
 
 	entry = &terminal->pvt->palette[VTE_DEF_BG];
 	_vte_debug_print(VTE_DEBUG_BG,
-			 "Setting background color to (%d, %d, %d, %.3f).\n",
-			 entry->red, entry->green, entry->blue,
-			 terminal->pvt->bg_tint_color.alpha);
+			 "Updating background color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
+			 entry->red, entry->green, entry->blue, entry->alpha);
 
 	/* Set the terminal widget background color since otherwise we
 	 * won't draw it for VTE_BG_SOURCE_NONE. */
-	color.red = entry->red;
-	color.green = entry->green;
-	color.blue = entry->blue;
+        color.pixel = 0;
+        color.red = entry->red * 65535.;
+        color.green = entry->green * 65535.;
+        color.blue = entry->blue * 65535.;
 	gtk_widget_modify_bg (&terminal->widget, GTK_STATE_NORMAL, &color);
 
-        rgba.red = entry->red / 65535.;
-        rgba.green = entry->green / 65535.;
-        rgba.blue = entry->blue / 65535.;
-        rgba.alpha = terminal->pvt->bg_tint_color.alpha;
+        rgba = *entry;
+        rgba.alpha *= terminal->pvt->bg_tint_color.alpha;
         _vte_draw_set_background_solid (terminal->pvt->draw, &rgba);
 
 	/* If we're transparent, and either have no root image or are being
@@ -12460,7 +12276,7 @@ vte_terminal_set_background_tint_color_rgba(VteTerminal *terminal,
         pvt = terminal->pvt;
 
         _vte_debug_print(VTE_DEBUG_MISC,
-                        "Setting background tint to %.3f,%.3f,%.3f,%.3f\n",
+                        "Setting background tint to rgba(%.3f,%.3f,%.3f,%.3f)\n",
                         rgba->red, rgba->green, rgba->blue, rgba->alpha);
         if (gdk_rgba_equal(&pvt->bg_tint_color, rgba))
                 return;
diff --git a/src/vte.h b/src/vte.h
index 6ad2b2e..8da5171 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -164,7 +164,7 @@ typedef struct _VteCharAttributes VteCharAttributes;
 struct _VteCharAttributes {
         /*< private >*/
 	long row, column;
-	GdkColor fore, back;
+	GdkRGBA fore, back;
 	guint underline:1, strikethrough:1;
 };
 
@@ -228,36 +228,19 @@ void vte_terminal_set_scroll_on_keystroke(VteTerminal *terminal,
 					  gboolean scroll);
 
 /* Set the color scheme. */
-void vte_terminal_set_color_dim(VteTerminal *terminal,
-				const GdkColor *dim);
-void vte_terminal_set_color_bold(VteTerminal *terminal,
-				 const GdkColor *bold);
-void vte_terminal_set_color_foreground(VteTerminal *terminal,
-				       const GdkColor *foreground);
-void vte_terminal_set_color_background(VteTerminal *terminal,
-				       const GdkColor *background);
-void vte_terminal_set_color_cursor(VteTerminal *terminal,
-				   const GdkColor *cursor_background);
-void vte_terminal_set_color_highlight(VteTerminal *terminal,
-				      const GdkColor *highlight_background);
-void vte_terminal_set_colors(VteTerminal *terminal,
-			     const GdkColor *foreground,
-			     const GdkColor *background,
-			     const GdkColor *palette,
-			     glong palette_size);
 
 void vte_terminal_set_color_bold_rgba(VteTerminal *terminal,
-                                      const GdkRGBA *bold);
+                                      const GdkRGBA *rgba);
 void vte_terminal_set_color_dim_rgba(VteTerminal *terminal,
-	                             const GdkRGBA *dim);
+	                             const GdkRGBA *rgba);
 void vte_terminal_set_color_foreground_rgba(VteTerminal *terminal,
-					    const GdkRGBA *foreground);
+					    const GdkRGBA *rgba);
 void vte_terminal_set_color_background_rgba(VteTerminal *terminal,
-					    const GdkRGBA *background);
+					    const GdkRGBA *rgba);
 void vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
-					const GdkRGBA *cursor_background);
+					const GdkRGBA *rgba);
 void vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
-					   const GdkRGBA *highlight_background);
+					   const GdkRGBA *rgba);
 void vte_terminal_set_colors_rgba(VteTerminal *terminal,
 				  const GdkRGBA *foreground,
 				  const GdkRGBA *background,
@@ -270,8 +253,6 @@ void vte_terminal_set_default_colors(VteTerminal *terminal);
 void vte_terminal_set_background_image(VteTerminal *terminal, GdkPixbuf *image);
 void vte_terminal_set_background_image_file(VteTerminal *terminal,
 					    const char *path);
-void vte_terminal_set_background_tint_color(VteTerminal *terminal,
-					    const GdkColor *color);
 void vte_terminal_set_background_tint_color_rgba(VteTerminal *terminal,
                                                  const GdkRGBA *rgba);
 void vte_terminal_set_background_saturation(VteTerminal *terminal,
diff --git a/src/vtebg.c b/src/vtebg.c
index 0670285..c53febd 100644
--- a/src/vtebg.c
+++ b/src/vtebg.c
@@ -390,7 +390,7 @@ vte_bg_cache_search(VteBg *bg,
  * @source_type: a #VteBgSourceType
  * @source_pixbuf: (allow-none): a #GdkPixbuf, or %NULL
  * @source_file: (allow-none): path of an image file, or %NULL
- * @tint: a #PangoColor to use as tint color
+ * @tint: a #GdkRGBA to use as tint color
  * @saturation: the saturation as a value between 0.0 and 1.0
  * @other: a #cairo_surface_t
  *
diff --git a/src/vtedraw.c b/src/vtedraw.c
index df19ec7..75b2a2b 100644
--- a/src/vtedraw.c
+++ b/src/vtedraw.c
@@ -946,21 +946,9 @@ _vte_draw_has_bold (struct _vte_draw *draw)
 }
 
 static void
-set_source_color_alpha (cairo_t        *cr,
-			const PangoColor *color,
-			guchar alpha)
-{
-	cairo_set_source_rgba (cr,
-			      color->red / 65535.,
-			      color->green / 65535.,
-			      color->blue / 65535.,
-			      alpha / 255.);
-}
-
-static void
 _vte_draw_text_internal (struct _vte_draw *draw,
 			 struct _vte_draw_text_request *requests, gsize n_requests,
-			 const PangoColor *color, guchar alpha, gboolean bold)
+			 const GdkRGBA *color, gboolean bold)
 {
 	gsize i;
 	cairo_scaled_font_t *last_scaled_font = NULL;
@@ -970,7 +958,7 @@ _vte_draw_text_internal (struct _vte_draw *draw,
 
 	g_return_if_fail (font != NULL);
 
-	set_source_color_alpha (draw->cr, color, alpha);
+        gdk_cairo_set_source_rgba (draw->cr, color);
 	cairo_set_operator (draw->cr, CAIRO_OPERATOR_OVER);
 
 	for (i = 0; i < n_requests; i++) {
@@ -1026,7 +1014,7 @@ _vte_draw_text_internal (struct _vte_draw *draw,
 void
 _vte_draw_text (struct _vte_draw *draw,
 	       struct _vte_draw_text_request *requests, gsize n_requests,
-	       const PangoColor *color, guchar alpha, gboolean bold)
+	       const GdkRGBA *color, gboolean bold)
 {
 	g_return_if_fail (draw->started);
 
@@ -1038,13 +1026,14 @@ _vte_draw_text (struct _vte_draw *draw,
 			g_string_append_unichar (string, requests[n].c);
 		}
 		str = g_string_free (string, FALSE);
-		g_printerr ("draw_text (\"%s\", len=%"G_GSIZE_FORMAT", color=(%d,%d,%d,%d), %s)\n",
-				str, n_requests, color->red, color->green, color->blue,
-				alpha, bold ? "bold" : "normal");
+		g_printerr ("draw_text (\"%s\", len=%"G_GSIZE_FORMAT", color=(%.3f,%.3f,%.3f,%.3f), %s)\n",
+				str, n_requests,
+                                color->red, color->green, color->blue, color->alpha,
+				bold ? "bold" : "normal");
 		g_free (str);
 	}
 
-	_vte_draw_text_internal (draw, requests, n_requests, color, alpha, bold);
+	_vte_draw_text_internal (draw, requests, n_requests, color, bold);
 
 	/* handle fonts that lack a bold face by double-striking */
 	if (bold && !_vte_draw_has_bold (draw)) {
@@ -1055,7 +1044,7 @@ _vte_draw_text (struct _vte_draw *draw,
 			requests[i].x++;
 		}
 		_vte_draw_text_internal (draw, requests,
-					   n_requests, color, alpha, FALSE);
+					   n_requests, color, FALSE);
 		/* Now take a step back. */
 		for (i = 0; i < n_requests; i++) {
 			requests[i].x--;
@@ -1080,19 +1069,19 @@ _vte_draw_has_char (struct _vte_draw *draw, vteunistr c, gboolean bold)
 gboolean
 _vte_draw_char (struct _vte_draw *draw,
 	       struct _vte_draw_text_request *request,
-	       const PangoColor *color, guchar alpha, gboolean bold)
+	       const GdkRGBA *color, gboolean bold)
 {
 	gboolean has_char;
 
 	_vte_debug_print (VTE_DEBUG_DRAW,
-			"draw_char ('%c', color=(%d,%d,%d,%d), %s)\n",
+			"draw_char ('%c', color=(%.3f,%.3f,%.3f,%.3f), %s)\n",
 			request->c,
-			color->red, color->green, color->blue,
-			alpha, bold ? "bold" : "normal");
+			color->red, color->green, color->blue, color->alpha,
+			bold ? "bold" : "normal");
 
 	has_char =_vte_draw_has_char (draw, request->c, bold);
 	if (has_char)
-		_vte_draw_text (draw, request, 1, color, alpha, bold);
+		_vte_draw_text (draw, request, 1, color, bold);
 
 	return has_char;
 }
@@ -1100,19 +1089,18 @@ _vte_draw_char (struct _vte_draw *draw,
 void
 _vte_draw_draw_rectangle (struct _vte_draw *draw,
 			 gint x, gint y, gint width, gint height,
-			 const PangoColor *color, guchar alpha)
+			 const GdkRGBA *color)
 {
 	g_return_if_fail (draw->started);
 
 	_vte_debug_print (VTE_DEBUG_DRAW,
-			"draw_rectangle (%d, %d, %d, %d, color=(%d,%d,%d,%d))\n",
+			"draw_rectangle (%d, %d, %d, %d, color=(%.3f,%.3f,%.3f,%.3f))\n",
 			x,y,width,height,
-			color->red, color->green, color->blue,
-			alpha);
+			color->red, color->green, color->blue, color->alpha);
 
 	cairo_set_operator (draw->cr, CAIRO_OPERATOR_OVER);
 	cairo_rectangle (draw->cr, x+VTE_LINE_WIDTH/2., y+VTE_LINE_WIDTH/2., width-VTE_LINE_WIDTH, height-VTE_LINE_WIDTH);
-	set_source_color_alpha (draw->cr, color, alpha);
+	gdk_cairo_set_source_rgba (draw->cr, color);
 	cairo_set_line_width (draw->cr, VTE_LINE_WIDTH);
 	cairo_stroke (draw->cr);
 }
@@ -1120,18 +1108,17 @@ _vte_draw_draw_rectangle (struct _vte_draw *draw,
 void
 _vte_draw_fill_rectangle (struct _vte_draw *draw,
 			 gint x, gint y, gint width, gint height,
-			 const PangoColor *color, guchar alpha)
+			 const GdkRGBA *color)
 {
 	g_return_if_fail (draw->started);
 
 	_vte_debug_print (VTE_DEBUG_DRAW,
-			"draw_fill_rectangle (%d, %d, %d, %d, color=(%d,%d,%d,%d))\n",
+			"draw_fill_rectangle (%d, %d, %d, %d, color=(%.3f,%.3f,%.3f,%.3f))\n",
 			x,y,width,height,
-			color->red, color->green, color->blue,
-			alpha);
+			color->red, color->green, color->blue, color->alpha);
 
 	cairo_set_operator (draw->cr, CAIRO_OPERATOR_OVER);
 	cairo_rectangle (draw->cr, x, y, width, height);
-	set_source_color_alpha (draw->cr, color, alpha);
+        gdk_cairo_set_source_rgba (draw->cr, color);
 	cairo_fill (draw->cr);
 }
diff --git a/src/vtedraw.h b/src/vtedraw.h
index a25e8f1..751df6d 100644
--- a/src/vtedraw.h
+++ b/src/vtedraw.h
@@ -45,7 +45,6 @@ G_BEGIN_DECLS
    returned by pango_layout would be screwed up for Chinese and Japanese
    fonts without Hangul */
 #define VTE_DRAW_DOUBLE_WIDE_IDEOGRAPHS 0x4e00, 0x4e8c, 0x4e09, 0x56db, 0x4e94
-#define VTE_DRAW_OPAQUE 0xff
 #define VTE_DRAW_MAX_LENGTH 1024
 
 struct _vte_draw;
@@ -92,19 +91,19 @@ int _vte_draw_get_char_width(struct _vte_draw *draw, vteunistr c, int columns,
 
 void _vte_draw_text(struct _vte_draw *draw,
 		    struct _vte_draw_text_request *requests, gsize n_requests,
-		    const PangoColor *color, guchar alpha, gboolean);
+		    const GdkRGBA *color, gboolean);
 gboolean _vte_draw_char(struct _vte_draw *draw,
 			struct _vte_draw_text_request *request,
-			const PangoColor *color, guchar alpha, gboolean bold);
+			const GdkRGBA *color, gboolean bold);
 gboolean _vte_draw_has_char(struct _vte_draw *draw, vteunistr c, gboolean bold);
 
 
 void _vte_draw_fill_rectangle(struct _vte_draw *draw,
 			      gint x, gint y, gint width, gint height,
-			      const PangoColor *color, guchar alpha);
+			      const GdkRGBA *color);
 void _vte_draw_draw_rectangle(struct _vte_draw *draw,
 			      gint x, gint y, gint width, gint height,
-			      const PangoColor *color, guchar alpha);
+			      const GdkRGBA *color);
 
 G_END_DECLS
 
diff --git a/src/vteseq.c b/src/vteseq.c
index 669e653..67e8191 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -135,10 +135,11 @@ vte_ucs4_to_utf8 (VteTerminal *terminal, const guchar *in)
 }
 
 static gboolean
-vte_parse_color (const char *spec, GdkColor *color)
+vte_parse_color (const char *spec, GdkRGBA *rgba)
 {
 	gchar *spec_copy = (gchar *) spec;
 	gboolean retval = FALSE;
+        GdkColor color;
 
 	/* gdk_color_parse doesnt handle all XParseColor formats.  It only
 	 * supports the #RRRGGGBBB format, not the rgb:RRR/GGG/BBB format.
@@ -158,18 +159,20 @@ vte_parse_color (const char *spec, GdkColor *color)
 		*cur++ = '\0';
 	}
 
-	retval = gdk_color_parse (spec_copy, color);
-
+	retval = gdk_color_parse (spec_copy, &color);
 	if (spec_copy != spec)
 		g_free (spec_copy);
 
-	return retval;
-}
-
-
-
+        if (!retval)
+                return FALSE;
 
+        rgba->red = color.red / 65535.;
+        rgba->green = color.green / 65535.;
+        rgba->blue = color.blue / 65535.;
+        rgba->alpha = 1.;
 
+        return TRUE;
+}
 
 /* Emit a "deiconify-window" signal. */
 static void
@@ -1807,7 +1810,7 @@ vte_sequence_handler_change_color (VteTerminal *terminal, GValueArray *params)
 {
 	gchar **pairs, *str = NULL;
 	GValue *value;
-	GdkColor color;
+	GdkRGBA color;
 	guint idx, i;
 
 	if (params != NULL && params->n_values > 0) {
@@ -1834,16 +1837,14 @@ vte_sequence_handler_change_color (VteTerminal *terminal, GValueArray *params)
 				continue;
 
 			if (vte_parse_color (pairs[i + 1], &color)) {
-				terminal->pvt->palette[idx].red = color.red;
-				terminal->pvt->palette[idx].green = color.green;
-				terminal->pvt->palette[idx].blue = color.blue;
+				terminal->pvt->palette[idx] = color;
 			} else if (strcmp (pairs[i + 1], "?") == 0) {
 				gchar buf[128];
 				g_snprintf (buf, sizeof (buf),
 					    _VTE_CAP_OSC "4;%u;rgb:%04x/%04x/%04x" BEL, idx,
-					    terminal->pvt->palette[idx].red,
-					    terminal->pvt->palette[idx].green,
-					    terminal->pvt->palette[idx].blue);
+					    (guint) (terminal->pvt->palette[idx].red * 65535.),
+                                            (guint) (terminal->pvt->palette[idx].green * 65535.),
+                                            (guint) (terminal->pvt->palette[idx].blue * 65535.));
 				vte_terminal_feed_child (terminal, buf, -1);
 			}
 		}
@@ -3258,7 +3259,7 @@ vte_sequence_handler_change_cursor_color (VteTerminal *terminal, GValueArray *pa
 {
 	gchar *name = NULL;
 	GValue *value;
-	GdkColor color;
+	GdkRGBA color;
 
 	if (params != NULL && params->n_values > 0) {
 		value = g_value_array_get_nth (params, 0);
@@ -3272,14 +3273,14 @@ vte_sequence_handler_change_cursor_color (VteTerminal *terminal, GValueArray *pa
 			return;
 
 		if (vte_parse_color (name, &color))
-			vte_terminal_set_color_cursor (terminal, &color);
+			vte_terminal_set_color_cursor_rgba (terminal, &color);
 		else if (strcmp (name, "?") == 0) {
 			gchar buf[128];
 			g_snprintf (buf, sizeof (buf),
 				    _VTE_CAP_OSC "12;rgb:%04x/%04x/%04x" BEL,
-				    terminal->pvt->palette[VTE_CUR_BG].red,
-				    terminal->pvt->palette[VTE_CUR_BG].green,
-				    terminal->pvt->palette[VTE_CUR_BG].blue);
+                                    (guint) (terminal->pvt->palette[VTE_CUR_BG].red * 65535.),
+                                    (guint) (terminal->pvt->palette[VTE_CUR_BG].green * 65535.),
+                                    (guint) (terminal->pvt->palette[VTE_CUR_BG].blue * 65535.));
 			vte_terminal_feed_child (terminal, buf, -1);
 		}
 



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