Commit 0e8b0b54 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

add a singleton object for managing copies of background images, either

* src/vtebg.c, src/vtebg.h: add a singleton object for managing copies of
	background images, either the desktop background, an in-memory pixbuf,
	or an on-disk file, with tinting.  Using a single store for this stuff
	lets multiple widgets share images and should reduce both CPU and
	memory consumption in applications which create more than one
	VteTerminal instance with similar settings.
* src/vtedraw.c, src/vtedraw.h: adapt the set_background_pixbuf() interface to
	the vtebg method and rename to set_background_image().
* src/vteft2.c, src/vtegl.c, src/vtepango.c, src/vtepangox.c, src/vteskel.c,
	src/vtexft.c: update to work with newer vtebg/vtedraw interfaces.
* src/vte.c(vte_terminal_filter_property_changes): remove in favor of vtebg
	method.  Manage background state for vtebg.
parent 28a56869
2003-05-01 nalin
* src/vtebg.c, src/vtebg.h: add a singleton object for managing
copies of background images, either the desktop background, an
in-memory pixbuf, or an on-disk file, with tinting. Using a single
store for this stuff lets multiple widgets share images and should
reduce both CPU and memory consumption in applications which create
more than one VteTerminal instance with similar settings.
* src/vtedraw.c, src/vtedraw.h: adapt the set_background_pixbuf()
interface to the vtebg method and rename to set_background_image().
* src/vteft2.c, src/vtegl.c, src/vtepango.c, src/vtepangox.c,
src/vteskel.c, src/vtexft.c: update to work with newer vtebg/vtedraw
interfaces.
* src/vte.c(vte_terminal_filter_property_changes): remove in favor
of vtebg method. Manage background state for vtebg.
2003-05-01 Kang Jeong-Hee <Keizi@mail.co.kr>
* doc/reference/Makefile.am: s/index.sgml/index.html/.
There's no index.sgml in html directory, but a index.html.
......
......@@ -55,6 +55,8 @@ libvte_la_SOURCES = \
trie.h \
vte.c \
vte.h \
vtebg.c \
vtebg.h \
vteaccess.c \
vteaccess.h \
vtedraw.c \
......
......@@ -733,7 +733,9 @@ _vte_iso2022_state_set_codeset(struct _vte_iso2022_state *state,
codeset, state->target_codeset);
return;
}
g_iconv_close(state->conv);
if (state->conv != (GIConv) -1) {
g_iconv_close(state->conv);
}
state->codeset = g_quark_to_string(g_quark_from_string(codeset));
state->conv = conv;
}
......@@ -747,8 +749,10 @@ _vte_iso2022_state_get_codeset(struct _vte_iso2022_state *state)
void
_vte_iso2022_state_free(struct _vte_iso2022_state *state)
{
g_iconv_close(state->conv);
state->conv = NULL;
if (state->conv != ((GIConv) -1)) {
g_iconv_close(state->conv);
}
state->conv = (GIConv) -1;
state->native_codeset = state->utf8_codeset = state->codeset = NULL;
state->target_codeset = NULL;
state->g[3] = 'B';
......
This diff is collapsed.
......@@ -89,11 +89,7 @@ char_size_changed(GtkWidget *widget, guint width, guint height, gpointer data)
static void
destroy_and_quit(GtkWidget *widget, gpointer data)
{
if (GTK_IS_CONTAINER(data)) {
gtk_container_remove(GTK_CONTAINER(data), widget);
} else {
gtk_widget_destroy(widget);
}
gtk_widget_destroy(GTK_WIDGET(data));
gtk_main_quit();
}
static void
......@@ -520,9 +516,9 @@ main(int argc, char **argv)
/* Connect to the "eof" signal to quit when the session ends. */
g_signal_connect(G_OBJECT(widget), "eof",
G_CALLBACK(destroy_and_quit_eof), widget);
G_CALLBACK(destroy_and_quit_eof), window);
g_signal_connect(G_OBJECT(widget), "child-exited",
G_CALLBACK(destroy_and_quit_exited), widget);
G_CALLBACK(destroy_and_quit_exited), window);
/* Connect to the "status-line-changed" signal. */
g_signal_connect(G_OBJECT(widget), "status-line-changed",
......
......@@ -128,9 +128,19 @@ _vte_draw_get_visual(struct _vte_draw *draw)
GdkColormap *
_vte_draw_get_colormap(struct _vte_draw *draw)
{
GdkColormap *colormap;
g_return_val_if_fail(draw->impl != NULL, NULL);
g_return_val_if_fail(draw->impl->get_colormap != NULL, NULL);
return draw->impl->get_colormap(draw);
colormap = draw->impl->get_colormap(draw);
if (colormap) {
return colormap;
}
#if GTK_CHECK_VERSION(2,2,0)
colormap = gdk_screen_get_default_colormap(gdk_screen_get_default());
#else
colormap = gdk_colormap_get_system();
#endif
return colormap;
}
void
......@@ -164,11 +174,17 @@ _vte_draw_set_background_color(struct _vte_draw *draw, GdkColor *color)
}
void
_vte_draw_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
_vte_draw_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *filename,
const GdkColor *color,
double saturation)
{
g_return_if_fail(draw->impl != NULL);
g_return_if_fail(draw->impl->set_background_pixbuf != NULL);
draw->impl->set_background_pixbuf(draw, pixbuf);
g_return_if_fail(draw->impl->set_background_image != NULL);
draw->impl->set_background_image(draw, type, pixbuf, filename,
color, saturation);
}
void
_vte_draw_clear(struct _vte_draw *draw, gint x, gint y, gint width, gint height)
......
......@@ -25,6 +25,7 @@
#include <glib.h>
#include <gtk/gtk.h>
#include "vtebg.h"
G_BEGIN_DECLS
......@@ -57,7 +58,12 @@ struct _vte_draw_impl {
void (*start)(struct _vte_draw *draw);
void (*end)(struct _vte_draw *draw);
void (*set_background_color)(struct _vte_draw *, GdkColor *);
void (*set_background_pixbuf)(struct _vte_draw *, GdkPixbuf *);
void (*set_background_image)(struct _vte_draw *,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *file,
const GdkColor *color,
double saturation);
void (*clear)(struct _vte_draw *, gint, gint, gint, gint);
void (*set_text_font)(struct _vte_draw *, const PangoFontDescription *);
int (*get_text_width)(struct _vte_draw *);
......@@ -102,7 +108,12 @@ 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_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf);
void _vte_draw_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *file,
const GdkColor *color,
double saturation);
void _vte_draw_clear(struct _vte_draw *draw,
gint x, gint y, gint width, gint height);
......
......@@ -26,6 +26,7 @@
#include <glib.h>
#include <fontconfig/fontconfig.h>
#include "debug.h"
#include "vtebg.h"
#include "vtedraw.h"
#include "vtefc.h"
#include "vteglyph.h"
......@@ -156,7 +157,12 @@ _vte_ft2_set_background_color(struct _vte_draw *draw, GdkColor *color)
}
static void
_vte_ft2_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
_vte_ft2_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *file,
const GdkColor *color,
double saturation)
{
struct _vte_ft2_data *data;
......@@ -165,10 +171,8 @@ _vte_ft2_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
if (GDK_IS_PIXBUF(data->pixbuf)) {
g_object_unref(G_OBJECT(data->pixbuf));
}
data->pixbuf = pixbuf;
if (GDK_IS_PIXBUF(data->pixbuf)) {
g_object_ref(G_OBJECT(data->pixbuf));
}
data->pixbuf = vte_bg_get_pixbuf(vte_bg_get(), type, pixbuf, file,
color, saturation);
}
static void
......@@ -332,7 +336,7 @@ struct _vte_draw_impl _vte_draw_ft2 = {
_vte_ft2_start,
_vte_ft2_end,
_vte_ft2_set_background_color,
_vte_ft2_set_background_pixbuf,
_vte_ft2_set_background_image,
_vte_ft2_clear,
_vte_ft2_set_text_font,
_vte_ft2_get_text_width,
......
......@@ -46,7 +46,7 @@ struct _vte_gl_data
GLXContext context;
GLXPixmap pixmap;
GdkColor color;
GdkPixbuf *pixbuf;
GdkPixmap *gpixmap;
gint scrollx, scrolly;
};
......@@ -151,7 +151,7 @@ _vte_gl_create(struct _vte_draw *draw, GtkWidget *widget)
data->color.red = 0;
data->color.green = 0;
data->color.blue = 0;
data->pixbuf = NULL;
data->gpixmap = NULL;
data->pixmap = -1;
data->scrollx = data->scrolly = 0;
}
......@@ -178,10 +178,10 @@ _vte_gl_destroy(struct _vte_draw *draw)
data->scrollx = data->scrolly = 0;
if (GDK_IS_PIXBUF(data->pixbuf)) {
g_object_unref(G_OBJECT(data->pixbuf));
if (GDK_IS_PIXBUF(data->gpixmap)) {
g_object_unref(G_OBJECT(data->gpixmap));
}
data->pixbuf = NULL;
data->gpixmap = NULL;
memset(&data->color, 0, sizeof(data->color));
glXDestroyContext(display, data->context);
......@@ -290,18 +290,22 @@ _vte_gl_set_background_color(struct _vte_draw *draw, GdkColor *color)
}
static void
_vte_gl_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
_vte_gl_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *file,
const GdkColor *tint,
double saturation)
{
struct _vte_gl_data *data;
data = (struct _vte_gl_data*) draw->impl_data;
if (GDK_IS_PIXBUF(pixbuf)) {
g_object_ref(G_OBJECT(pixbuf));
if (GDK_IS_PIXMAP(data->gpixmap)) {
g_object_unref(G_OBJECT(data->gpixmap));
}
if (GDK_IS_PIXBUF(data->pixbuf)) {
g_object_unref(G_OBJECT(data->pixbuf));
}
data->pixbuf = pixbuf;
data->gpixmap = vte_bg_get_pixmap(vte_bg_get(), type, pixbuf, file,
tint, saturation,
_vte_draw_get_colormap(draw));
}
static void
......@@ -413,7 +417,7 @@ struct _vte_draw_impl _vte_draw_gl = {
_vte_gl_start,
_vte_gl_end,
_vte_gl_set_background_color,
_vte_gl_set_background_pixbuf,
_vte_gl_set_background_image,
_vte_gl_clear,
_vte_gl_set_text_font,
_vte_gl_get_text_width,
......
......@@ -27,6 +27,7 @@
#include <gtk/gtk.h>
#include <pango/pango.h>
#include "debug.h"
#include "vtebg.h"
#include "vtedraw.h"
#include "vtepango.h"
......@@ -170,11 +171,14 @@ _vte_pango_set_background_color(struct _vte_draw *draw, GdkColor *color)
}
static void
_vte_pango_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
_vte_pango_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *file,
const GdkColor *color,
double saturation)
{
GdkColormap *colormap;
GdkPixmap *pixmap;
GdkBitmap *bitmap;
struct _vte_pango_data *data;
data = (struct _vte_pango_data*) draw->impl_data;
......@@ -183,21 +187,12 @@ _vte_pango_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
data->pixmap = NULL;
data->pixmapw = data->pixmaph = 0;
}
if ((pixbuf != NULL) &&
(gdk_pixbuf_get_width(pixbuf) > 0) &&
(gdk_pixbuf_get_height(pixbuf) > 0)) {
colormap = gdk_drawable_get_colormap(draw->widget->window);
gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, colormap,
&pixmap, &bitmap,
0);
if (bitmap) {
g_object_unref(G_OBJECT(bitmap));
}
if (pixmap) {
data->pixmap = pixmap;
data->pixmapw = gdk_pixbuf_get_width(pixbuf);
data->pixmaph = gdk_pixbuf_get_height(pixbuf);
}
pixmap = vte_bg_get_pixmap(vte_bg_get(), type, pixbuf, file,
color, saturation,
_vte_draw_get_colormap(draw));
if (pixmap) {
data->pixmap = pixmap;
gdk_drawable_get_size(pixmap, &data->pixmapw, &data->pixmaph);
}
}
......@@ -206,7 +201,7 @@ _vte_pango_clear(struct _vte_draw *draw,
gint x, gint y, gint width, gint height)
{
struct _vte_pango_data *data;
gint i, j, istart, jstart, h, w, xstop, ystop;
gint i, j, h, w, xstop, ystop;
data = (struct _vte_pango_data*) draw->impl_data;
......@@ -441,7 +436,7 @@ struct _vte_draw_impl _vte_draw_pango = {
_vte_pango_start,
_vte_pango_end,
_vte_pango_set_background_color,
_vte_pango_set_background_pixbuf,
_vte_pango_set_background_image,
_vte_pango_clear,
_vte_pango_set_text_font,
_vte_pango_get_text_width,
......
......@@ -31,6 +31,7 @@
#include <pango/pango.h>
#include <pango/pangox.h>
#include "debug.h"
#include "vtebg.h"
#include "vtedraw.h"
#include "vtepangox.h"
......@@ -197,11 +198,14 @@ _vte_pango_x_set_background_color(struct _vte_draw *draw, GdkColor *color)
}
static void
_vte_pango_x_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
_vte_pango_x_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *file,
const GdkColor *color,
double saturation)
{
GdkColormap *colormap;
GdkPixmap *pixmap;
GdkBitmap *bitmap;
struct _vte_pango_x_data *data;
data = (struct _vte_pango_x_data*) draw->impl_data;
......@@ -210,21 +214,12 @@ _vte_pango_x_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
data->pixmap = NULL;
data->pixmapw = data->pixmaph = 0;
}
if ((pixbuf != NULL) &&
(gdk_pixbuf_get_width(pixbuf) > 0) &&
(gdk_pixbuf_get_height(pixbuf) > 0)) {
colormap = gdk_drawable_get_colormap(draw->widget->window);
gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, colormap,
&pixmap, &bitmap,
0);
if (bitmap) {
g_object_unref(G_OBJECT(bitmap));
}
if (pixmap) {
data->pixmap = pixmap;
data->pixmapw = gdk_pixbuf_get_width(pixbuf);
data->pixmaph = gdk_pixbuf_get_height(pixbuf);
}
pixmap = vte_bg_get_pixmap(vte_bg_get(), type, pixbuf, file,
color, saturation,
_vte_draw_get_colormap(draw));
if (pixmap) {
data->pixmap = pixmap;
gdk_drawable_get_size(pixmap, &data->pixmapw, &data->pixmaph);
}
}
......@@ -233,7 +228,7 @@ _vte_pango_x_clear(struct _vte_draw *draw,
gint x, gint y, gint width, gint height)
{
struct _vte_pango_x_data *data;
gint i, j, istart, jstart, h, w, xstop, ystop;
gint i, j, h, w, xstop, ystop;
data = (struct _vte_pango_x_data*) draw->impl_data;
......@@ -470,7 +465,7 @@ struct _vte_draw_impl _vte_draw_pango_x = {
_vte_pango_x_start,
_vte_pango_x_end,
_vte_pango_x_set_background_color,
_vte_pango_x_set_background_pixbuf,
_vte_pango_x_set_background_image,
_vte_pango_x_clear,
_vte_pango_x_set_text_font,
_vte_pango_x_get_text_width,
......
......@@ -25,6 +25,7 @@
#include <string.h>
#include <gtk/gtk.h>
#include "debug.h"
#include "vtebg.h"
#include "vtedraw.h"
struct _vte_skel_data
......@@ -114,7 +115,12 @@ _vte_skel_set_background_color(struct _vte_draw *draw, GdkColor *color)
}
static void
_vte_skel_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
_vte_skel_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
const GdkPixbuf *pixbuf,
const char *filename,
const GdkColor *tint,
double saturation)
{
struct _vte_skel_data *data;
......@@ -207,7 +213,7 @@ struct _vte_draw_impl _vte_draw_skel = {
_vte_skel_start,
_vte_skel_end,
_vte_skel_set_background_color,
_vte_skel_set_background_pixbuf,
_vte_skel_set_background_image,
_vte_skel_clear,
_vte_skel_set_text_font,
_vte_skel_get_text_width,
......
......@@ -31,6 +31,7 @@
#include <fontconfig/fontconfig.h>
#include <X11/Xft/Xft.h>
#include "debug.h"
#include "vtebg.h"
#include "vtedraw.h"
#include "vtefc.h"
#include "vtexft.h"
......@@ -407,12 +408,15 @@ _vte_xft_set_background_color(struct _vte_draw *draw, GdkColor *color)
}
static void
_vte_xft_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
_vte_xft_set_background_image(struct _vte_draw *draw,
enum VteBgSourceType type,
GdkPixbuf *pixbuf,
const char *file,
const GdkColor *color,
double saturation)
{
struct _vte_xft_data *data;
GdkColormap *colormap;
GdkPixmap *pixmap;
GdkBitmap *bitmap;
data = (struct _vte_xft_data*) draw->impl_data;
......@@ -422,22 +426,13 @@ _vte_xft_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf)
data->pixmap = NULL;
data->xpixmap = -1;
data->pixmapw = data->pixmaph = 0;
if ((pixbuf != NULL) &&
(gdk_pixbuf_get_width(pixbuf) > 0) &&
(gdk_pixbuf_get_height(pixbuf) > 0)) {
colormap = gdk_drawable_get_colormap(draw->widget->window);
gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, colormap,
&pixmap, &bitmap,
0);
if (bitmap) {
g_object_unref(G_OBJECT(bitmap));
}
if (pixmap) {
data->pixmap = pixmap;
data->xpixmap = gdk_x11_drawable_get_xid(pixmap);
data->pixmapw = gdk_pixbuf_get_width(pixbuf);
data->pixmaph = gdk_pixbuf_get_height(pixbuf);
}
pixmap = vte_bg_get_pixmap(vte_bg_get(), type,
pixbuf, file, color, saturation,
_vte_draw_get_colormap(draw));
if (GDK_IS_PIXMAP(pixmap)) {
data->pixmap = pixmap;
data->xpixmap = gdk_x11_drawable_get_xid(pixmap);
gdk_drawable_get_size(pixmap, &data->pixmapw, &data->pixmaph);
}
}
......@@ -766,7 +761,7 @@ struct _vte_draw_impl _vte_draw_xft = {
_vte_xft_start,
_vte_xft_end,
_vte_xft_set_background_color,
_vte_xft_set_background_pixbuf,
_vte_xft_set_background_image,
_vte_xft_clear,
_vte_xft_set_text_font,
_vte_xft_get_text_width,
......
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