--- rxvt-unicode/src/background.h 2007/10/31 09:55:23 1.5 +++ rxvt-unicode/src/background.h 2011/01/20 17:39:29 1.43 @@ -11,71 +11,89 @@ # undef max #endif -#if defined(BG_IMAGE_FROM_FILE) || defined(ENABLE_TRANSPARENCY) -# define HAVE_BG_PIXMAP 1/* to simplify further usage */ -struct bgPixmap_t { +#ifdef HAVE_PIXBUF +#include +#endif - bgPixmap_t(); +#if defined(BG_IMAGE_FROM_FILE) || defined(ENABLE_TRANSPARENCY) +# define HAVE_BG_PIXMAP 1 /* to simplify further usage */ +struct bgPixmap_t +{ + bgPixmap_t (); + void destroy (); enum { - geometrySet = (1UL<<0), - propScale = (1UL<<1), - geometryFlags = (geometrySet|propScale), - - tintSet = (1UL<<8), - tintNeeded = (1UL<<9), - tintWholesome = (1UL<<10), - tintServerSide = (1UL<<11), - tintFlags = (tintSet|tintServerSide|tintNeeded|tintWholesome), - blurNeeded = (1UL<<12), - blurServerSide = (1UL<<13), /* this don't work yet */ - - isTransparent = (1UL<<16), - isInvalid = (1UL<<17), - isVtOrigin = (1UL<<18), /* if set pixmap has origin at corner of - vt window instead of parent[0]! */ - hasChanged = (1UL<<19) + propScale = 1 << 1, + rootAlign = 1 << 2, + geometryFlags = propScale | rootAlign, + + tintSet = 1 << 8, + tintNeeded = 1 << 9, + tintWholesome = 1 << 10, + tintFlags = tintSet | tintNeeded | tintWholesome, + + blurNeeded = 1 << 11, + + HAS_RENDER = 1 << 12, + HAS_RENDER_CONV = 1 << 13, + CLIENT_RENDER = 1 << 14, + + isTransparent = 1 << 16, + isInvalid = 1 << 17, + hasChanged = 1 << 19, + sizeSensitive = 1 << 20, }; - unsigned long flags; + unsigned int flags; enum { - transpPmapTiled = (1UL<<0), - transpPmapTinted = tintNeeded, - transpPmapBlured = blurNeeded, - transpTransformations = (tintNeeded|blurNeeded) - }; /* this flags are returned by make_transparency_pixmap if called */ - - bool check_clearChanged () { bool r = flags & hasChanged; flags &= ~hasChanged; return r; }; + transpPmapTiled = 1 << 0, + transpPmapTinted = tintNeeded, + transpPmapBlurred = blurNeeded, + transpTransformations = tintNeeded | blurNeeded, + }; /* these flags are returned by make_transparency_pixmap if called */ # ifdef BG_IMAGE_FROM_FILE # ifdef HAVE_AFTERIMAGE ASImage *original_asim; - bool render_asim (ASImage *background, ARGB32 background_tint); # endif - enum { defaultScale = 100, defaultAlign = 50 }; +# 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); +# endif + + void get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y); + bool render_image (unsigned long background_flags); + bool have_image; + + enum { + noScale = 0, + windowScale = 100, + defaultScale = windowScale, + centerAlign = 50, + defaultAlign = centerAlign, + }; 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 */ - void unset_geometry () { flags = flags & ~geometryFlags; }; - bool set_geometry (const char *geom); + bool set_geometry (const char *geom, bool update = false); void set_defaultGeometry () { h_scale = v_scale = defaultScale; h_align = v_align = defaultAlign; - flags |= geometrySet; - }; + } bool set_file (const char *file); # endif /* BG_IMAGE_FROM_FILE */ rxvt_term *target; - bool set_target (rxvt_term *new_target); + void set_target (rxvt_term *new_target); # ifdef ENABLE_TRANSPARENCY - int root_depth; /* obtained when target is set */ Pixmap root_pixmap; /* current root pixmap set */ rxvt_color tint; int shade; @@ -84,37 +102,29 @@ bool set_transparent (); bool set_blur_radius (const char *geom); bool set_tint (rxvt_color &new_tint); - bool unset_tint (); bool set_shade (const char *shade_str); - bool set_root_pixmap (); + bool blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height); + bool tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height); + void set_root_pixmap (); unsigned long make_transparency_pixmap ();/* returns combination of the transpTransformations flags */ # endif - double invalid_since; + double valid_since; Pixmap pixmap; unsigned int pmap_width, pmap_height; - unsigned int pmap_depth; + int target_x; + int target_y; + bool set_position (int x, int y); bool window_size_sensitive (); - bool window_position_sensitive () { - return (flags & isTransparent); - }; + bool window_position_sensitive (); - bool is_parentOrigin () { - return !(flags & isVtOrigin); - }; - - bool need_client_side_rendering (); - void apply (); bool render (); - void invalidate () { - if (!(flags & isInvalid)) - { - flags |= isInvalid; - invalid_since = NOW; - } - }; + void invalidate () + { + flags |= isInvalid; + } }; #else # undef HAVE_BG_PIXMAP @@ -122,4 +132,4 @@ -#endif /* _BACKGROUND_H_ */ +#endif /* _BACKGROUND_H_ */