From 55ddc328cd0f7a6c16d62e24c6213ada7ddd2583 Mon Sep 17 00:00:00 2001 From: Michael Jennings Date: Sat, 11 Dec 1999 02:06:33 +0000 Subject: [PATCH] Fri Dec 10 23:33:16 PST 1999 Michael Jennings I finally got around to implementing double-buffering, although it seems to still have some issues with font changes. But if you don't change fonts, it works great. :-) I also fixed the multibyte font stuff with help from Sung-Hyun Nam . There seem to be some new issues here, though, with the background pixmap. But I'm to tired to look deeper tonight. SVN revision: 1588 --- ChangeLog | 11 +++ configure.in | 16 +++- src/events.c | 8 +- src/font.c | 29 +++++-- src/options.c | 9 ++ src/options.h | 1 + src/pixmap.c | 87 +++++++++++++++++-- src/pixmap.h | 13 +-- src/screen.c | 85 ++++++++++-------- src/screen.h | 30 +++---- src/windows.c | 9 +- themes/Eterm/{Eterm-menu.cfg => menus.cfg} | 0 themes/Eterm/theme.cfg.in | 31 ++++--- themes/Makefile.am | 9 +- themes/auto/{auto-menu.cfg => menus.cfg} | 0 themes/auto/theme.cfg.in | 26 +++--- themes/cEterm/{cEterm-menu.cfg => menus.cfg} | 0 themes/cEterm/theme.cfg.in | 26 +++--- .../chooser/{chooser-menu.cfg => menus.cfg} | 0 themes/chooser/theme.cfg.in | 26 +++--- themes/emacs/{emacs-menu.cfg => menus.cfg} | 0 themes/emacs/theme.cfg.in | 26 +++--- themes/irc/{irc-menu.cfg => menus.cfg} | 0 themes/irc/theme.cfg.in | 31 ++++--- themes/mutt/{mutt-menu.cfg => menus.cfg} | 0 themes/mutt/theme.cfg.in | 31 ++++--- themes/trans/{trans-menu.cfg => menus.cfg} | 0 themes/trans/theme.cfg.in | 26 +++--- 28 files changed, 339 insertions(+), 191 deletions(-) rename themes/Eterm/{Eterm-menu.cfg => menus.cfg} (100%) rename themes/auto/{auto-menu.cfg => menus.cfg} (100%) rename themes/cEterm/{cEterm-menu.cfg => menus.cfg} (100%) rename themes/chooser/{chooser-menu.cfg => menus.cfg} (100%) rename themes/emacs/{emacs-menu.cfg => menus.cfg} (100%) rename themes/irc/{irc-menu.cfg => menus.cfg} (100%) rename themes/mutt/{mutt-menu.cfg => menus.cfg} (100%) rename themes/trans/{trans-menu.cfg => menus.cfg} (100%) diff --git a/ChangeLog b/ChangeLog index bd7ad93..1eb241f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2902,3 +2902,14 @@ Wed Dec 8 19:05:06 PST 1999 Michael Jennings Updated the man page once again. ------------------------------------------------------------------------------- +Fri Dec 10 23:33:16 PST 1999 Michael Jennings + + I finally got around to implementing double-buffering, although it + seems to still have some issues with font changes. But if you don't + change fonts, it works great. :-) + + I also fixed the multibyte font stuff with help from Sung-Hyun Nam + . There seem to be some new issues here, though, + with the background pixmap. But I'm to tired to look deeper tonight. + +------------------------------------------------------------------------------- diff --git a/configure.in b/configure.in index 01312c0..9025e66 100644 --- a/configure.in +++ b/configure.in @@ -336,7 +336,7 @@ AC_ARG_ENABLE(multi-charset, AC_DEFINE_UNQUOTED(FONT2, "9x18") AC_DEFINE_UNQUOTED(FONT3, "12x24") AC_DEFINE_UNQUOTED(FONT4, "13x26") - elif test "$enableval" = "utf-8"; then + elif test "$enableval" = "utf-8" -o "$enableval" = "utf8"; then AC_MSG_RESULT(utf-8) AC_DEFINE(MULTI_CHARSET) AC_DEFINE_UNQUOTED(DEF_FONT_IDX, 2) @@ -350,7 +350,7 @@ AC_ARG_ENABLE(multi-charset, AC_DEFINE_UNQUOTED(FONT2, "fixed") AC_DEFINE_UNQUOTED(FONT3, "8x13") AC_DEFINE_UNQUOTED(FONT4, "9x15") - else + elif test "$enableval" = "no"; then AC_MSG_RESULT(no) AC_DEFINE_UNQUOTED(DEF_FONT_IDX, 2) AC_DEFINE_UNQUOTED(FONT0, "5x7") @@ -358,6 +358,8 @@ AC_ARG_ENABLE(multi-charset, AC_DEFINE_UNQUOTED(FONT2, "fixed") AC_DEFINE_UNQUOTED(FONT3, "8x13") AC_DEFINE_UNQUOTED(FONT4, "9x15") + else + AC_ERROR(invalid value for --enable-multi-charset) fi, AC_MSG_RESULT(no) AC_DEFINE_UNQUOTED(DEF_FONT_IDX, 2) AC_DEFINE_UNQUOTED(FONT0, "5x7") @@ -388,6 +390,16 @@ AC_ARG_ENABLE(greek, AC_MSG_RESULT(no) fi, AC_MSG_RESULT(no) ) +AC_ARG_WITH(theme-update, +[ --with-theme-update existing themes will be forceably removed and new ones installed], + if test "$withval" = "yes"; then + REMOVE_THEMES=yes + else + REMOVE_THEMES=no + fi, REMOVE_THEMES=no +) +AC_SUBST(REMOVE_THEMES) + dnl# AC_MSG_CHECKING(which threads library to use) dnl# AC_ARG_WITH(threads, dnl# [ --with-threads[=STYLE] compile with threads support, STYLE is either "posix" or blank diff --git a/src/events.c b/src/events.c index c393d37..6ab0c18 100644 --- a/src/events.c +++ b/src/events.c @@ -509,10 +509,12 @@ handle_expose(event_t * ev) REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0); if (ev->xany.window == TermWin.vt) { - if (refresh_type == NO_REFRESH) { - refresh_type = FAST_REFRESH; + if (buffer_pixmap == None) { + if (refresh_type == NO_REFRESH) { + refresh_type = FAST_REFRESH; + } + scr_expose(ev->xexpose.x, ev->xexpose.y, ev->xexpose.width, ev->xexpose.height); } - scr_expose(ev->xexpose.x, ev->xexpose.y, ev->xexpose.width, ev->xexpose.height); } else { XEvent unused_xevent; diff --git a/src/font.c b/src/font.c index dcb73eb..02a9621 100644 --- a/src/font.c +++ b/src/font.c @@ -72,16 +72,29 @@ eterm_font_add(char ***plist, const char *fontname, unsigned char idx) { if (idx >= font_cnt) { unsigned char new_size = sizeof(char *) * (idx + 1); - if (flist) { - *plist = (char **) REALLOC(*plist, new_size); - D_FONT((" -> Reallocating flist to a size of %u bytes gives %8p\n", new_size, *plist)); + if (etfonts) { + etfonts = (char **) REALLOC(etfonts, new_size); +#ifdef MULTI_CHARSET + etmfonts = (char **) REALLOC(etmfonts, new_size); +#endif + D_FONT((" -> Reallocating fonts lists to a size of %u bytes gives %8p/%8p\n", new_size, etfonts, etmfonts)); } else { - *plist = (char **) MALLOC(new_size); - D_FONT((" -> Allocating flist with a size of %u bytes gives %8p\n", new_size, *plist)); + etfonts = (char **) MALLOC(new_size); +#ifdef MULTI_CHARSET + etmfonts = (char **) MALLOC(new_size); +#endif + D_FONT((" -> Allocating fonts lists to a size of %u bytes gives %8p/%8p\n", new_size, etfonts, etmfonts)); } - flist = *plist; - MEMSET(flist + font_cnt, 0, sizeof(char *) * (idx - font_cnt)); + MEMSET(etfonts + font_cnt, 0, sizeof(char *) * (idx - font_cnt + 1)); +#ifdef MULTI_CHARSET + MEMSET(etmfonts + font_cnt, 0, sizeof(char *) * (idx - font_cnt + 1)); +#endif font_cnt = idx + 1; +#ifdef MULTI_CHARSET + flist = ((plist == &etfonts) ? (etfonts) : (etmfonts)); +#else + flist = etfonts; +#endif } else { if (flist[idx]) { if ((flist[idx] == fontname) || (!strcasecmp(flist[idx], fontname))) { @@ -205,7 +218,7 @@ font_cache_find_info(const char *name, unsigned char type) { cachefont_t *current; - ASSERT_RVAL(name != NULL, NULL); + REQUIRE_RVAL(name != NULL, NULL); D_FONT(("font_cache_find_info(%s, %d) called.\n", NONULL(name), type)); diff --git a/src/options.c b/src/options.c index 3842be8..2c41899 100644 --- a/src/options.c +++ b/src/options.c @@ -391,6 +391,7 @@ static const struct { OPT_BOOL('8', "meta-8", "Meta key toggles 8-bit", &Options, Opt_meta8), #endif OPT_BLONG("backing-store", "use backing store", &Options, Opt_backing_store), + OPT_BLONG("double-buffer", "use double-buffering to reduce exposes (uses more memory)", &Options, Opt_double_buffer), OPT_BLONG("no-cursor", "disable the text cursor", &Options, Opt_noCursor), OPT_BLONG("pause", "pause for a keypress after the child process exits", &Options, Opt_pause), OPT_BLONG("xterm-select", "duplicate xterm's broken selection behavior", &Options, Opt_xterm_select), @@ -1958,6 +1959,13 @@ parse_toggles(char *buff) Options &= ~(Opt_backing_store); } + } else if (!BEG_STRCASECMP(buff, "double_buffer ")) { + if (bool_val) { + Options |= Opt_double_buffer; + } else { + Options &= ~(Opt_double_buffer); + } + } else if (!BEG_STRCASECMP(buff, "no_cursor ")) { if (bool_val) { Options |= Opt_noCursor; @@ -3863,6 +3871,7 @@ save_config(char *path) fprintf(fp, " scrollbar_popup %d\n", (Options & Opt_scrollbar_popup ? 1 : 0)); fprintf(fp, " borderless %d\n", (Options & Opt_borderless ? 1 : 0)); fprintf(fp, " backing_store %d\n", (Options & Opt_backing_store ? 1 : 0)); + fprintf(fp, " double_buffer %d\n", (Options & Opt_double_buffer ? 1 : 0)); fprintf(fp, " no_cursor %d\n", (Options & Opt_noCursor ? 1 : 0)); fprintf(fp, " pause %d\n", (Options & Opt_pause ? 1 : 0)); fprintf(fp, " xterm_select %d\n", (Options & Opt_xterm_select ? 1 : 0)); diff --git a/src/options.h b/src/options.h index 087df0f..d836c53 100644 --- a/src/options.h +++ b/src/options.h @@ -72,6 +72,7 @@ # define Opt_select_trailing_spaces (1LU << 22) # define Opt_install (1LU << 23) # define Opt_scrollbar_floating (1LU << 24) +# define Opt_double_buffer (1LU << 25) # define IMOPT_TRANS (1U << 0) # define IMOPT_VIEWPORT (1U << 1) diff --git a/src/pixmap.c b/src/pixmap.c index 5da5618..b13bf24 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -47,8 +47,8 @@ static const char cvs_ident[] = "$Id$"; #include "term.h" #ifdef PIXMAP_SUPPORT -Pixmap desktop_pixmap = None; -Pixmap viewport_pixmap = None; +Pixmap desktop_pixmap = None, viewport_pixmap = None; +Pixmap buffer_pixmap = None; Window desktop_window = None; unsigned char desktop_pixmap_is_mine = 0; ImlibData *imlib_id = NULL; @@ -69,6 +69,7 @@ image_t images[image_max] = #ifdef PIXMAP_SUPPORT static const char *get_iclass_name(unsigned char); +static void copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width, unsigned short height); const char * get_image_type(unsigned short type) @@ -475,6 +476,34 @@ redraw_image(unsigned char which) { } } +static void +copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width, unsigned short height) +{ + GC gc; + XGCValues gcvalue; + + ASSERT(buffer_pixmap == None); + buffer_pixmap = XCreatePixmap(Xdisplay, TermWin.vt, width, height, Xdepth); + gcvalue.foreground = (Pixel) fill; + gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground, &gcvalue); + XSetGraphicsExposures(Xdisplay, gc, False); + + if (mode == MODE_SOLID) { + simage_t *simg; + + simg = images[image_bg].current; + if (simg->pmap->pixmap) { + XFreePixmap(Xdisplay, simg->pmap->pixmap); + } + simg->pmap->pixmap = XCreatePixmap(Xdisplay, TermWin.vt, width, height, Xdepth); + XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); + XCopyArea(Xdisplay, simg->pmap->pixmap, buffer_pixmap, gc, 0, 0, width, height, 0, 0); + } else { + XCopyArea(Xdisplay, (Pixmap) fill, buffer_pixmap, gc, 0, 0, width, height, 0, 0); + } + XFreeGC(Xdisplay, gc); +} + void render_simage(simage_t * simg, Window win, unsigned short width, unsigned short height, unsigned char which, renderop_t renderop) { @@ -517,6 +546,11 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short gc = XCreateGC(Xdisplay, win, GCForeground | GCBackground, &gcvalue); pixmap = simg->pmap->pixmap; /* Save this for later */ + if ((which == image_bg) && (buffer_pixmap != None)) { + XFreePixmap(Xdisplay, buffer_pixmap); + buffer_pixmap = None; + } + if ((images[which].mode & MODE_AUTO) && (images[which].mode & ALLOW_AUTO)) { char buff[255]; const char *iclass, *state; @@ -569,7 +603,12 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short "window manager or use Esetroot to set a new one."); desktop_pixmap = None; D_PIXMAP(("Setting background of window 0x%08x to the background color\n", win)); - XSetWindowBackground(Xdisplay, win, PixColors[bgColor]); + if ((which == image_bg) && (Options & Opt_double_buffer)) { + copy_buffer_pixmap(MODE_SOLID, (unsigned long) PixColors[bgColor], width, height); + XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap); + } else { + XSetWindowBackground(Xdisplay, win, PixColors[bgColor]); + } } else { if (pw < (unsigned int) scr->width || ph < (unsigned int) scr->height) { XFreeGC(Xdisplay, gc); @@ -588,12 +627,22 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short Imlib_bevel_pixmap(imlib_id, simg->pmap->pixmap, width, height, simg->iml->bevel->edges, simg->iml->bevel->up); } D_PIXMAP(("Setting background of window 0x%08x to 0x%08x\n", win, simg->pmap->pixmap)); - XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap); + if ((which == image_bg) && (Options & Opt_double_buffer)) { + copy_buffer_pixmap(MODE_TRANS, (unsigned long) simg->pmap->pixmap, width, height); + XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap); + } else { + XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap); + } } } } else { D_PIXMAP(("Setting background of window 0x%08x to the background color\n", win)); - XSetWindowBackground(Xdisplay, win, PixColors[bgColor]); + if ((which == image_bg) && (Options & Opt_double_buffer)) { + copy_buffer_pixmap(MODE_SOLID, (unsigned long) PixColors[bgColor], width, height); + XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap); + } else { + XSetWindowBackground(Xdisplay, win, PixColors[bgColor]); + } } } else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) { D_PIXMAP(("Viewport mode enabled. viewport_pixmap == 0x%08x and simg->pmap->pixmap == 0x%08x\n", viewport_pixmap, simg->pmap->pixmap)); @@ -655,7 +704,12 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height); } D_PIXMAP(("Setting background of window 0x%08x to 0x%08x\n", win, simg->pmap->pixmap)); - XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap); + if ((which == image_bg) && (Options & Opt_double_buffer)) { + copy_buffer_pixmap(MODE_VIEWPORT, (unsigned long) simg->pmap->pixmap, width, height); + XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap); + } else { + XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap); + } } else # endif if (image_mode_is(which, MODE_IMAGE) && image_mode_is(which, ALLOW_IMAGE)) { @@ -744,7 +798,12 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short shaped_window_apply_mask(win, simg->pmap->mask); } } else { - XSetWindowBackground(Xdisplay, win, PixColors[bgColor]); + if ((which == image_bg) && (Options & Opt_double_buffer)) { + copy_buffer_pixmap(MODE_SOLID, (unsigned long) PixColors[bgColor], width, height); + XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap); + } else { + XSetWindowBackground(Xdisplay, win, PixColors[bgColor]); + } reset_simage(simg, RESET_ALL); } if (simg->pmap->pixmap != None) { @@ -774,7 +833,12 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short Imlib_bevel_pixmap(imlib_id, simg->pmap->pixmap, width, height, simg->iml->bevel->edges, simg->iml->bevel->up); } D_PIXMAP(("Setting background of window 0x%08x to 0x%08x\n", win, simg->pmap->pixmap)); - XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap); + if ((which == image_bg) && (Options & Opt_double_buffer)) { + copy_buffer_pixmap(MODE_VIEWPORT, (unsigned long) simg->pmap->pixmap, width, height); + XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap); + } else { + XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap); + } } } else { unsigned short cidx; @@ -797,7 +861,12 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short break; } - XSetWindowBackground(Xdisplay, win, PixColors[cidx]); + if ((which == image_bg) && (Options & Opt_double_buffer)) { + copy_buffer_pixmap(MODE_SOLID, (unsigned long) PixColors[bgColor], width, height); + XSetWindowBackgroundPixmap(Xdisplay, win, buffer_pixmap); + } else { + XSetWindowBackground(Xdisplay, win, PixColors[cidx]); + } image_set_mode(which, MODE_SOLID); } XClearWindow(Xdisplay, win); diff --git a/src/pixmap.h b/src/pixmap.h index 0e205ce..d00cb19 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -29,7 +29,7 @@ /************ Macros and Definitions ************/ #ifdef PIXMAP_SUPPORT -# define background_is_image() (images[image_bg].current && images[image_bg].current->iml && images[image_bg].current->iml->im) +# define background_is_image() ((buffer_pixmap) || (images[image_bg].current && images[image_bg].current->iml && images[image_bg].current->iml->im)) # define background_is_trans() (images[image_bg].mode & MODE_TRANS) # define background_is_viewport() (images[image_bg].mode & MODE_VIEWPORT) # define background_is_auto() (images[image_bg].mode & MODE_AUTO) @@ -44,10 +44,11 @@ # define CONVERT_TINT_GREEN(t) (((t) & 0x00ff00) >> 8) # define CONVERT_TINT_BLUE(t) ((t) & 0x0000ff) #else -# define background_is_image() ((int)0) -# define background_is_trans() ((int)0) -# define background_is_pixmap() ((int)0) -# define delete_simage(simg) ((void)0) +# define background_is_image() NOP +# define background_is_trans() NOP +# define background_is_viewport() NOP +# define background_is_auto() NOP +# define delete_simage(simg) NOP #endif #define PIXMAP_EXT NULL /* '[', 2*4 + 2*3 digits + 3 delimiters, ']'. -vendu */ @@ -153,7 +154,7 @@ typedef short renderop_t; /************ Variables ************/ extern image_t images[image_max]; extern ImlibData *imlib_id; -extern Pixmap desktop_pixmap, viewport_pixmap; +extern Pixmap desktop_pixmap, viewport_pixmap, buffer_pixmap; extern Window desktop_window; /************ Function Prototypes ************/ diff --git a/src/screen.c b/src/screen.c index 4cbb921..7e3d6df 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1090,12 +1090,21 @@ scr_erase_screen(int mode) rend_t ren; long gcmask; XGCValues gcvalue; + Drawable draw_buffer; + Pixmap pmap = None; D_SCREEN(("scr_erase_screen(%d) at screen row: %d\n", mode, screen.row)); REFRESH_ZERO_SCROLLBACK; RESET_CHSTAT; row_offset = TermWin.saveLines; + if (buffer_pixmap) { + draw_buffer = buffer_pixmap; + pmap = images[image_bg].current->pmap->pixmap; + } else { + draw_buffer = TermWin.vt; + } + switch (mode) { case 0: /* erase to end of screen */ scr_erase_line(0); @@ -1553,17 +1562,17 @@ scr_expose(int x, int y, int width, int height) if (drawn_text == NULL) /* sanity check */ return; - part_beg.col = Pixel2Col(x); /* round down */ - part_beg.row = Pixel2Row(y); /* round down */ - full_beg.col = Pixel2Col(x + TermWin.fwidth - 1); /* round up */ - full_beg.row = Pixel2Row(y + TermWin.fheight - 1); /* round up */ + part_beg.col = Pixel2Col(x); + part_beg.row = Pixel2Row(y); + part_end.col = Pixel2Width(x + width + TermWin.fwidth - 1); + part_end.row = Pixel2Row(y + height + TermWin.fheight - 1); - part_end.col = Pixel2Width(x + width + TermWin.fwidth - 1); /* round up */ - part_end.row = Pixel2Row(y + height + TermWin.fheight - 1); /* round up */ - full_end.col = Pixel2Width(x + width); /* round down */ - full_end.row = Pixel2Row(y + height); /* round down */ + full_beg.col = Pixel2Col(x + TermWin.fwidth - 1); + full_beg.row = Pixel2Row(y + TermWin.fheight - 1); + full_end.col = Pixel2Width(x + width); + full_end.row = Pixel2Row(y + height); -/* sanity checks */ + /* sanity checks */ MAX_IT(part_beg.col, 0); MAX_IT(full_beg.col, 0); MAX_IT(part_end.col, 0); @@ -1609,6 +1618,13 @@ scr_expose(int x, int y, int width, int height) for (i = full_beg.row; i <= full_end.row; i++) drawn_rend[i][part_end.col] = RS_Dirty; + if (buffer_pixmap) { + x = Col2Pixel(full_beg.col); + y = Row2Pixel(full_beg.row); + XCopyArea(Xdisplay, images[image_bg].current->pmap->pixmap, buffer_pixmap, TermWin.gc, x, y, Width2Pixel(full_end.col - full_beg.col + 1), + Height2Pixel(full_end.row - full_beg.row + 1), x, y); + } + #ifdef USE_XIM scr_refresh(FAST_REFRESH); #endif @@ -1713,15 +1729,6 @@ scr_printscreen(int fullhist) * screen.text/screen.rend contain what the screen will change to. */ -#define DRAW_STRING(Func, x, y, str, len) \ - Func(Xdisplay, drawBuffer, TermWin.gc, x, y, str, len) - -#ifndef NO_BRIGHTCOLOR -# define MONO_BOLD(x) (((x) & RS_Bold) && fore == fgColor) -#else -# define MONO_BOLD(x) ((x) & (RS_Bold|RS_Blink)) -#endif - void scr_refresh(int type) { @@ -1753,8 +1760,9 @@ scr_refresh(int type) XGCValues gcvalue; /* Graphics Context values */ char buf[MAX_COLS + 1]; register char *buffer = buf; + Drawable draw_buffer; + Pixmap pmap = images[image_bg].current->pmap->pixmap; int (*draw_string) (), (*draw_image_string) (); - int (*clear_area) () = XClearArea; #ifndef NO_BOLDFONT int bfont = 0; /* we've changed font to bold font */ @@ -1792,6 +1800,12 @@ scr_refresh(int type) P_SETTIMEVAL(cnt.start); #endif + if (buffer_pixmap) { + draw_buffer = buffer_pixmap; + } else { + draw_buffer = TermWin.vt; + } + row_offset = TermWin.saveLines - TermWin.view_start; fprop = TermWin.fprop; @@ -2050,13 +2064,13 @@ scr_refresh(int type) SWAP_IT(gcvalue.foreground, gcvalue.background, ltmp); gcmask |= (GCForeground | GCBackground); XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); - XFillRectangle(Xdisplay, drawBuffer, TermWin.gc, + XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, ypixel - TermWin.font->ascent, Width2Pixel(1), Height2Pixel(1)); SWAP_IT(gcvalue.foreground, gcvalue.background, ltmp); XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); } else { - FAST_CLEAR_CHARS(xpixel, ypixel - TermWin.font->ascent, 1); + CLEAR_CHARS(xpixel, ypixel - TermWin.font->ascent, 1); } DRAW_STRING(draw_string, xpixel, ypixel, buffer, 1); #ifndef NO_BOLDOVERSTRIKE @@ -2066,13 +2080,13 @@ scr_refresh(int type) } else #ifdef PIXMAP_SUPPORT if (background_is_pixmap() && (back == bgColor)) { - FAST_CLEAR_CHARS(xpixel, ypixel - TermWin.font->ascent, len); + CLEAR_CHARS(xpixel, ypixel - TermWin.font->ascent, len); DRAW_STRING(draw_string, xpixel, ypixel, buffer, wlen); } else #endif { #ifdef FORCE_CLEAR_CHARS - FAST_CLEAR_CHARS(xpixel, ypixel - TermWin.font->ascent, len); + CLEAR_CHARS(xpixel, ypixel - TermWin.font->ascent, len); #endif DRAW_STRING(draw_image_string, xpixel, ypixel, buffer, wlen); } @@ -2084,7 +2098,7 @@ scr_refresh(int type) #endif if ((rend & RS_Uline) && (TermWin.font->descent > 1)) - XDrawLine(Xdisplay, drawBuffer, TermWin.gc, + XDrawLine(Xdisplay, draw_buffer, TermWin.gc, xpixel, ypixel + 1, xpixel + Width2Pixel(len) - 1, ypixel + 1); if (is_cursor == 1) { @@ -2095,7 +2109,7 @@ scr_refresh(int type) XChangeGC(Xdisplay, TermWin.gc, gcmask, &gcvalue); } #endif - XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc, + XDrawRectangle(Xdisplay, draw_buffer, TermWin.gc, xpixel, ypixel - TermWin.font->ascent, Width2Pixel(1 + wbyte) - 1, Height2Pixel(1) - 1); } @@ -2127,17 +2141,18 @@ scr_refresh(int type) screen.rend[row][col - 1] &= ~RS_Cursor; #endif } - if (boldlast) { - XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, - 1, TermWin_TotalHeight() - 1, 0); + if (buffer_pixmap) { + XClearWindow(Xdisplay, TermWin.vt); + } else { + if (boldlast) { + XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, + 1, TermWin_TotalHeight() - 1, 0); + } + if (boldlast) { + XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, + 1, TermWin_TotalHeight() - 1, 0); + } } - if (boldlast) { - XClearArea(Xdisplay, TermWin.vt, TermWin_TotalWidth() - 2, 0, - 1, TermWin_TotalHeight() - 1, 0); - } -#if defined(PIXMAP_SUPPORT) && defined(PIXMAP_BUFFERING) - XClearWindow(Xdisplay, TermWin.vt); -#endif if (type == SLOW_REFRESH) { XSync(Xdisplay, False); } diff --git a/src/screen.h b/src/screen.h index f7c4b29..907b976 100644 --- a/src/screen.h +++ b/src/screen.h @@ -42,22 +42,20 @@ * CLEAR_CHARS: clear chars starting from pixel position * ERASE_ROWS : set rows starting from row to the foreground color */ -#define drawBuffer (TermWin.vt) -#define CLEAR_ROWS(row, num) do { \ - XClearArea(Xdisplay, drawBuffer, Col2Pixel(0), Row2Pixel(row), \ - TermWin.width, Height2Pixel(num), 0); \ - } while (0) -#define CLEAR_CHARS(x, y, num) do { \ - D_SCREEN(("CLEAR_CHARS(%d, %d, %d)\n", x, y, num)); \ - XClearArea(Xdisplay, drawBuffer, x, y, Width2Pixel(num), Height2Pixel(1), 0); \ - } while (0) -#define FAST_CLEAR_CHARS(x, y, num) do { \ - clear_area(Xdisplay, drawBuffer, x, y, Width2Pixel(num), Height2Pixel(1), 0); \ - } while (0) -#define ERASE_ROWS(row, num) do { \ - XFillRectangle(Xdisplay, drawBuffer, TermWin.gc, Col2Pixel(0), Row2Pixel(row), \ - TermWin.width, Height2Pixel(num)); \ - } while (0) +#define CLEAR_ROWS(row, num) ((buffer_pixmap) \ + ? (XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, Col2Pixel(0), Row2Pixel(row), TermWin.width, Height2Pixel(num), \ + Col2Pixel(0), Row2Pixel(row))) \ + : (XClearArea(Xdisplay, TermWin.vt, Col2Pixel(0), Row2Pixel(row), TermWin.width, Height2Pixel(num), 0))) +#define CLEAR_CHARS(x, y, num) ((buffer_pixmap) \ + ? (XCopyArea(Xdisplay, pmap, buffer_pixmap, TermWin.gc, x, y, Width2Pixel(num), Height2Pixel(1), x, y)) \ + : (XClearArea(Xdisplay, TermWin.vt, x, y, Width2Pixel(num), Height2Pixel(1), 0))) +#define ERASE_ROWS(row, num) (XFillRectangle(Xdisplay, draw_buffer, TermWin.gc, Col2Pixel(0), Row2Pixel(row), TermWin.width, Height2Pixel(num))) +#define DRAW_STRING(Func, x, y, str, len) Func(Xdisplay, draw_buffer, TermWin.gc, x, y, str, len) +#ifndef NO_BRIGHTCOLOR +# define MONO_BOLD(x) (((x) & RS_Bold) && fore == fgColor) +#else +# define MONO_BOLD(x) ((x) & (RS_Bold|RS_Blink)) +#endif /* Screen refresh methods */ #define NO_REFRESH 0 /* Window not visible at all! */ diff --git a/src/windows.c b/src/windows.c index c5c8b46..9df559b 100644 --- a/src/windows.c +++ b/src/windows.c @@ -442,13 +442,8 @@ Create_Windows(int argc, char *argv[]) XMapWindow(Xdisplay, TermWin.vt); XMapWindow(Xdisplay, TermWin.parent); XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[bgColor]); - XClearWindow(Xdisplay, TermWin.vt); -#ifdef PIXMAP_SUPPORT - if (background_is_image()) { - render_simage(images[image_bg].norm, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); - } -#endif /* PIXMAP_SUPPORT */ + render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); /* graphics context for the vt window */ { @@ -624,7 +619,7 @@ set_window_color(int idx, const char *color) return; } - if (idx == bgColor) { + if (!background_is_pixmap() && (idx == bgColor)) { XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[bgColor]); } diff --git a/themes/Eterm/Eterm-menu.cfg b/themes/Eterm/menus.cfg similarity index 100% rename from themes/Eterm/Eterm-menu.cfg rename to themes/Eterm/menus.cfg diff --git a/themes/Eterm/theme.cfg.in b/themes/Eterm/theme.cfg.in index d129d38..324a03f 100644 --- a/themes/Eterm/theme.cfg.in +++ b/themes/Eterm/theme.cfg.in @@ -93,6 +93,18 @@ begin main # font bold 7x14 end attributes +# The Multichar support options. Same goes for these fonts as for the normal +# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" +# or big5 or gb +# begin multichar +# font 0 k14 +# font 1 jiskan16 +# font 2 jiskan18 +# font 3 jiskan24 +# font 4 jiskan26 +# encoding eucj +# end multichar + # Define the imageclasses. begin imageclasses @@ -220,7 +232,7 @@ begin main end image end -%include "Eterm-menu.cfg" +%include "menus.cfg" # This section *must* come after the menu definitions if you want # menu actions to work. C'est la vie. :-) @@ -234,18 +246,6 @@ begin main bind anymod 0xffbe to menu Eterm end actions -# The Multichar support options. Same goes for these fonts as for the normal -# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" -# or big5 or gb -# begin multichar -# font 0 k14 -# font 1 jiskan16 -# font 2 jiskan18 -# font 3 jiskan24 -# font 4 jiskan26 -# encoding eucj -# end multichar - # The XIM support options. # input_method: set the name of your favorate input method program # preedit_type: OverTheSpot or OffTheSpot or Root @@ -303,6 +303,11 @@ begin main # If true, Eterm will run with no window borders. borderless false +# If true, Eterm will use a double-buffered background pixmap for drawing text. This +# makes redraws faster by reducing exposes, but it uses more memory. If you have the +# memory to spare, it's a good idea. +# double_buffer true + end toggles begin keyboard diff --git a/themes/Makefile.am b/themes/Makefile.am index c3d697c..06da447 100644 --- a/themes/Makefile.am +++ b/themes/Makefile.am @@ -16,6 +16,13 @@ all: Makefile install-data-hook: $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/themes -@for i in $(THEMES) ; do \ + if test -d $(DESTDIR)$(pkgdatadir)/themes/$$i -a "@REMOVE_THEMES@" = "yes"; then \ + echo "Removing $$i theme in $(DESTDIR)$(pkgdatadir)/themes as requested." ; \ + $(RM) -rf $(DESTDIR)$(pkgdatadir)/themes/$$i ; \ + if test -d $(DESTDIR)$(pkgdatadir)/themes/$$i ; then \ + echo "ERROR: Unable to remove theme." ; \ + fi ; \ + fi ; \ if test ! -d $(DESTDIR)$(pkgdatadir)/themes/$$i ; then \ echo "Installing $$i theme in $(DESTDIR)$(pkgdatadir)/themes" ; \ $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/themes/$$i ; \ @@ -24,6 +31,6 @@ install-data-hook: $(CHMOD) 644 $(DESTDIR)$(pkgdatadir)/themes/$$i/???* ; \ rm -f $(DESTDIR)$(pkgdatadir)/themes/$$i/theme.cfg.in ; \ else \ - echo "ALERT! Not overwriting theme $$i in $(DESTDIR)$(pkgdatadir)/themes. You will need to update this theme manually." ; \ + echo "ALERT! Not overwriting $$i theme in $(DESTDIR)$(pkgdatadir)/themes. You will need to update this theme manually." ; \ fi ; \ done diff --git a/themes/auto/auto-menu.cfg b/themes/auto/menus.cfg similarity index 100% rename from themes/auto/auto-menu.cfg rename to themes/auto/menus.cfg diff --git a/themes/auto/theme.cfg.in b/themes/auto/theme.cfg.in index 0ea69e9..286389d 100644 --- a/themes/auto/theme.cfg.in +++ b/themes/auto/theme.cfg.in @@ -93,6 +93,18 @@ begin main # font bold 7x14 end attributes +# The Multichar support options. Same goes for these fonts as for the normal +# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" +# or big5 or gb +# begin multichar +# font 0 k14 +# font 1 jiskan16 +# font 2 jiskan18 +# font 3 jiskan24 +# font 4 jiskan26 +# encoding eucj +# end multichar + # Define the imageclasses. begin imageclasses @@ -220,7 +232,7 @@ begin main end image end -%include "auto-menu.cfg" +%include "menus.cfg" # This section *must* come after the menu definitions if you want # menu actions to work. C'est la vie. :-) @@ -234,18 +246,6 @@ begin main bind anymod 0xffbe to menu Eterm end actions -# The Multichar support options. Same goes for these fonts as for the normal -# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" -# or big5 or gb -# begin multichar -# font 0 k14 -# font 1 jiskan16 -# font 2 jiskan18 -# font 3 jiskan24 -# font 4 jiskan26 -# encoding eucj -# end multichar - # The XIM support options. # input_method: set the name of your favorate input method program # preedit_type: OverTheSpot or OffTheSpot or Root diff --git a/themes/cEterm/cEterm-menu.cfg b/themes/cEterm/menus.cfg similarity index 100% rename from themes/cEterm/cEterm-menu.cfg rename to themes/cEterm/menus.cfg diff --git a/themes/cEterm/theme.cfg.in b/themes/cEterm/theme.cfg.in index 2e2806c..84b13cf 100644 --- a/themes/cEterm/theme.cfg.in +++ b/themes/cEterm/theme.cfg.in @@ -92,6 +92,18 @@ begin main # font bold 7x14 end attributes +# The Multichar support options. Same goes for these fonts as for the normal +# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" +# or big5 or gb +# begin multichar +# font 0 k14 +# font 1 jiskan16 +# font 2 jiskan18 +# font 3 jiskan24 +# font 4 jiskan26 +# encoding eucj +# end multichar + # Define the imageclasses. begin imageclasses @@ -219,7 +231,7 @@ begin main end image end -%include "cEterm-menu.cfg" +%include "menus.cfg" # This section *must* come after the menu definitions if you want # menu actions to work. C'est la vie. :-) @@ -233,18 +245,6 @@ begin main bind anymod 0xffbe to menu Eterm end actions -# The Multichar support options. Same goes for these fonts as for the normal -# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" -# or big5 or gb -# begin multichar -# font 0 k14 -# font 1 jiskan16 -# font 2 jiskan18 -# font 3 jiskan24 -# font 4 jiskan26 -# encoding eucj -# end multichar - # The XIM support options. # input_method: set the name of your favorate input method program # preedit_type: OverTheSpot or OffTheSpot or Root diff --git a/themes/chooser/chooser-menu.cfg b/themes/chooser/menus.cfg similarity index 100% rename from themes/chooser/chooser-menu.cfg rename to themes/chooser/menus.cfg diff --git a/themes/chooser/theme.cfg.in b/themes/chooser/theme.cfg.in index 3a83911..0fdd98e 100644 --- a/themes/chooser/theme.cfg.in +++ b/themes/chooser/theme.cfg.in @@ -93,6 +93,18 @@ begin main # font bold 7x14 end attributes +# The Multichar support options. Same goes for these fonts as for the normal +# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" +# or big5 or gb +# begin multichar +# font 0 k14 +# font 1 jiskan16 +# font 2 jiskan18 +# font 3 jiskan24 +# font 4 jiskan26 +# encoding eucj +# end multichar + # Define the imageclasses. begin imageclasses @@ -220,7 +232,7 @@ begin main end image end -%include "chooser-menu.cfg" +%include "menus.cfg" # This section *must* come after the menu definitions if you want # menu actions to work. C'est la vie. :-) @@ -234,18 +246,6 @@ begin main bind anymod 0xffbe to menu Eterm end actions -# The Multichar support options. Same goes for these fonts as for the normal -# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" -# or big5 or gb -# begin multichar -# font 0 k14 -# font 1 jiskan16 -# font 2 jiskan18 -# font 3 jiskan24 -# font 4 jiskan26 -# encoding eucj -# end multichar - # The XIM support options. # input_method: set the name of your favorate input method program # preedit_type: OverTheSpot or OffTheSpot or Root diff --git a/themes/emacs/emacs-menu.cfg b/themes/emacs/menus.cfg similarity index 100% rename from themes/emacs/emacs-menu.cfg rename to themes/emacs/menus.cfg diff --git a/themes/emacs/theme.cfg.in b/themes/emacs/theme.cfg.in index a773271..a524cc9 100644 --- a/themes/emacs/theme.cfg.in +++ b/themes/emacs/theme.cfg.in @@ -93,6 +93,18 @@ begin main # font bold 7x14 end attributes +# The Multichar support options. Same goes for these fonts as for the normal +# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" +# or big5 or gb +# begin multichar +# font 0 k14 +# font 1 jiskan16 +# font 2 jiskan18 +# font 3 jiskan24 +# font 4 jiskan26 +# encoding eucj +# end multichar + # Define the imageclasses. begin imageclasses @@ -220,7 +232,7 @@ begin main end image end -%include "emacs-menu.cfg" +%include "menus.cfg" # This section *must* come after the menu definitions if you want # menu actions to work. C'est la vie. :-) @@ -234,18 +246,6 @@ begin main bind anymod 0xffbe to menu Eterm end actions -# The Multichar support options. Same goes for these fonts as for the normal -# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" -# or big5 or gb -# begin multichar -# font 0 k14 -# font 1 jiskan16 -# font 2 jiskan18 -# font 3 jiskan24 -# font 4 jiskan26 -# encoding eucj -# end multichar - # The XIM support options. # input_method: set the name of your favorate input method program # preedit_type: OverTheSpot or OffTheSpot or Root diff --git a/themes/irc/irc-menu.cfg b/themes/irc/menus.cfg similarity index 100% rename from themes/irc/irc-menu.cfg rename to themes/irc/menus.cfg diff --git a/themes/irc/theme.cfg.in b/themes/irc/theme.cfg.in index 614133e..129cb1f 100644 --- a/themes/irc/theme.cfg.in +++ b/themes/irc/theme.cfg.in @@ -95,6 +95,18 @@ begin main # font bold 7x14 end attributes +# The Multichar support options. Same goes for these fonts as for the normal +# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" +# or big5 or gb +# begin multichar +# font 0 k14 +# font 1 jiskan16 +# font 2 jiskan18 +# font 3 jiskan24 +# font 4 jiskan26 +# encoding eucj +# end multichar + # Define the imageclasses. begin imageclasses @@ -222,7 +234,7 @@ begin main end image end -%include "irc-menu.cfg" +%include "menus.cfg" # This section *must* come after the menu definitions if you want # menu actions to work. C'est la vie. :-) @@ -236,18 +248,6 @@ begin main bind anymod 0xffbe to menu Eterm end actions -# The Multichar support options. Same goes for these fonts as for the normal -# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" -# or big5 or gb -# begin multichar -# font 0 k14 -# font 1 jiskan16 -# font 2 jiskan18 -# font 3 jiskan24 -# font 4 jiskan26 -# encoding eucj -# end multichar - # The XIM support options. # input_method: set the name of your favorate input method program # preedit_type: OverTheSpot or OffTheSpot or Root @@ -300,6 +300,11 @@ begin main # If true, Eterm will run with no window borders. borderless false +# If true, Eterm will use a double-buffered background pixmap for drawing text. This +# makes redraws faster by reducing exposes, but it uses more memory. If you have the +# memory to spare, it's a good idea. +# double_buffer true + end toggles begin keyboard diff --git a/themes/mutt/mutt-menu.cfg b/themes/mutt/menus.cfg similarity index 100% rename from themes/mutt/mutt-menu.cfg rename to themes/mutt/menus.cfg diff --git a/themes/mutt/theme.cfg.in b/themes/mutt/theme.cfg.in index 6566bcd..86e3daa 100644 --- a/themes/mutt/theme.cfg.in +++ b/themes/mutt/theme.cfg.in @@ -93,6 +93,18 @@ begin main # font bold 7x14 end attributes +# The Multichar support options. Same goes for these fonts as for the normal +# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" +# or big5 or gb +# begin multichar +# font 0 k14 +# font 1 jiskan16 +# font 2 jiskan18 +# font 3 jiskan24 +# font 4 jiskan26 +# encoding eucj +# end multichar + # Define the imageclasses. begin imageclasses @@ -166,7 +178,7 @@ begin main end image end -%include "mutt-menu.cfg" +%include "menus.cfg" # This section *must* come after the menu definitions if you want # menu actions to work. C'est la vie. :-) @@ -180,18 +192,6 @@ begin main bind anymod 0xffbe to menu Eterm end actions -# The Multichar support options. Same goes for these fonts as for the normal -# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" -# or big5 or gb -# begin multichar -# font 0 k14 -# font 1 jiskan16 -# font 2 jiskan18 -# font 3 jiskan24 -# font 4 jiskan26 -# encoding eucj -# end multichar - # The XIM support options. # input_method: set the name of your favorate input method program # preedit_type: OverTheSpot or OffTheSpot or Root @@ -244,6 +244,11 @@ begin main # If true, Eterm will run with no window borders. borderless false +# If true, Eterm will use a double-buffered background pixmap for drawing text. This +# makes redraws faster by reducing exposes, but it uses more memory. If you have the +# memory to spare, it's a good idea. +# double_buffer true + end toggles begin keyboard diff --git a/themes/trans/trans-menu.cfg b/themes/trans/menus.cfg similarity index 100% rename from themes/trans/trans-menu.cfg rename to themes/trans/menus.cfg diff --git a/themes/trans/theme.cfg.in b/themes/trans/theme.cfg.in index d068180..764506e 100644 --- a/themes/trans/theme.cfg.in +++ b/themes/trans/theme.cfg.in @@ -93,6 +93,18 @@ begin main # font bold 7x14 end attributes +# The Multichar support options. Same goes for these fonts as for the normal +# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" +# or big5 or gb +# begin multichar +# font 0 k14 +# font 1 jiskan16 +# font 2 jiskan18 +# font 3 jiskan24 +# font 4 jiskan26 +# encoding eucj +# end multichar + # Define the imageclasses. begin imageclasses @@ -220,7 +232,7 @@ begin main end image end -%include "trans-menu.cfg" +%include "menus.cfg" # This section *must* come after the menu definitions if you want # menu actions to work. C'est la vie. :-) @@ -234,18 +246,6 @@ begin main bind anymod 0xffbe to menu Eterm end actions -# The Multichar support options. Same goes for these fonts as for the normal -# ones. The "encoding" attribute can be either "eucj" or "sjis" or "euckr" -# or big5 or gb -# begin multichar -# font 0 k14 -# font 1 jiskan16 -# font 2 jiskan18 -# font 3 jiskan24 -# font 4 jiskan26 -# encoding eucj -# end multichar - # The XIM support options. # input_method: set the name of your favorate input method program # preedit_type: OverTheSpot or OffTheSpot or Root