Commit f3f8eafd authored by Behdad Esfahbod's avatar Behdad Esfahbod Committed by Behdad Esfahbod
Browse files

Bug 345377 – real transparency Patch from Kristian Høgsberg <krh

2006-07-10  Behdad Esfahbod  <behdad@gnome.org>

        Bug 345377 – real transparency
        Patch from Kristian Høgsberg <krh redhat.com>

        * doc/reference/tmpl/vte.sgml:
        * doc/reference/vte-sections.txt:
        * python/vte.defs:
        * src/vte-private.h:
        * src/vte.c (vte_terminal_set_opacity), (vte_terminal_init),
        (vte_terminal_background_update):
        * src/vte.h:
        * src/vteapp.c (main):
        * src/vtedraw.c (_vte_draw_set_background_color):
        * src/vtedraw.h:
        * src/vteft2.c (_vte_ft2_set_background_color):
        * src/vtegl.c (_vte_gl_set_background_color):
        * src/vtepango.c (_vte_pango_set_background_color):
        * src/vtepangox.c (_vte_pango_x_set_background_color):
        * src/vteskel.c (_vte_skel_set_background_color):
        * src/vtexft.c (_vte_xft_create), (_vte_xft_set_background_color),
        (_vte_xft_clear):
        Add vte_terminal_set_opacity().
