ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/background.h
Revision: 1.38
Committed: Thu Dec 2 11:02:16 2010 UTC (13 years, 5 months ago) by sf-exg
Content type: text/plain
Branch: MAIN
CVS Tags: rel-9_10
Changes since 1.37: +4 -1 lines
Log Message:
Implement our own pixbuf to pixmap rendering to get rid of dependency on
buggy gtk-pixbuf-xlib. Only truecolor visuals are supported.

File Contents

# Content
1 /*
2 * background.h
3 */
4
5 #ifndef BACKGROUND_H_
6 #define BACKGROUND_H_
7
8 #ifdef HAVE_AFTERIMAGE
9 # include <afterimage.h>
10 # undef min
11 # undef max
12 #endif
13
14 #ifdef HAVE_PIXBUF
15 #include <gdk-pixbuf/gdk-pixbuf.h>
16 #endif
17
18 #if defined(BG_IMAGE_FROM_FILE) || defined(ENABLE_TRANSPARENCY)
19 # define HAVE_BG_PIXMAP 1 /* to simplify further usage */
20 struct bgPixmap_t
21 {
22 bgPixmap_t ();
23 void destroy ();
24
25 enum {
26 propScale = 1 << 1,
27 rootAlign = 1 << 2,
28 geometryFlags = propScale | rootAlign,
29
30 tintSet = 1 << 8,
31 tintNeeded = 1 << 9,
32 tintWholesome = 1 << 10,
33 tintFlags = tintSet | tintNeeded | tintWholesome,
34
35 blurNeeded = 1 << 11,
36
37 HAS_RENDER = 1 << 12,
38 HAS_RENDER_CONV = 1 << 13,
39
40 isTransparent = 1 << 16,
41 isInvalid = 1 << 17,
42 hasChanged = 1 << 19,
43 sizeSensitive = 1 << 20,
44 };
45
46 unsigned int flags;
47
48 enum {
49 transpPmapTiled = 1 << 0,
50 transpPmapTinted = tintNeeded,
51 transpPmapBlurred = blurNeeded,
52 transpTransformations = tintNeeded | blurNeeded,
53 }; /* these flags are returned by make_transparency_pixmap if called */
54
55 # ifdef BG_IMAGE_FROM_FILE
56 # ifdef HAVE_AFTERIMAGE
57 ASImage *original_asim;
58 # endif
59
60 # ifdef HAVE_PIXBUF
61 GdkPixbuf *pixbuf;
62 bool pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc,
63 int src_x, int src_y, int dst_x, int dst_y,
64 unsigned int width, unsigned int height);
65 # endif
66
67 void get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y);
68 bool render_image (unsigned long background_flags);
69 bool have_image;
70
71 enum {
72 noScale = 0,
73 windowScale = 100,
74 defaultScale = windowScale,
75 centerAlign = 50,
76 defaultAlign = centerAlign,
77 };
78
79 unsigned int h_scale, v_scale;/* percents of the window size */
80 int h_align, v_align; /* percents of the window size:
81 0 - left align, 50 - center, 100 - right */
82 bool set_geometry (const char *geom, bool update = false);
83 void set_defaultGeometry ()
84 {
85 h_scale = v_scale = defaultScale;
86 h_align = v_align = defaultAlign;
87 }
88
89 bool set_file (const char *file);
90 # endif /* BG_IMAGE_FROM_FILE */
91
92 rxvt_term *target;
93 void set_target (rxvt_term *new_target);
94
95 # ifdef ENABLE_TRANSPARENCY
96 Pixmap root_pixmap; /* current root pixmap set */
97 rxvt_color tint;
98 int shade;
99 int h_blurRadius, v_blurRadius;
100
101 bool set_transparent ();
102 bool set_blur_radius (const char *geom);
103 bool set_tint (rxvt_color &new_tint);
104 bool unset_tint ();
105 bool set_shade (const char *shade_str);
106 bool blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height);
107 bool tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height);
108 void set_root_pixmap ();
109
110 unsigned long make_transparency_pixmap ();/* returns combination of the transpTransformations flags */
111 # endif
112 double invalid_since, valid_since;
113
114 Pixmap pixmap;
115 unsigned int pmap_width, pmap_height;
116 unsigned int pmap_depth;
117
118 int target_x;
119 int target_y;
120 bool set_position (int x, int y);
121 bool window_size_sensitive ();
122 bool window_position_sensitive ();
123
124 bool need_client_side_rendering ();
125 void apply ();
126 bool render ();
127 void invalidate ()
128 {
129 if (!(flags & isInvalid))
130 {
131 flags |= isInvalid;
132 invalid_since = ev::now ();
133 }
134 }
135 };
136 #else
137 # undef HAVE_BG_PIXMAP
138 #endif
139
140
141
142 #endif /* _BACKGROUND_H_ */