--- rxvt-unicode/src/rxvt.h 2012/01/19 13:33:43 1.466 +++ rxvt-unicode/src/rxvt.h 2012/05/28 14:25:16 1.487 @@ -26,8 +26,6 @@ // stdlib.h might provide it #endif -using namespace std; - // we assume that Xlib.h defines XPointer, and it does since at least 1994... extern "C" { @@ -74,12 +72,6 @@ #include #include -#ifdef HAVE_AFTERIMAGE -# include -# undef min -# undef max -#endif - #ifdef HAVE_PIXBUF # include #endif @@ -88,6 +80,7 @@ # define HAVE_BG_PIXMAP 1 #endif +#include #include "encoding.h" #include "rxvtutil.h" #include "rxvtfont.h" @@ -218,6 +211,60 @@ } }; +#ifdef HAVE_BG_PIXMAP +# ifdef BG_IMAGE_FROM_FILE +enum { + IM_IS_SET = 1 << 0, + IM_IS_SIZE_SENSITIVE = 1 << 1, + IM_KEEP_ASPECT = 1 << 2, + IM_ROOT_ALIGN = 1 << 3, + IM_TILE = 1 << 4, + IM_GEOMETRY_FLAGS = IM_KEEP_ASPECT | IM_ROOT_ALIGN | IM_TILE, +}; + +enum { + noScale = 0, + windowScale = 100, + defaultScale = windowScale, + centerAlign = 50, + defaultAlign = centerAlign, +}; + +struct rxvt_image +{ + unsigned short alpha; + uint8_t flags; + unsigned int h_scale, v_scale; /* percents of the window size */ + int h_align, v_align; /* percents of the window size: + 0 - left align, 50 - center, 100 - right */ + +# ifdef HAVE_PIXBUF + GdkPixbuf *pixbuf; + + void destroy () + { + if (pixbuf) + g_object_unref (pixbuf); + } + + int width () + { + return gdk_pixbuf_get_width (pixbuf); + } + int height () + { + return gdk_pixbuf_get_height (pixbuf); + } +# endif + + rxvt_image (); + bool set_file_geometry (const char *file); + bool set_file (const char *file); + bool set_geometry (const char *geom, bool update = false); +}; +# endif +#endif + /* ***************************************************************************** * STRUCTURES AND TYPEDEFS @@ -706,6 +753,16 @@ tlen_t_ l; // length of each text line uint32_t f; // flags + bool valid () + { + return l >= 0; + } + + void alloc () + { + l = 0; + } + bool is_longer () { return f & LINE_LONGER; @@ -779,6 +836,9 @@ struct compose_char { unicode_t c1, c2; // any chars != NOCHAR are valid + #if __cplusplus >= 201103L || ECB_GCC_VERSION(4,4) + compose_char () = default; + #endif compose_char (unicode_t c1, unicode_t c2) : c1(c1), c2(c2) { } @@ -982,6 +1042,7 @@ XSizeHints szHint; rxvt_color *pix_colors; Cursor TermWin_cursor; /* cursor for vt window */ + line_t *row_buf; // all lines, scrollback + terminal, circular line_t *drawn_buf; // text on screen line_t *swap_buf; // lines for swap buffer @@ -1092,58 +1153,31 @@ void bg_destroy (); enum { - //subset returned by make_transparency_pixmap - BG_IS_VALID = 1 << 0, - BG_NEEDS_TINT = 1 << 1, - BG_NEEDS_BLUR = 1 << 2, - - BG_EFFECTS_FLAGS = BG_NEEDS_TINT | BG_NEEDS_BLUR, - - BG_KEEP_ASPECT = 1 << 3, - BG_ROOT_ALIGN = 1 << 4, - BG_TILE = 1 << 14, - BG_GEOMETRY_FLAGS = BG_KEEP_ASPECT | BG_ROOT_ALIGN | BG_TILE, - - BG_TINT_SET = 1 << 5, - BG_TINT_BITAND = 1 << 6, - BG_TINT_FLAGS = BG_NEEDS_TINT | BG_TINT_BITAND, - - BG_HAS_RENDER = 1 << 7, - BG_HAS_RENDER_CONV = 1 << 8, - BG_CLIENT_RENDER = 1 << 9, - - BG_IS_TRANSPARENT = 1 << 10, - BG_NEEDS_REFRESH = 1 << 11, - BG_IS_SIZE_SENSITIVE = 1 << 12, - BG_IS_FROM_FILE = 1 << 13, - }; + BG_IS_VALID = 1 << 0, - unsigned int bg_flags; + BG_IS_TRANSPARENT = 1 << 1, + BG_NEEDS_REFRESH = 1 << 2, -# ifdef BG_IMAGE_FROM_FILE - void get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y); - bool render_image (unsigned long tr_flags); + BG_HAS_RENDER = 1 << 3, + BG_HAS_RENDER_CONV = 1 << 4, + BG_CLIENT_RENDER = 1 << 5, - enum { - noScale = 0, - windowScale = 100, - defaultScale = windowScale, - centerAlign = 50, - defaultAlign = centerAlign, + BG_TINT_SET = 1 << 6, + BG_TINT_BITAND = 1 << 7, }; - unsigned int h_scale, v_scale; /* percents of the window size */ - int h_align, v_align; /* percents of the window size: - 0 - left align, 50 - center, 100 - right */ + uint8_t bg_flags; - bool bg_set_geometry (const char *geom, bool update = false); - void bg_set_default_geometry () +# ifdef BG_IMAGE_FROM_FILE + vector image_vec; + rxvt_image *new_image () { - h_scale = v_scale = defaultScale; - h_align = v_align = defaultAlign; + image_vec.resize (image_vec.size () + 1); + return &image_vec.back (); } - - bool bg_set_file (const char *file); + void get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y); + bool render_image (rxvt_image &image); + void parse_image (int id, const char *type, const char *arg); # endif # ifdef ENABLE_TRANSPARENCY @@ -1152,17 +1186,19 @@ int shade; int h_blurRadius, v_blurRadius; - bool bg_set_transparent (); + void bg_set_transparent () + { + bg_flags |= BG_IS_TRANSPARENT; + } void bg_set_root_pixmap (); - void set_tint_shade_flags (); bool bg_set_tint (rxvt_color &new_tint); bool bg_set_shade (const char *shade_str); bool bg_set_blur (const char *geom); - bool blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height, int depth); - bool tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height); - void tint_ximage (Visual *visual, XImage *ximage); - unsigned long make_transparency_pixmap (); + bool blur_pixmap (Pixmap pixmap, int width, int height); + bool tint_pixmap (Pixmap pixmap, int width, int height); + void tint_ximage (XImage *ximage); + bool make_transparency_pixmap (); # endif ev_tstamp bg_valid_since; @@ -1182,22 +1218,10 @@ bg_flags &= ~BG_IS_VALID; } #endif -#ifdef HAVE_AFTERIMAGE - ASImage *original_asim; - ASVisual *asv; - ASImageManager *asimman; - - void init_asv () - { - if (!asv) - asv = create_asvisual_for_id (dpy, display->screen, depth, XVisualIDFromVisual (visual), cmap, NULL); - } -#endif #ifdef HAVE_PIXBUF - GdkPixbuf *pixbuf; bool pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, int src_x, int src_y, int dst_x, int dst_y, - unsigned int width, unsigned int height); + unsigned int width, unsigned int height, bool argb); #endif #if ENABLE_OVERLAY @@ -1235,8 +1259,10 @@ ptytty *pty; - rxvt_salloc *talloc; // text line allocator - rxvt_salloc *ralloc; // rend line allocator + // chunk contains all line_t's as well as rend_t and text_t buffers + // for drawn_buf, swap_buf and row_buf, in this order + void *chunk; + size_t chunk_size; static vector termlist; // a vector of all running rxvt_term's @@ -1283,6 +1309,7 @@ void pty_cb (ev::io &w, int revents); ev::io pty_ev; #ifdef CURSOR_BLINK + void cursor_blink_reset (); void cursor_blink_cb (ev::timer &w, int revents); ev::timer cursor_blink_ev; #endif #ifdef TEXT_BLINK @@ -1419,34 +1446,6 @@ // screen.C - void lalloc (line_t &l) const - { - l.t = (text_t *)talloc->alloc (); - l.r = (rend_t *)ralloc->alloc (); - } - -#if 0 - void lfree (line_t &l) - { - talloc->free (l.t); - ralloc->free (l.r); - } -#endif - - void lresize (line_t &l) const - { - if (!l.t) - return; - - l.t = (text_t *)talloc->alloc (l.t, prev_ncol * sizeof (text_t)); - l.r = (rend_t *)ralloc->alloc (l.r, prev_ncol * sizeof (rend_t)); - - l.l = min (l.l, ncol); - - if (ncol > prev_ncol) - scr_blank_line (l, prev_ncol, ncol - prev_ncol, DEFAULT_RSTYLE); - } - int fgcolor_of (rend_t r) const NOTHROW { int base = GET_BASEFG (r); @@ -1485,6 +1484,7 @@ // modifies first argument(!) void tt_paste (char *data, unsigned int len) NOTHROW; void paste (char *data, unsigned int len) NOTHROW; + void scr_alloc () NOTHROW; void scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW; void scr_blank_screen_mem (line_t &l, rend_t efs) const NOTHROW; void scr_kill_char (line_t &l, int col) const NOTHROW; @@ -1566,6 +1566,15 @@ const char *x_resource (const char *name); void extract_resources (); void extract_keysym_resources (); + void find_resources (const char *n_prefix, const char *c_prefix, int mode, + Bool (*proc)(XrmDatabase *, XrmBindingList, XrmQuarkList, XrmRepresentation *, XrmValue *, XPointer)); + bool parse_bool_resource (const char *str) + { + return (!strcasecmp (str, "TRUE") + || !strcasecmp (str, "YES") + || !strcasecmp (str, "ON") + || !strcasecmp (str, "1")); + } }; #endif /* _RXVT_H_ */