From: Ira W. Snyder Date: Mon, 14 Jan 2008 08:24:43 +0000 (-0800) Subject: [Terminal] Add transparency support X-Git-Url: https://irasnyder.com/gitweb/?a=commitdiff_plain;h=880eae5226f60d49537200834627fd5af6ee89ae;p=tilda-gobject.git [Terminal] Add transparency support This adds the ability to specify transparency. With the earlier TildaWindow changes, this should give true transparency in a composited environment, but falls back to fake transparency if true transparency is not available. --- diff --git a/tilda-terminal.c b/tilda-terminal.c index d1533db..ec76061 100644 --- a/tilda-terminal.c +++ b/tilda-terminal.c @@ -175,6 +175,35 @@ tilda_terminal_window_title_changed_cb (GtkWidget *widget, gpointer data) g_free (new_title); } +/** + * Set the given TildaTerminal to the appropriate transparency level + * based on the self->transparency_percent member. */ +static void +tilda_terminal_set_transparent (TildaTerminal *self) +{ + TildaWindow *parent_window = TILDA_WINDOW(self->parent_window); + gdouble temp; + + /* Convert the transparency to VTE's format */ + temp = ((gdouble) self->transparency_percent) / 100.0; + + if (self->transparency_percent > 0) + { + vte_terminal_set_background_saturation (VTE_TERMINAL(self->vte_term), temp); + vte_terminal_set_opacity (VTE_TERMINAL(self->vte_term), (1.0 - temp) * 0xffff); + + /* Use fake transparency if necessary */ + vte_terminal_set_background_transparent (VTE_TERMINAL(self->vte_term), + !parent_window->have_real_transparency); + return; + } + + /* Turn off transparency */ + vte_terminal_set_background_saturation (VTE_TERMINAL(self->vte_term), 0); + vte_terminal_set_opacity (VTE_TERMINAL(self->vte_term), 0xffff); + vte_terminal_set_background_transparent (VTE_TERMINAL(self->vte_term), FALSE); +} + /******************************************************************************* * All GObject stuff is below. You probably don't need to change this... ******************************************************************************/ @@ -298,6 +327,7 @@ tilda_terminal_set_property (GObject *object, case TILDA_TERMINAL_TRANSPARENCY_PERCENT: self->transparency_percent = g_value_get_int (value); + tilda_terminal_set_transparent (self); g_print ("terminal transp percent: %d\n", self->transparency_percent); break;