From 71dd12d1769059f05f5244b61c595f47b086589d Mon Sep 17 00:00:00 2001
From: gnunn1 <gerald.b.nunn@gmail.com>
Date: Sat, 8 Oct 2016 20:24:43 -0400
Subject: [PATCH] add DisableBGDraw property

---
 src/vte.cc            | 20 ++++++++++++++++---
 src/vte/vteterminal.h |  7 +++++++
 src/vtegtk.cc         | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/vtegtk.hh         |  1 +
 src/vteinternal.hh    |  2 ++
 5 files changed, 80 insertions(+), 3 deletions(-)

diff --git a/src/vte.cc b/src/vte.cc
index 02bea92..8db45af 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -8079,6 +8079,7 @@ VteTerminalPrivate::VteTerminalPrivate(VteTerminal *t) :
 	vte_terminal_set_delete_binding(m_terminal, VTE_ERASE_AUTO);
 	m_meta_sends_escape = TRUE;
 	m_audible_bell = TRUE;
+	m_disable_bg_draw = FALSE;
 	m_bell_margin = 10;
 	m_allow_bold = TRUE;
         m_deccolm_mode = FALSE;
@@ -9723,9 +9724,11 @@ VteTerminalPrivate::widget_draw(cairo_t *cr)
 	/* Designate the start of the drawing operation and clear the area. */
 	_vte_draw_set_cairo(m_draw, cr);
 
-	_vte_draw_clear (m_draw, 0, 0,
-			 allocated_width, allocated_height,
-                         get_color(VTE_DEFAULT_BG), m_background_alpha);
+	if (!m_disable_bg_draw) {
+		_vte_draw_clear (m_draw, 0, 0,
+				 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. */
@@ -9949,6 +9952,17 @@ VteTerminalPrivate::set_audible_bell(bool setting)
 }
 
 bool
+VteTerminalPrivate::set_disable_bg_draw(bool setting)
+{
+        if (setting == m_disable_bg_draw)
+                return false;
+
+	m_disable_bg_draw = setting;
+	invalidate_all();
+        return true;
+}
+
+bool
 VteTerminalPrivate::set_allow_bold(bool setting)
 {
         if (setting == m_allow_bold)
diff --git a/src/vte/vteterminal.h b/src/vte/vteterminal.h
index 38ea8c3..668cf9c 100644
--- a/src/vte/vteterminal.h
+++ b/src/vte/vteterminal.h
@@ -452,6 +452,13 @@ gboolean vte_terminal_write_contents_sync (VteTerminal *terminal,
                                            GCancellable *cancellable,
                                            GError **error) _VTE_GNUC_NONNULL(1) _VTE_GNUC_NONNULL(2);
 
+/* Set disable background draw. */
+_VTE_PUBLIC
+void vte_terminal_set_disable_bg_draw(VteTerminal *terminal,
+                                   gboolean is_disabled) _VTE_GNUC_NONNULL(1);
+_VTE_PUBLIC
+gboolean vte_terminal_get_disable_bg_draw(VteTerminal *terminal);
+
 G_END_DECLS
 
 #endif /* __VTE_VTE_TERMINAL_H__ */
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 6ea47f9..dcd1e2d 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -458,6 +458,9 @@ vte_terminal_get_property (GObject *object,
                 case PROP_DELETE_BINDING:
                         g_value_set_enum (value, impl->m_delete_binding);
                         break;
+                case PROP_DISABLE_BG_DRAW:
+                        g_value_set_boolean (value, vte_terminal_get_disable_bg_draw (terminal));
+                        break;
                 case PROP_ENCODING:
                         g_value_set_string (value, vte_terminal_get_encoding (terminal));
                         break;
@@ -547,6 +550,9 @@ vte_terminal_set_property (GObject *object,
                 case PROP_DELETE_BINDING:
                         vte_terminal_set_delete_binding (terminal, (VteEraseBinding)g_value_get_enum (value));
                         break;
+                case PROP_DISABLE_BG_DRAW:
+                        vte_terminal_set_disable_bg_draw (terminal, g_value_get_boolean (value));
+                        break;
                 case PROP_ENCODING:
                         vte_terminal_set_encoding (terminal, g_value_get_string (value), NULL);
                         break;
@@ -1309,6 +1315,18 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                    (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
 
         /**
+         * VteTerminal:disable_bg_draw:
+         *
+         * Controls whether or not the terminal will draw the background,
+         * if disabled the responsibility is deferred to the application via
+         * the draw signal
+         */
+        pspecs[PROP_DISABLE_BG_DRAW] =
+                g_param_spec_boolean ("disable-bg-draw", NULL, NULL,
+                                      TRUE,
+                                      (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY));
+
+        /**
          * VteTerminal:font-scale:
          *
          * The terminal's font scale.
@@ -3044,6 +3062,41 @@ vte_terminal_set_delete_binding(VteTerminal *terminal,
 }
 
 /**
+ * vte_terminal_get_disable_bg_draw:
+ * @terminal: a #VteTerminal
+ *
+ * Determines whether the terminal will render the background or
+ * defer it to the application via the draw signal.
+ *
+ * Returns: %TRUE if background draw is disabled, %FALSE if not
+ */
+gboolean
+vte_terminal_get_disable_bg_draw(VteTerminal *terminal)
+{
+	g_return_val_if_fail(VTE_IS_TERMINAL(terminal), FALSE);
+	return IMPL(terminal)->m_disable_bg_draw;
+}
+
+/**
+ * vte_terminal_set_disable_bg_draw:
+ * @terminal: a #VteTerminal
+ * @is_disabled: %TRUE if the terminal should not draw the background
+ *
+ * Controls whether or not the terminal will beep when the child outputs the
+ * "bl" sequence.
+ */
+void
+vte_terminal_set_disable_bg_draw(VteTerminal *terminal,
+                              gboolean is_disabled)
+{
+        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+
+        if (IMPL(terminal)->set_disable_bg_draw(is_disabled != FALSE))
+                g_object_notify_by_pspec(G_OBJECT(terminal), pspecs[PROP_DISABLE_BG_DRAW]);
+}
+
+
+/**
  * vte_terminal_get_encoding:
  * @terminal: a #VteTerminal
  *
diff --git a/src/vtegtk.hh b/src/vtegtk.hh
index 5fd8c11..fcc69e7 100644
--- a/src/vtegtk.hh
+++ b/src/vtegtk.hh
@@ -71,6 +71,7 @@ enum {
         PROP_CURRENT_DIRECTORY_URI,
         PROP_CURRENT_FILE_URI,
         PROP_DELETE_BINDING,
+        PROP_DISABLE_BG_DRAW,
         PROP_ENCODING,
         PROP_FONT_DESC,
         PROP_FONT_SCALE,
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 1ef0cea..5384607 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -389,6 +389,7 @@ public:
         VteEraseBinding m_delete_binding;
         gboolean m_meta_sends_escape;
         gboolean m_audible_bell;
+        gboolean m_disable_bg_draw;
         gboolean m_margin_bell;
         guint m_bell_margin;
         gboolean m_allow_bold;
@@ -1130,6 +1131,7 @@ public:
         bool set_cursor_shape(VteCursorShape shape);
         bool set_cursor_style(VteCursorStyle style);
         bool set_delete_binding(VteEraseBinding binding);
+        bool set_disable_bg_draw(bool setting);
         bool set_encoding(char const* codeset);
         bool set_font_desc(PangoFontDescription const* desc);
         bool set_font_scale(double scale);
-- 
2.10.0

