--- rxvt-unicode/src/rxvt.h 2012/05/28 16:40:03 1.489 +++ rxvt-unicode/src/rxvt.h 2013/01/13 22:30:47 1.518 @@ -47,6 +47,7 @@ #if defined (ISO_14755) || defined (ENABLE_PERL) # define ENABLE_OVERLAY 1 +# undef NO_RESOURCES #endif #if ENABLE_PERL @@ -72,19 +73,29 @@ #include #include -#ifdef HAVE_PIXBUF +#if HAVE_PIXBUF # include #endif -#if defined(BG_IMAGE_FROM_FILE) || defined(ENABLE_TRANSPARENCY) +#if XRENDER && (HAVE_PIXBUF || ENABLE_TRANSPARENCY) # define HAVE_BG_PIXMAP 1 #endif +#if HAVE_BG_PIXMAP +# if HAVE_PIXBUF +# define BG_IMAGE_FROM_FILE 1 +# endif +# if ENABLE_TRANSPARENCY +# define BG_IMAGE_FROM_ROOT 1 +# endif +#endif + #include #include "encoding.h" #include "rxvtutil.h" #include "rxvtfont.h" #include "rxvttoolkit.h" +#include "rxvtimg.h" #include "scrollbar.h" #include "ev_cpp.h" #include "libptytty.h" @@ -211,9 +222,38 @@ }; #ifdef HAVE_BG_PIXMAP -# ifdef BG_IMAGE_FROM_FILE +struct image_effects +{ + bool tint_set; + rxvt_color tint; + int shade; + int h_blurRadius, v_blurRadius; + + image_effects () + { + tint_set = + h_blurRadius = + v_blurRadius = 0; + shade = 100; + } + + bool need_tint () + { + return shade != 100 || tint_set; + } + + bool need_blur () + { + return h_blurRadius && v_blurRadius; + } + + bool set_tint (const rxvt_color &new_tint); + bool set_shade (const char *shade_str); + bool set_blur (const char *geom); +}; + +# if 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, @@ -229,7 +269,7 @@ defaultAlign = centerAlign, }; -struct rxvt_image +struct rxvt_image : image_effects { unsigned short alpha; uint8_t flags; @@ -237,28 +277,24 @@ int h_align, v_align; /* percents of the window size: 0 - left align, 50 - center, 100 - right */ -# ifdef HAVE_PIXBUF - GdkPixbuf *pixbuf; - - void destroy () + bool is_size_sensitive () { - if (pixbuf) - g_object_unref (pixbuf); + return (!(flags & IM_TILE) + || h_scale || v_scale + || (!(flags & IM_ROOT_ALIGN) && (h_align || v_align))); } - int width () - { - return gdk_pixbuf_get_width (pixbuf); - } - int height () + rxvt_img *img; + + void destroy () { - return gdk_pixbuf_get_height (pixbuf); + delete img; + img = 0; } -# endif rxvt_image (); - bool set_file_geometry (const char *file); - bool set_file (const char *file); + void set_file_geometry (rxvt_screen *s, const char *file); + void set_file (rxvt_screen *s, const char *file); bool set_geometry (const char *geom, bool update = false); }; # endif @@ -315,7 +351,7 @@ /* COLORTERM, TERM environment variables */ #define COLORTERMENV "rxvt" -#ifdef BG_IMAGE_FROM_FILE +#if BG_IMAGE_FROM_FILE # define COLORTERMENVFULL COLORTERMENV "-xpm" #else # define COLORTERMENVFULL COLORTERMENV @@ -555,7 +591,7 @@ #ifdef RXVT_SCROLLBAR Color_trough, #endif -#if ENABLE_TRANSPARENCY +#if BG_IMAGE_FROM_ROOT Color_tint, #endif #if OFF_FOCUS_FADING @@ -1147,80 +1183,43 @@ XComposeStatus compose; static struct termios def_tio; row_col_t oldcursor; + #ifdef HAVE_BG_PIXMAP void bg_init (); void bg_destroy (); - enum { - BG_IS_VALID = 1 << 0, - - BG_IS_TRANSPARENT = 1 << 1, - BG_NEEDS_REFRESH = 1 << 2, - - BG_HAS_RENDER = 1 << 3, - BG_HAS_RENDER_CONV = 1 << 4, - BG_CLIENT_RENDER = 1 << 5, - - BG_TINT_SET = 1 << 6, - BG_TINT_BITAND = 1 << 7, - }; - - uint8_t bg_flags; - -# ifdef BG_IMAGE_FROM_FILE - vector image_vec; - rxvt_image *new_image () - { - image_vec.resize (image_vec.size () + 1); - return &image_vec.back (); - } - 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); +# if BG_IMAGE_FROM_FILE + rxvt_image fimage; + void render_image (rxvt_image &image); # endif -# ifdef ENABLE_TRANSPARENCY - Pixmap root_pixmap; /* current root pixmap set */ - rxvt_color tint; - int shade; - int h_blurRadius, v_blurRadius; +# if BG_IMAGE_FROM_ROOT + rxvt_img *root_img; + image_effects root_effects; - void bg_set_transparent () - { - bg_flags |= BG_IS_TRANSPARENT; - } - void bg_set_root_pixmap (); - 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, int width, int height); - bool tint_pixmap (Pixmap pixmap, int width, int height); - void tint_ximage (XImage *ximage); - bool make_transparency_pixmap (); + void render_root_image (); # endif - ev_tstamp bg_valid_since; + void tint_image (rxvt_img *img, rxvt_color &tint, bool tint_set, int shade); - Pixmap bg_pixmap; - unsigned int bg_pmap_width, bg_pmap_height; + ev_tstamp bg_valid_since; - int target_x; - int target_y; - bool bg_set_position (int x, int y); bool bg_window_size_sensitive (); bool bg_window_position_sensitive (); - bool bg_render (); - void bg_invalidate () - { - bg_flags &= ~BG_IS_VALID; - } + void bg_render (); #endif -#ifdef HAVE_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, bool argb); + +#ifdef HAVE_IMG + enum { + BG_IS_TRANSPARENT = 1 << 1, + BG_NEEDS_REFRESH = 1 << 2, + BG_INHIBIT_RENDER = 1 << 3, + }; + + uint8_t bg_flags; + + rxvt_img *bg_img; #endif #if ENABLE_OVERLAY @@ -1238,6 +1237,8 @@ vector allocated; // free these memory blocks with free() + int parent_x, parent_y; // parent window position relative to root, only updated on demand + char *locale; char charsets[4]; char *v_buffer; /* pointer to physical buffer */ @@ -1270,7 +1271,7 @@ unicode_t iso14755buf; void commit_iso14755 (); # if ISO_14755 - void iso14755_51 (unicode_t ch, rend_t r = DEFAULT_RSTYLE, int x = 0, int y = -1); + void iso14755_51 (unicode_t ch, rend_t r = DEFAULT_RSTYLE, int x = 0, int y = -1, int y2 = -1); void iso14755_54 (int x, int y); # endif #endif @@ -1282,7 +1283,7 @@ XSelectInput (dpy, vt, vt_emask | vt_emask_perl | vt_emask_xim | vt_emask_mouse); } -#if ENABLE_TRANSPARENCY || ENABLE_PERL +#if BG_IMAGE_FROM_ROOT || ENABLE_PERL void rootwin_cb (XEvent &xev); xevent_watcher rootwin_ev; #endif @@ -1441,10 +1442,16 @@ void alias_color (int dst, int src); void set_widthheight (unsigned int newwidth, unsigned int newheight); void get_window_origin (int &x, int &y); - Pixmap get_pixmap_property (Atom property); // screen.C + bool option (uint8_t opt) const NOTHROW + { + return options[opt >> 3] & (1 << (opt & 7)); + } + + void set_option (uint8_t opt, bool set = true) NOTHROW; + int fgcolor_of (rend_t r) const NOTHROW { int base = GET_BASEFG (r); @@ -1473,13 +1480,6 @@ return base; } - bool option (uint8_t opt) const NOTHROW - { - return options[opt >> 3] & (1 << (opt & 7)); - } - - void set_option (uint8_t opt, bool set = true) NOTHROW; - // modifies first argument(!) void tt_paste (char *data, unsigned int len) NOTHROW; void paste (char *data, unsigned int len) NOTHROW; @@ -1488,6 +1488,7 @@ void scr_blank_screen_mem (line_t &l, rend_t efs) const NOTHROW; void scr_kill_char (line_t &l, int col) const NOTHROW; int scr_scroll_text (int row1, int row2, int count) NOTHROW; + void copy_line (line_t &dst, line_t &src); void scr_reset (); void scr_release () NOTHROW; void scr_clear (bool really = false) NOTHROW; @@ -1560,20 +1561,12 @@ void selection_rotate (int x, int y) NOTHROW; // xdefaults.C + void rxvt_usage (int type); 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_ */