[vte] widget: Simplify background handling
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] widget: Simplify background handling
- Date: Tue, 15 Dec 2015 19:39:52 +0000 (UTC)
commit 0ecfbc1c05960df2878360ff78add2f496d555a0
Author: Christian Persch <chpe gnome org>
Date: Tue Dec 15 20:38:41 2015 +0100
widget: Simplify background handling
src/vte.cc | 59 +++++----------------------------------------------
src/vtedraw.cc | 46 +++++++++++-----------------------------
src/vtedraw.hh | 6 +---
src/vteinternal.hh | 2 -
4 files changed, 21 insertions(+), 92 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index e37ed0a..d226648 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -2477,12 +2477,6 @@ VteTerminalPrivate::set_color(int entry,
if (!widget_realized())
return;
- /* If we're setting the background color, set the background color
- * on the widget as well. */
- if (entry == VTE_DEFAULT_BG) {
- widget_background_update();
- }
-
/* and redraw */
if (entry == VTE_CURSOR_BG || entry == VTE_CURSOR_FG)
invalidate_cursor_once();
@@ -2512,12 +2506,6 @@ VteTerminalPrivate::reset_color(int entry,
if (!widget_realized())
return;
- /* If we're setting the background color, set the background color
- * on the widget as well. */
- if (entry == VTE_DEFAULT_BG) {
- widget_background_update();
- }
-
/* and redraw */
if (entry == VTE_CURSOR_BG || entry == VTE_CURSOR_FG)
invalidate_cursor_once();
@@ -2536,7 +2524,8 @@ VteTerminalPrivate::set_background_alpha(double alpha)
_vte_debug_print(VTE_DEBUG_MISC,
"Setting background alpha to %.3f\n", alpha);
m_background_alpha = alpha;
- widget_background_update();
+
+ invalidate_all();
return true;
}
@@ -8694,10 +8683,6 @@ VteTerminalPrivate::widget_realize()
widget_style_updated();
ensure_font();
-
- /* Set up the background, *now*. */
- // FIXMEchpe this is obsolete
- widget_background_update();
}
static inline void
@@ -9723,7 +9708,8 @@ VteTerminalPrivate::paint_im_preedit_string()
col * width,
row_to_pixel(m_cursor.row),
width * columns,
- height);
+ height,
+ get_color(VTE_DEFAULT_BG), m_background_alpha);
fore = m_color_defaults.attr.fore;
back = m_color_defaults.attr.back;
draw_cells_with_attributes(
@@ -9777,7 +9763,8 @@ VteTerminalPrivate::widget_draw(cairo_t *cr)
_vte_draw_set_cairo(m_draw, cr);
_vte_draw_clear (m_draw, 0, 0,
- allocated_width, allocated_height);
+ allocated_width, allocated_height,
+ get_color(VTE_DEFAULT_BG), m_background_alpha);
/* Clip vertically, for the sake of smooth scrolling. We want the top and bottom paddings to be
unused.
* Don't clip horizontally so that antialiasing can legally overflow to the right padding. */
@@ -10039,40 +10026,6 @@ VteTerminalPrivate::set_rewrap_on_resize(bool rewrap)
return true;
}
-/* Set up whatever background we wanted. */
-// FIXMEchpe this is mostly obsolete
-void
-VteTerminalPrivate::widget_background_update()
-{
- vte::color::rgb const* entry;
- GdkRGBA color;
-
- /* If we're not realized yet, don't worry about it, because we get
- * called when we realize. */
- if (!widget_realized()) {
- return;
- }
-
- _vte_debug_print(VTE_DEBUG_MISC|VTE_DEBUG_EVENTS,
- "Updating background color.\n");
-
- entry = get_color(VTE_DEFAULT_BG);
- _vte_debug_print(VTE_DEBUG_STYLE,
- "Setting background color to (%d, %d, %d, %.3f).\n",
- entry->red, entry->green, entry->blue,
- m_background_alpha);
-
- color.red = entry->red / 65535.;
- color.green = entry->green / 65535.;
- color.blue = entry->blue / 65535.;
- color.alpha = m_background_alpha;
-
- _vte_draw_set_background_solid(m_draw, &color);
-
- /* Force a redraw for everything. */
- invalidate_all();
-}
-
void
VteTerminalPrivate::update_cursor_blinks()
{
diff --git a/src/vtedraw.cc b/src/vtedraw.cc
index 3fe7fd1..026a887 100644
--- a/src/vtedraw.cc
+++ b/src/vtedraw.cc
@@ -743,7 +743,6 @@ guint _vte_draw_get_style(gboolean bold, gboolean italic) {
struct _vte_draw {
struct font_info *fonts[4];
- cairo_pattern_t *bg_pattern;
cairo_t *cr;
};
@@ -767,11 +766,6 @@ _vte_draw_free (struct _vte_draw *draw)
gint style;
_vte_debug_print (VTE_DEBUG_DRAW, "draw_free\n");
- if (draw->bg_pattern != NULL) {
- cairo_pattern_destroy (draw->bg_pattern);
- draw->bg_pattern = NULL;
- }
-
/* Free all fonts (make sure to destroy every font only once)*/
for (style = 3; style >= 0; style--) {
if (draw->fonts[style] != NULL &&
@@ -799,31 +793,30 @@ _vte_draw_set_cairo (struct _vte_draw *draw,
}
}
-void
-_vte_draw_set_background_solid(struct _vte_draw *draw,
- const GdkRGBA *color)
+static void
+_vte_draw_set_source_color_alpha (struct _vte_draw *draw,
+ vte::color::rgb const* color,
+ double alpha)
{
- if (draw->bg_pattern)
- cairo_pattern_destroy (draw->bg_pattern);
-
- draw->bg_pattern = cairo_pattern_create_rgba (color->red,
- color->green,
- color->blue,
- color->alpha);
+ g_assert(draw->cr);
+ cairo_set_source_rgba (draw->cr,
+ color->red / 65535.,
+ color->green / 65535.,
+ color->blue / 65535.,
+ alpha);
}
void
-_vte_draw_clear (struct _vte_draw *draw, gint x, gint y, gint width, gint height)
+_vte_draw_clear (struct _vte_draw *draw, gint x, gint y, gint width, gint height,
+ vte::color::rgb const* color, double alpha)
{
- g_return_if_fail (draw->bg_pattern != NULL);
-
_vte_debug_print (VTE_DEBUG_DRAW, "draw_clear (%d, %d, %d, %d)\n",
x,y,width, height);
g_assert(draw->cr);
cairo_rectangle (draw->cr, x, y, width, height);
cairo_set_operator (draw->cr, CAIRO_OPERATOR_SOURCE);
- cairo_set_source (draw->cr, draw->bg_pattern);
+ _vte_draw_set_source_color_alpha(draw, color, alpha);
cairo_fill (draw->cr);
}
@@ -925,19 +918,6 @@ _vte_draw_has_bold (struct _vte_draw *draw, guint style)
return (draw->fonts[style ^ VTE_DRAW_BOLD] != draw->fonts[style]);
}
-static void
-_vte_draw_set_source_color_alpha (struct _vte_draw *draw,
- vte::color::rgb const* color,
- double alpha)
-{
- g_assert(draw->cr);
- cairo_set_source_rgba (draw->cr,
- color->red / 65535.,
- color->green / 65535.,
- color->blue / 65535.,
- alpha);
-}
-
/* Check if a unicode character is actually a graphic character we draw
* ourselves to handle cases where fonts don't have glyphs for them. */
static gboolean
diff --git a/src/vtedraw.hh b/src/vtedraw.hh
index 36f3d75..cc17a05 100644
--- a/src/vtedraw.hh
+++ b/src/vtedraw.hh
@@ -56,11 +56,9 @@ void _vte_draw_free(struct _vte_draw *draw);
void _vte_draw_set_cairo(struct _vte_draw *draw,
cairo_t *cr);
-void _vte_draw_set_background_solid(struct _vte_draw *draw,
- const GdkRGBA *color);
-
void _vte_draw_clear(struct _vte_draw *draw,
- gint x, gint y, gint width, gint height);
+ gint x, gint y, gint width, gint height,
+ vte::color::rgb const* color, double alpha);
void _vte_draw_set_text_font(struct _vte_draw *draw,
GtkWidget *widget,
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 0b11d22..6804db1 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -774,8 +774,6 @@ public:
void set_tabstop(int column);
void set_default_tabstops();
- void widget_background_update();
-
void process_incoming();
void match_contents_clear();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]