parent 1eded1ef
2006-07-10 Behdad Esfahbod <behdad@gnome.org>
Bug 345377 real transparency
Patch from Kristian Høgsberg <krh redhat.com>
* doc/reference/tmpl/vte.sgml:
* doc/reference/vte-sections.txt:
* python/vte.defs:
* src/vte-private.h:
* src/vte.c (vte_terminal_set_opacity), (vte_terminal_init),
(vte_terminal_background_update):
* src/vte.h:
* src/vteapp.c (main):
* src/vtedraw.c (_vte_draw_set_background_color):
* src/vtedraw.h:
* src/vteft2.c (_vte_ft2_set_background_color):
* src/vtegl.c (_vte_gl_set_background_color):
* src/vtepango.c (_vte_pango_set_background_color):
* src/vtepangox.c (_vte_pango_x_set_background_color):
* src/vteskel.c (_vte_skel_set_background_color):
* src/vtexft.c (_vte_xft_create), (_vte_xft_set_background_color),
(_vte_xft_clear):
Add vte_terminal_set_opacity().
2006-07-05 Behdad Esfahbod <behdad@gnome.org>
* src/Makefile.am: Allow _vte_debug_.* into exported symbols.
......
......@@ -529,6 +529,15 @@ keys.
@terminal:
<!-- ##### FUNCTION vte_terminal_set_opacity ##### -->
<para>
</para>
@terminal:
@opacity:
<!-- ##### FUNCTION vte_terminal_set_background_image ##### -->
<para>
......
......@@ -32,6 +32,7 @@ vte_terminal_set_color_cursor
vte_terminal_set_color_highlight
vte_terminal_set_colors
vte_terminal_set_default_colors
vte_terminal_set_opacity
vte_terminal_set_background_image
vte_terminal_set_background_image_file
vte_terminal_set_background_saturation
......
......@@ -6,7 +6,7 @@ import vte
# FIXME: figure out why we don't get a PID here.
def exited_cb(terminal):
gtk.mainquit()
gtk.main_quit()
def nuke(button, (box, terminal)):
box.remove(terminal)
......
......@@ -17,7 +17,7 @@ def restore_cb(terminal):
print text
def child_exited_cb(terminal):
gtk.mainquit()
gtk.main_quit()
if __name__ == '__main__':
child_pid = -1;
......
......@@ -286,6 +286,15 @@
(return-type "none")
)
(define-method set_opacity
(of-object "VteTerminal")
(c-name "vte_terminal_set_opacity")
(return-type "none")
(parameters
'("guint16" "opacity")
)
)
(define-method set_background_image
(of-object "VteTerminal")
(c-name "vte_terminal_set_background_image")
......
......@@ -339,6 +339,7 @@ struct _VteTerminalPrivate {
guint bg_update_tag;
GdkColor bg_tint_color;
long bg_saturation; /* out of VTE_SATURATION_MAX */
guint16 bg_opacity;
/* Key modifiers. */
GdkModifierType modifiers;
......
......@@ -2097,6 +2097,21 @@ vte_terminal_set_colors(VteTerminal *terminal,
terminal->pvt->palette_initialized = TRUE;
}
/**
* vte_terminal_set_opacity
* @terminal: a #VteTerminal
* @opacity: the new opacity
*
* Sets the opacity of the terminal background, were 0 means completely
* transparent and 65535 means completely opaque.
*
*/
void
vte_terminal_set_opacity(VteTerminal *terminal, guint16 opacity)
{
terminal->pvt->bg_opacity = opacity;
}
/**
* vte_terminal_set_default_colors:
* @terminal: a #VteTerminal
......@@ -6831,6 +6846,7 @@ vte_terminal_init(VteTerminal *terminal, gpointer *klass)
pvt->bg_tint_color.green = 0;
pvt->bg_tint_color.blue = 0;
pvt->bg_saturation = 0.4 * VTE_SATURATION_MAX;
pvt->bg_opacity = 0xffff;
pvt->block_mode = FALSE;
pvt->had_block_mode = FALSE;
......@@ -10187,7 +10203,8 @@ vte_terminal_background_update(gpointer data)
gdk_rgb_find_color(colormap, &bgcolor);
}
gdk_window_set_background(widget->window, &bgcolor);
_vte_draw_set_background_color(terminal->pvt->draw, &bgcolor);
_vte_draw_set_background_color(terminal->pvt->draw, &bgcolor,
terminal->pvt->bg_opacity);
/* If we're transparent, and either have no root image or are being
* told to update it, get a new copy of the root window. */
......
......@@ -272,6 +272,7 @@ void vte_terminal_set_background_saturation(VteTerminal *terminal,
double saturation);
void vte_terminal_set_background_transparent(VteTerminal *terminal,
gboolean transparent);
void vte_terminal_set_opacity(VteTerminal *terminal, guint16 opacity);
/* Set whether or not the cursor blinks. */
void vte_terminal_set_cursor_blinks(VteTerminal *terminal, gboolean blink);
......
......@@ -388,6 +388,8 @@ add_weak_pointer(GObject *object, GtkWidget **target)
int
main(int argc, char **argv)
{
GdkScreen *screen;
GdkColormap *colormap;
GtkWidget *window, *hbox, *scrollbar, *widget;
char *env_add[] = {
#ifdef VTE_DEBUG
......@@ -567,6 +569,12 @@ main(int argc, char **argv)
g_signal_connect(G_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(deleted_and_quit), window);
/* Set ARGB colormap */
screen = gtk_widget_get_screen (window);
colormap = gdk_screen_get_rgba_colormap (screen);
if (colormap)
gtk_widget_set_colormap(GTK_WIDGET (window), colormap);
/* Create a box to hold everything. */
hbox = gtk_hbox_new(0, FALSE);
gtk_container_add(GTK_CONTAINER(window), hbox);
......@@ -658,6 +666,7 @@ main(int argc, char **argv)
}
vte_terminal_set_background_tint_color(VTE_TERMINAL(widget), &tint);
vte_terminal_set_colors(VTE_TERMINAL(widget), &fore, &back, NULL, 0);
vte_terminal_set_opacity(VTE_TERMINAL(widget), 0xcccc);
if (highlight_set) {
vte_terminal_set_color_highlight(VTE_TERMINAL(widget),
&highlight);
......
......@@ -168,11 +168,13 @@ _vte_draw_end(struct _vte_draw *draw)
}
void
_vte_draw_set_background_color(struct _vte_draw *draw, GdkColor *color)
_vte_draw_set_background_color(struct _vte_draw *draw,
GdkColor *color,
guint16 opacity)
{
g_return_if_fail(draw->impl != NULL);
g_return_if_fail(draw->impl->set_background_color != NULL);
draw->impl->set_background_color(draw, color);
draw->impl->set_background_color(draw, color, opacity);
}
void
......
......@@ -57,7 +57,7 @@ struct _vte_draw_impl {
GdkColormap* (*get_colormap)(struct _vte_draw *draw);
void (*start)(struct _vte_draw *draw);
void (*end)(struct _vte_draw *draw);
void (*set_background_color)(struct _vte_draw *, GdkColor *);
void (*set_background_color)(struct _vte_draw *, GdkColor *, guint16);
void (*set_background_image)(struct _vte_draw *,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
......@@ -115,7 +115,9 @@ void _vte_draw_end(struct _vte_draw *draw);
/* Set the background color, a background pixbuf (if you want transparency,
you'll have to do that yourself), and clear an area to the default. */
void _vte_draw_set_background_color(struct _vte_draw *draw, GdkColor *color);
void _vte_draw_set_background_color(struct _vte_draw *draw,
GdkColor *color,
guint16 opacity);
void _vte_draw_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
......
......@@ -148,7 +148,7 @@ _vte_ft2_end(struct _vte_draw *draw)
}
static void
_vte_ft2_set_background_color(struct _vte_draw *draw, GdkColor *color)
_vte_ft2_set_background_color(struct _vte_draw *draw, GdkColor *color, guint16 opacity)
{
struct _vte_ft2_data *data;
data = (struct _vte_ft2_data*) draw->impl_data;
......
......@@ -259,7 +259,7 @@ _vte_gl_end(struct _vte_draw *draw)
}
static void
_vte_gl_set_background_color(struct _vte_draw *draw, GdkColor *color)
_vte_gl_set_background_color(struct _vte_draw *draw, GdkColor *color, guint16 opacity)
{
struct _vte_gl_data *data;
......
......@@ -171,7 +171,7 @@ _vte_pango_end(struct _vte_draw *draw)
}
static void
_vte_pango_set_background_color(struct _vte_draw *draw, GdkColor *color)
_vte_pango_set_background_color(struct _vte_draw *draw, GdkColor *color, guint16 opacity)
{
struct _vte_pango_data *data;
data = (struct _vte_pango_data*) draw->impl_data;
......
......@@ -189,7 +189,7 @@ _vte_pango_x_end(struct _vte_draw *draw)
}
static void
_vte_pango_x_set_background_color(struct _vte_draw *draw, GdkColor *color)
_vte_pango_x_set_background_color(struct _vte_draw *draw, GdkColor *color, guint16 opacity)
{
struct _vte_pango_x_data *data;
data = (struct _vte_pango_x_data*) draw->impl_data;
......
......@@ -33,6 +33,7 @@ struct _vte_skel_data
GdkPixmap *pixmap;
gint pixmapw, pixmaph;
gint scrollx, scrolly;
guint16 opacity;
};
static gboolean
......@@ -106,11 +107,12 @@ _vte_skel_end(struct _vte_draw *draw)
}
static void
_vte_skel_set_background_color(struct _vte_draw *draw, GdkColor *color)
_vte_skel_set_background_color(struct _vte_draw *draw, GdkColor *color, guint16 opacity)
{
struct _vte_skel_data *data;
data = (struct _vte_skel_data*) draw->impl_data;
data->color = *color;
data->opacity = opacity;
}
static void
......
......@@ -60,6 +60,7 @@ struct _vte_xft_data
XftDraw *draw;
GC gc;
GdkColor color;
guint16 opacity;
GdkPixmap *pixmap;
Pixmap xpixmap;
gint pixmapw, pixmaph;
......@@ -313,6 +314,7 @@ _vte_xft_create(struct _vte_draw *draw, GtkWidget *widget)
data->draw = NULL;
data->gc = NULL;
memset(&data->color, 0, sizeof(data->color));
data->opacity = 0xffff;
data->pixmap = NULL;
data->xpixmap = -1;
data->pixmapw = data->pixmaph = -1;
......@@ -416,11 +418,13 @@ _vte_xft_end(struct _vte_draw *draw)
}
static void
_vte_xft_set_background_color(struct _vte_draw *draw, GdkColor *color)
_vte_xft_set_background_color(struct _vte_draw *draw, GdkColor *color,
guint16 opacity)
{
struct _vte_xft_data *data;
data = (struct _vte_xft_data*) draw->impl_data;
data->color = *color;
data->opacity = opacity;
}
static void
......@@ -469,10 +473,10 @@ _vte_xft_clear(struct _vte_draw *draw,
if (!GDK_IS_PIXMAP(data->pixmap) ||
(data->pixmapw <= 0) ||
(data->pixmaph <= 0)) {
rcolor.red = data->color.red;
rcolor.green = data->color.green;
rcolor.blue = data->color.blue;
rcolor.alpha = 0xffff;
rcolor.red = data->color.red * data->opacity / 0xffff;
rcolor.green = data->color.green * data->opacity / 0xffff;
rcolor.blue = data->color.blue * data->opacity / 0xffff;
rcolor.alpha = data->opacity;
if (XftColorAllocValue(data->display, data->visual,
data->colormap, &rcolor, &ftcolor)) {
XftDrawRect(data->draw, &ftcolor,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment