--- rxvt-unicode/src/rxvt.h 2011/12/12 13:56:03 1.453 +++ rxvt-unicode/src/rxvt.h 2012/05/25 08:27:47 1.484 @@ -1,17 +1,17 @@ #ifndef RXVT_H_ /* include once only */ #define RXVT_H_ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef HAVE_STDINT_H #include #endif #include #include -#include +#include #include #ifdef HAVE_SYS_IOCTL_H #include @@ -20,16 +20,12 @@ #include #endif -#if HAVE_CWCHAR -# include -#elif HAVE_WCHAR_H +#if HAVE_WCHAR_H # include #else // 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" { @@ -76,12 +72,6 @@ #include #include -#ifdef HAVE_AFTERIMAGE -# include -# undef min -# undef max -#endif - #ifdef HAVE_PIXBUF # include #endif @@ -90,6 +80,7 @@ # define HAVE_BG_PIXMAP 1 #endif +#include #include "encoding.h" #include "rxvtutil.h" #include "rxvtfont.h" @@ -220,6 +211,55 @@ } }; +#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 +{ + int id; + 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 + auto_ptr 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 @@ -781,6 +821,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) { } @@ -872,6 +915,8 @@ struct TermWin_t { + int vt_width; /* actual window width [pixels] */ + int vt_height; /* actual window height [pixels] */ int width; /* window width [pixels] */ int height; /* window height [pixels] */ int fwidth; /* font width [pixels] */ @@ -893,7 +938,6 @@ Window parent; /* parent identifier */ Window vt; /* vt100 window */ GC gc; /* GC for drawing */ - Pixmap pixmap; rxvt_drawable *drawable; rxvt_fontset *fontset[4]; }; @@ -1030,6 +1074,7 @@ enc_utf8:1, /* whether locale uses utf-8 */ seen_input:1, /* whether we have seen some program output yet */ seen_resize:1, /* whether we had a resize event */ + init_done:1, parsed_geometry:1; unsigned char refresh_type, @@ -1073,8 +1118,6 @@ unsigned int ModLevel3Mask, ModMetaMask, ModNumLockMask; - int old_width, /* last used width in screen resize */ - old_height; /* last used height in screen resize */ unsigned long priv_modes, SavedModes; /* ---------- */ @@ -1094,58 +1137,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 @@ -1154,16 +1170,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); - bool tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height); - 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; @@ -1183,22 +1202,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 @@ -1216,11 +1223,6 @@ vector allocated; // free these memory blocks with free() - char env_windowid[21]; /* environmental variable WINDOWID */ - char env_colorfgbg[sizeof ("COLORFGBG=default;default;bg") + 1]; - char *env_display; /* environmental variable DISPLAY */ - char *env_term; /* environmental variable TERM */ - char *locale; char charsets[4]; char *v_buffer; /* pointer to physical buffer */ @@ -1289,6 +1291,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 @@ -1318,15 +1321,6 @@ void tt_write (const char *data, unsigned int len); void pty_write (); - void init (stringvec *argv, stringvec *envv) - { - this->argv = argv; - this->envv = envv; - argv->push_back (0); - envv->push_back (0); - init (argv->size () - 1, argv->begin ()); - } - void make_current () const // make this the "currently active" urxvt instance { SET_R (this); @@ -1393,9 +1387,11 @@ void process_terminal_mode (int mode, int priv, unsigned int nargs, const int *arg); void process_sgr_mode (unsigned int nargs, const int *arg); // init.C + void init (stringvec *argv, stringvec *envv); + void init (int argc, const char *const *argv, const char *const *envv); + void init2 (int argc, const char *const *argv); void init_vars (); const char **init_resources (int argc, const char *const *argv); - void init (int argc, const char *const *argv); void init_env (); void set_locale (const char *locale); void init_xlocale (); @@ -1423,7 +1419,7 @@ void set_title (const char *str); void set_icon_name (const char *str); void set_window_color (int idx, const char *color); - void set_colorfgbg (); + char *get_colorfgbg (); bool set_color (rxvt_color &color, const char *name); void alias_color (int dst, int src); void set_widthheight (unsigned int newwidth, unsigned int newheight); @@ -1574,11 +1570,20 @@ void selection_rotate (int x, int y) NOTHROW; // xdefaults.C - void get_options (int argc, const char *const *argv); + const char **get_options (int argc, const char *const *argv); int parse_keysym (const char *str, const char *arg); 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_ */