Commit d0c8c47d authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

toggle the IUTF8 flag, if it was defined at compile-time (maybe for

* src/pty.c(_vte_pty_set_utf8): toggle the IUTF8 flag, if it was defined at
	compile-time (maybe for #129317).
* src/vte.c(vte_terminal_set_encoding): call _vte_pty_set_utf8.
* src/vte.h (vte_terminal_anti_alias_get_type): declare.
* src/vtebg.c(vte_bg_get_pixmap): Optimisation to fix the ridiculous
	amount of time required to render solid colour or extremely small
	image tiled backgrounds.  This fixes bug #123903.  (desrt)
* src/vtebg.c(vte_bg_root_pixmap): move resize code into a separate
	function.
* src/vtebg.c(vte_bg_get_pixmap): Resize all image sources, in case
	we're using a very small image file for the background.
* python/Makefile.am: move python module to site-packages/gtk-2.0,
	which is added to the search path only by pygtk 2 (#92252).
parent a335c65b
2004-04-19 nalin
* src/pty.c(_vte_pty_set_utf8): toggle the IUTF8 flag, if
it was defined at compile-time (maybe for #129317).
* src/vte.c(vte_terminal_set_encoding): call _vte_pty_set_utf8.
* src/vte.h (vte_terminal_anti_alias_get_type): declare.
* src/vtebg.c(vte_bg_get_pixmap): Optimisation to fix the ridiculous
amount of time required to render solid colour or extremely small
image tiled backgrounds. This fixes bug #123903. (desrt)
* src/vtebg.c(vte_bg_root_pixmap): move resize code into a separate
function.
* src/vtebg.c(vte_bg_get_pixmap): Resize all image sources, in case
we're using a very small image file for the background.
2004-04-19 nalin
* python/Makefile.am: move python module to site-packages/gtk-2.0,
which is added to the search path only by pygtk 2 (#92252).
2004-04-19 nalin
* python/vte.override: define a modulename override so that the
Terminal class is registered in the proper namespace so that python's
......
......@@ -3,7 +3,7 @@ EXTRA_DIST = vte.defs vte.override
PYTHON_MODULES = vtemodule.la
if BUILD_PYTHON_MODULES
pythonsiteexecdir = $(pyexecdir)
pythonsiteexecdir = $(pyexecdir)/gtk-2.0
pythonsiteexec_LTLIBRARIES = $(PYTHON_MODULES)
CLEANFILES = vte.c
......@@ -11,7 +11,7 @@ CLEANFILES = vte.c
vtemodule_la_CFLAGS = @VTE_CFLAGS@ @X_CFLAGS@ @PYTHON_INCLUDES@ @PYGTK_CFLAGS@
vtemodule_la_SOURCES = vtemodule.c vte.c
vtemodule_la_LIBADD = $(top_builddir)/src/libvte.la @LIBS@ @PYGTK_LIBS@ @VTE_LIBS@ @X_LIBS@
vtemodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex initvte
vtemodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex=initvte
vte.c: vte.defs vte.override
pygtk-codegen-2.0 -p py$(PACKAGE) -o vte.override --register @PYGTK_DATADIR@/pygtk/2.0/defs/gtk-types.defs --register @PYGTK_DATADIR@/pygtk/2.0/defs/gdk-types.defs --register @PYGTK_DATADIR@/pygtk/2.0/defs/pango-types.defs $< > $@
......
......@@ -297,19 +297,22 @@ _vte_pty_run_on_pty(int fd, int ready_reader, int ready_writer,
}
#ifdef HAVE_STROPTS_H
if (!ioctl (fd, I_FIND, "ptem") && ioctl (fd, I_PUSH, "ptem") == -1) {
if ((ioctl(fd, I_FIND, "ptem") == 0) &&
(ioctl(fd, I_PUSH, "ptem") == -1)) {
close (fd);
_exit (0);
return -1;
}
if (!ioctl (fd, I_FIND, "ldterm") && ioctl (fd, I_PUSH, "ldterm") == -1) {
if ((ioctl(fd, I_FIND, "ldterm") == 0) &&
(ioctl(fd, I_PUSH, "ldterm") == -1)) {
close (fd);
_exit (0);
return -1;
}
if (!ioctl (fd, I_FIND, "ttcompat") && ioctl (fd, I_PUSH, "ttcompat") == -1) {
if ((ioctl(fd, I_FIND, "ttcompat") == 0) &&
(ioctl(fd, I_PUSH, "ttcompat") == -1)) {
perror ("ioctl (fd, I_PUSH, \"ttcompat\")");
close (fd);
_exit (0);
......@@ -1111,6 +1114,36 @@ _vte_pty_open(pid_t *child, char **env_add,
return ret;
}
/**
* _vte_pty_set_utf8:
* @pty: The pty master descriptor.
* @utf8: Whether or not the pty is in UTF-8 mode.
*
* Tells the kernel whether the terminal is UTF-8 or not, in case it can make
* use of the info. Linux 2.6.5 or so defines IUTF8 to make the line
* discipline do multibyte backspace correctly.
*/
void
_vte_pty_set_utf8(int pty, gboolean utf8)
{
#ifdef IUTF8
struct termios tio;
tcflag_t saved_cflag;
if (pty != -1) {
if (tcgetattr(pty, &tio) != -1) {
saved_cflag = tio.c_iflag;
tio.c_iflag &= ~IUTF8;
if (utf8) {
tio.c_iflag |= IUTF8;
}
if (saved_cflag != tio.c_iflag) {
tcsetattr(pty, TCSANOW, &tio);
}
}
}
#endif
}
/**
* _vte_pty_close:
* @pty: the pty master descriptor.
......
......@@ -39,6 +39,9 @@ int _vte_pty_open(pid_t *child, char **env_add,
int _vte_pty_get_size(int master, int *columns, int *rows);
int _vte_pty_set_size(int master, int columns, int rows);
/* Try to let the kernel know that the terminal is or is not UTF-8. */
void _vte_pty_set_utf8(int pty, gboolean utf8);
/* Close a pty. */
void _vte_pty_close(int pty);
......
......@@ -2083,6 +2083,8 @@ vte_terminal_set_encoding(VteTerminal *terminal, const char *codeset)
/* Set the terminal's encoding to the new value. */
encoding_quark = g_quark_from_string(codeset);
terminal->pvt->encoding = g_quark_to_string(encoding_quark);
_vte_pty_set_utf8(terminal->pvt->pty_master,
(strcmp(codeset, "UTF-8") == 0));
/* Convert any buffered output bytes. */
if ((_vte_buffer_length(terminal->pvt->outgoing) > 0) &&
......
......@@ -179,6 +179,7 @@ struct vte_char_attributes {
/* The widget's type. */
GtkType vte_terminal_get_type(void);
GtkType vte_terminal_erase_binding_get_type(void);
GtkType vte_terminal_anti_alias_get_type(void);
#define VTE_TYPE_TERMINAL (vte_terminal_get_type())
#define VTE_TERMINAL(obj) (GTK_CHECK_CAST((obj),\
......
......@@ -18,6 +18,7 @@
#ident "$Id$"
#include "../config.h"
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h>
#include "debug.h"
......@@ -39,6 +40,8 @@ struct VteBgPrivate {
static VteBg *singleton_bg = NULL;
static void vte_bg_set_root_pixmap(VteBg *bg, GdkPixmap *pixmap);
static void vte_bg_init(VteBg *bg, gpointer *klass);
static GdkPixbuf *_vte_bg_resize_pixbuf(GdkPixbuf *pixbuf,
gint min_width, gint min_height);
#if 0
static const char *
......@@ -136,6 +139,16 @@ vte_bg_root_pixmap(VteBg *bg)
pixmap = gdk_pixmap_foreign_new_for_display(gdk_drawable_get_display(bg->native->window), pixmaps[0]);
#else
pixmap = gdk_pixmap_foreign_new(pixmaps[0]);
#endif
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_MISC) ||
_vte_debug_on(VTE_DEBUG_EVENTS)) {
gint pwidth, pheight;
gdk_drawable_get_size(pixmap,
&pwidth, &pheight);
fprintf(stderr, "New background image %dx%d\n",
pwidth, pheight);
}
#endif
}
if (pixmaps != NULL) {
......@@ -373,6 +386,62 @@ vte_bg_cache_prune(VteBg *bg)
vte_bg_cache_prune_int(bg, FALSE);
}
/**
* _vte_bg_resize_pixbuf:
* @pixmap: a #GdkPixbuf, or NULL
* @min_width: the requested minimum_width
* @min_height: the requested minimum_height
*
* The background pixbuf may be tiled, and if it is tiled, it may be very, very
* small. This function creates a pixbuf consisting of the passed-in pixbuf
* tiled to a usable size.
*
* Returns: a new #GdkPixbuf, unrefs @pixbuf.
*/
static GdkPixbuf *
_vte_bg_resize_pixbuf(GdkPixbuf *pixbuf, gint min_width, gint min_height)
{
GdkPixbuf *tmp;
gint src_width, src_height;
gint dst_width, dst_height;
gint x, y;
if (!GDK_IS_PIXBUF(pixbuf)) {
return pixbuf;
}
src_width = gdk_pixbuf_get_width(pixbuf);
src_height = gdk_pixbuf_get_height(pixbuf);
dst_width = (((min_width - 1) / src_width) + 1) * src_width;
dst_height = (((min_height - 1) / src_height) + 1) * src_height;
if ((dst_width == src_width) && (dst_height == src_height)) {
return pixbuf;
}
#ifdef VTE_DEBUG
if (_vte_debug_on(VTE_DEBUG_MISC) || _vte_debug_on(VTE_DEBUG_EVENTS)) {
fprintf(stderr, "Resizing (root?) pixbuf from %dx%d to %dx%d\n",
src_width, src_height, dst_width, dst_height);
}
#endif
tmp = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(pixbuf),
gdk_pixbuf_get_has_alpha(pixbuf),
gdk_pixbuf_get_bits_per_sample(pixbuf),
dst_width, dst_height);
for (y = 0; y < dst_height; y += src_height) {
for (x = 0; x < dst_width; x += src_width) {
gdk_pixbuf_copy_area(pixbuf,
0, 0, src_width, src_height,
tmp,
x, y);
}
}
g_object_unref(G_OBJECT(pixbuf));
return tmp;
}
static void
vte_bg_set_root_pixmap(VteBg *bg, GdkPixmap *pixmap)
{
......@@ -605,6 +674,11 @@ vte_bg_get_pixmap(VteBg *bg,
pixmap = NULL;
mask = NULL;
if (GDK_IS_PIXBUF(pixbuf)) {
/* If the image is smaller than 256x256 then tile it into a
* pixbuf that is at least this large. This is done because
* tiling a 1x1 pixmap onto the screen using thousands of calls
* to XCopyArea is very slow. */
pixbuf = _vte_bg_resize_pixbuf(pixbuf, 256, 256);
gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf,
colormap,
&pixmap, &mask,
......
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