1 |
sasha |
1.1 |
/*----------------------------------------------------------------------* |
2 |
sf-exg |
1.243 |
* File: background.C |
3 |
sasha |
1.1 |
*----------------------------------------------------------------------* |
4 |
|
|
* |
5 |
|
|
* All portions of code are copyright by their respective author/s. |
6 |
root |
1.147 |
* Copyright (c) 2005-2008 Marc Lehmann <schmorp@schmorp.de> |
7 |
sasha |
1.1 |
* Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
8 |
sf-exg |
1.209 |
* Copyright (c) 2010-2012 Emanuele Giaquinta <e.giaquinta@glauco.it> |
9 |
sasha |
1.1 |
* |
10 |
|
|
* This program is free software; you can redistribute it and/or modify |
11 |
|
|
* it under the terms of the GNU General Public License as published by |
12 |
root |
1.258 |
* the Free Software Foundation; either version 3 of the License, or |
13 |
sasha |
1.1 |
* (at your option) any later version. |
14 |
|
|
* |
15 |
|
|
* This program is distributed in the hope that it will be useful, |
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
|
|
* GNU General Public License for more details. |
19 |
|
|
* |
20 |
|
|
* You should have received a copy of the GNU General Public License |
21 |
|
|
* along with this program; if not, write to the Free Software |
22 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 |
|
|
*---------------------------------------------------------------------*/ |
24 |
|
|
|
25 |
|
|
#include "../config.h" /* NECESSARY */ |
26 |
|
|
#include "rxvt.h" /* NECESSARY */ |
27 |
|
|
|
28 |
|
|
#ifdef HAVE_BG_PIXMAP |
29 |
sf-exg |
1.188 |
|
30 |
root |
1.14 |
void |
31 |
sf-exg |
1.142 |
rxvt_term::bg_destroy () |
32 |
sasha |
1.11 |
{ |
33 |
sf-exg |
1.246 |
# if BG_IMAGE_FROM_ROOT |
34 |
sf-exg |
1.236 |
delete root_img; |
35 |
root |
1.237 |
root_img = 0; |
36 |
sf-exg |
1.236 |
# endif |
37 |
|
|
|
38 |
root |
1.232 |
# if BG_IMAGE_FROM_FILE |
39 |
sf-exg |
1.233 |
fimage.destroy (); |
40 |
sf-exg |
1.221 |
# endif |
41 |
sasha |
1.11 |
} |
42 |
sasha |
1.2 |
|
43 |
sasha |
1.1 |
bool |
44 |
sf-exg |
1.142 |
rxvt_term::bg_window_size_sensitive () |
45 |
sasha |
1.1 |
{ |
46 |
sf-exg |
1.246 |
# if BG_IMAGE_FROM_ROOT |
47 |
sf-exg |
1.254 |
if (root_img) |
48 |
sasha |
1.13 |
return true; |
49 |
|
|
# endif |
50 |
|
|
|
51 |
root |
1.232 |
# if BG_IMAGE_FROM_FILE |
52 |
sf-exg |
1.236 |
if (fimage.img) |
53 |
sasha |
1.1 |
{ |
54 |
sf-exg |
1.233 |
if ((fimage.flags & IM_IS_SIZE_SENSITIVE) |
55 |
sf-exg |
1.236 |
|| fimage.img->w > szHint.width |
56 |
|
|
|| fimage.img->h > szHint.height) |
57 |
sasha |
1.1 |
return true; |
58 |
|
|
} |
59 |
|
|
# endif |
60 |
sasha |
1.13 |
|
61 |
|
|
return false; |
62 |
|
|
} |
63 |
|
|
|
64 |
sf-exg |
1.37 |
bool |
65 |
sf-exg |
1.142 |
rxvt_term::bg_window_position_sensitive () |
66 |
sasha |
1.13 |
{ |
67 |
sf-exg |
1.246 |
# if BG_IMAGE_FROM_ROOT |
68 |
sf-exg |
1.254 |
if (root_img) |
69 |
sasha |
1.1 |
return true; |
70 |
|
|
# endif |
71 |
sasha |
1.13 |
|
72 |
root |
1.232 |
# if BG_IMAGE_FROM_FILE |
73 |
sf-exg |
1.236 |
if (fimage.img) |
74 |
sasha |
1.13 |
{ |
75 |
sf-exg |
1.233 |
if (fimage.flags & IM_ROOT_ALIGN) |
76 |
sasha |
1.13 |
return true; |
77 |
|
|
} |
78 |
|
|
# endif |
79 |
|
|
|
80 |
sasha |
1.1 |
return false; |
81 |
sf-exg |
1.117 |
} |
82 |
sasha |
1.1 |
|
83 |
root |
1.232 |
# if BG_IMAGE_FROM_FILE |
84 |
sasha |
1.1 |
static inline int |
85 |
|
|
make_align_position (int align, int window_size, int image_size) |
86 |
|
|
{ |
87 |
sf-exg |
1.66 |
if (align >= 0 && align <= 100) |
88 |
sf-exg |
1.206 |
return lerp (0, window_size - image_size, align); |
89 |
sf-exg |
1.205 |
else if (align > 100) |
90 |
sf-exg |
1.206 |
return lerp (window_size - image_size, window_size, align - 100); |
91 |
sf-exg |
1.205 |
else |
92 |
sf-exg |
1.206 |
return lerp (-image_size, 0, align + 100); |
93 |
sasha |
1.1 |
} |
94 |
|
|
|
95 |
sf-exg |
1.219 |
static void |
96 |
|
|
parse_style (const char *style, int &x, int &y, unsigned int &w, unsigned int &h, uint8_t &flags) |
97 |
|
|
{ |
98 |
|
|
if (!strcasecmp (style, "tiled")) |
99 |
|
|
{ |
100 |
|
|
flags = IM_TILE; |
101 |
|
|
w = h = noScale; |
102 |
|
|
x = y = 0; |
103 |
|
|
} |
104 |
|
|
else if (!strcasecmp (style, "aspect-stretched")) |
105 |
|
|
{ |
106 |
|
|
flags = IM_KEEP_ASPECT; |
107 |
|
|
w = h = windowScale; |
108 |
|
|
x = y = centerAlign; |
109 |
|
|
} |
110 |
|
|
else if (!strcasecmp (style, "stretched")) |
111 |
|
|
{ |
112 |
|
|
flags = 0; |
113 |
|
|
w = h = windowScale; |
114 |
|
|
x = y = centerAlign; |
115 |
|
|
} |
116 |
|
|
else if (!strcasecmp (style, "centered")) |
117 |
|
|
{ |
118 |
|
|
flags = 0; |
119 |
|
|
w = h = noScale; |
120 |
|
|
x = y = centerAlign; |
121 |
|
|
} |
122 |
|
|
else if (!strcasecmp (style, "root-tiled")) |
123 |
|
|
{ |
124 |
|
|
flags = IM_TILE|IM_ROOT_ALIGN; |
125 |
|
|
w = h = noScale; |
126 |
|
|
x = y = 0; |
127 |
|
|
} |
128 |
|
|
} |
129 |
|
|
|
130 |
sasha |
1.1 |
bool |
131 |
sf-exg |
1.214 |
rxvt_image::set_geometry (const char *geom, bool update) |
132 |
sasha |
1.1 |
{ |
133 |
sf-exg |
1.110 |
bool changed = false; |
134 |
|
|
int geom_flags = 0; |
135 |
sf-exg |
1.198 |
int x = h_align; |
136 |
|
|
int y = v_align; |
137 |
|
|
unsigned int w = h_scale; |
138 |
|
|
unsigned int h = v_scale; |
139 |
sf-exg |
1.219 |
uint8_t new_flags = 0; |
140 |
sasha |
1.1 |
|
141 |
|
|
if (geom == NULL) |
142 |
|
|
return false; |
143 |
|
|
|
144 |
sf-exg |
1.163 |
if (geom[0]) |
145 |
sf-exg |
1.122 |
{ |
146 |
sf-exg |
1.163 |
char **arr = rxvt_strsplit (':', geom); |
147 |
sf-exg |
1.131 |
|
148 |
sf-exg |
1.173 |
for (int i = 0; arr[i]; i++) |
149 |
sasha |
1.1 |
{ |
150 |
sf-exg |
1.219 |
if (!strncasecmp (arr[i], "style=", 6)) |
151 |
sf-exg |
1.160 |
{ |
152 |
sf-exg |
1.219 |
parse_style (arr[i] + 6, x, y, w, h, new_flags); |
153 |
sf-exg |
1.160 |
geom_flags = WidthValue|HeightValue|XValue|YValue; |
154 |
|
|
} |
155 |
|
|
else if (!strcasecmp (arr[i], "op=tile")) |
156 |
sf-exg |
1.214 |
new_flags |= IM_TILE; |
157 |
sf-exg |
1.176 |
else if (!strcasecmp (arr[i], "op=keep-aspect")) |
158 |
sf-exg |
1.214 |
new_flags |= IM_KEEP_ASPECT; |
159 |
sf-exg |
1.176 |
else if (!strcasecmp (arr[i], "op=root-align")) |
160 |
sf-exg |
1.214 |
new_flags |= IM_ROOT_ALIGN; |
161 |
sf-exg |
1.160 |
|
162 |
|
|
// deprecated |
163 |
|
|
else if (!strcasecmp (arr[i], "tile")) |
164 |
sf-exg |
1.122 |
{ |
165 |
sf-exg |
1.214 |
new_flags |= IM_TILE; |
166 |
sf-exg |
1.122 |
w = h = noScale; |
167 |
|
|
geom_flags |= WidthValue|HeightValue; |
168 |
|
|
} |
169 |
sf-exg |
1.133 |
else if (!strcasecmp (arr[i], "propscale")) |
170 |
sf-exg |
1.122 |
{ |
171 |
sf-exg |
1.214 |
new_flags |= IM_KEEP_ASPECT; |
172 |
sf-exg |
1.177 |
w = h = windowScale; |
173 |
|
|
geom_flags |= WidthValue|HeightValue; |
174 |
sf-exg |
1.122 |
} |
175 |
sf-exg |
1.161 |
else if (!strcasecmp (arr[i], "hscale")) |
176 |
|
|
{ |
177 |
sf-exg |
1.214 |
new_flags |= IM_TILE; |
178 |
sf-exg |
1.161 |
w = windowScale; |
179 |
|
|
h = noScale; |
180 |
|
|
geom_flags |= WidthValue|HeightValue; |
181 |
|
|
} |
182 |
|
|
else if (!strcasecmp (arr[i], "vscale")) |
183 |
|
|
{ |
184 |
sf-exg |
1.214 |
new_flags |= IM_TILE; |
185 |
sf-exg |
1.161 |
h = windowScale; |
186 |
|
|
w = noScale; |
187 |
|
|
geom_flags |= WidthValue|HeightValue; |
188 |
|
|
} |
189 |
sf-exg |
1.133 |
else if (!strcasecmp (arr[i], "scale")) |
190 |
sf-exg |
1.122 |
{ |
191 |
sf-exg |
1.161 |
w = h = windowScale; |
192 |
sf-exg |
1.122 |
geom_flags |= WidthValue|HeightValue; |
193 |
|
|
} |
194 |
sf-exg |
1.161 |
else if (!strcasecmp (arr[i], "auto")) |
195 |
|
|
{ |
196 |
|
|
w = h = windowScale; |
197 |
|
|
x = y = centerAlign; |
198 |
|
|
geom_flags |= WidthValue|HeightValue|XValue|YValue; |
199 |
|
|
} |
200 |
sf-exg |
1.133 |
else if (!strcasecmp (arr[i], "root")) |
201 |
sf-exg |
1.122 |
{ |
202 |
sf-exg |
1.214 |
new_flags |= IM_TILE|IM_ROOT_ALIGN; |
203 |
sf-exg |
1.122 |
w = h = noScale; |
204 |
|
|
geom_flags |= WidthValue|HeightValue; |
205 |
|
|
} |
206 |
sf-exg |
1.163 |
|
207 |
|
|
else |
208 |
|
|
geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
209 |
sf-exg |
1.131 |
} /* done parsing ops */ |
210 |
root |
1.26 |
|
211 |
sf-exg |
1.131 |
rxvt_free_strsplit (arr); |
212 |
sf-exg |
1.122 |
} |
213 |
sasha |
1.1 |
|
214 |
sf-exg |
1.214 |
new_flags |= flags & ~IM_GEOMETRY_FLAGS; |
215 |
sf-exg |
1.185 |
|
216 |
sf-exg |
1.163 |
if (!update) |
217 |
|
|
{ |
218 |
|
|
if (!(geom_flags & XValue)) |
219 |
|
|
x = y = defaultAlign; |
220 |
|
|
else if (!(geom_flags & YValue)) |
221 |
|
|
y = x; |
222 |
|
|
|
223 |
|
|
if (!(geom_flags & (WidthValue|HeightValue))) |
224 |
|
|
w = h = defaultScale; |
225 |
|
|
else if (!(geom_flags & HeightValue)) |
226 |
|
|
h = w; |
227 |
|
|
else if (!(geom_flags & WidthValue)) |
228 |
|
|
w = h; |
229 |
|
|
} |
230 |
|
|
|
231 |
sf-exg |
1.198 |
clamp_it (x, -100, 200); |
232 |
|
|
clamp_it (y, -100, 200); |
233 |
|
|
|
234 |
sf-exg |
1.214 |
if (flags != new_flags |
235 |
sf-exg |
1.198 |
|| h_scale != w |
236 |
|
|
|| v_scale != h |
237 |
|
|
|| h_align != x |
238 |
|
|
|| v_align != y) |
239 |
sasha |
1.1 |
{ |
240 |
sf-exg |
1.214 |
flags = new_flags; |
241 |
sf-exg |
1.198 |
h_scale = w; |
242 |
|
|
v_scale = h; |
243 |
|
|
h_align = x; |
244 |
|
|
v_align = y; |
245 |
sf-exg |
1.110 |
changed = true; |
246 |
sasha |
1.1 |
} |
247 |
root |
1.26 |
|
248 |
sf-exg |
1.225 |
if (is_size_sensitive ()) |
249 |
sf-exg |
1.214 |
flags |= IM_IS_SIZE_SENSITIVE; |
250 |
|
|
else |
251 |
|
|
flags &= ~IM_IS_SIZE_SENSITIVE; |
252 |
|
|
|
253 |
sf-exg |
1.110 |
return changed; |
254 |
sasha |
1.1 |
} |
255 |
|
|
|
256 |
sf-exg |
1.256 |
void |
257 |
sf-exg |
1.255 |
rxvt_term::render_image (rxvt_image &image) |
258 |
sf-exg |
1.59 |
{ |
259 |
sf-exg |
1.236 |
int image_width = image.img->w; |
260 |
|
|
int image_height = image.img->h; |
261 |
sf-exg |
1.240 |
int parent_width = szHint.width; |
262 |
|
|
int parent_height = szHint.height; |
263 |
|
|
int h_scale = min (image.h_scale, 32767 * 100 / parent_width); |
264 |
|
|
int v_scale = min (image.v_scale, 32767 * 100 / parent_height); |
265 |
sf-exg |
1.59 |
|
266 |
sf-exg |
1.255 |
int w; |
267 |
|
|
int h; |
268 |
|
|
int x; |
269 |
|
|
int y; |
270 |
|
|
|
271 |
sf-exg |
1.240 |
w = h_scale * parent_width / 100; |
272 |
|
|
h = v_scale * parent_height / 100; |
273 |
sf-exg |
1.164 |
|
274 |
sf-exg |
1.214 |
if (image.flags & IM_KEEP_ASPECT) |
275 |
sf-exg |
1.62 |
{ |
276 |
sf-exg |
1.164 |
float scale = (float)w / image_width; |
277 |
|
|
min_it (scale, (float)h / image_height); |
278 |
sf-exg |
1.62 |
w = image_width * scale + 0.5; |
279 |
|
|
h = image_height * scale + 0.5; |
280 |
|
|
} |
281 |
sf-exg |
1.59 |
|
282 |
sf-exg |
1.68 |
if (!w) w = image_width; |
283 |
|
|
if (!h) h = image_height; |
284 |
|
|
|
285 |
sf-exg |
1.214 |
if (image.flags & IM_ROOT_ALIGN) |
286 |
sf-exg |
1.59 |
{ |
287 |
sf-exg |
1.239 |
x = -parent_x; |
288 |
|
|
y = -parent_y; |
289 |
sf-exg |
1.59 |
} |
290 |
sf-exg |
1.63 |
else |
291 |
|
|
{ |
292 |
sf-exg |
1.240 |
x = make_align_position (image.h_align, parent_width, w); |
293 |
|
|
y = make_align_position (image.v_align, parent_height, h); |
294 |
sf-exg |
1.63 |
} |
295 |
sf-exg |
1.55 |
|
296 |
sf-exg |
1.214 |
if (!(image.flags & IM_ROOT_ALIGN) |
297 |
sf-exg |
1.240 |
&& (x >= parent_width |
298 |
|
|
|| y >= parent_height |
299 |
sf-exg |
1.172 |
|| x + w <= 0 |
300 |
|
|
|| y + h <= 0)) |
301 |
sf-exg |
1.256 |
return; |
302 |
sf-exg |
1.55 |
|
303 |
sf-exg |
1.236 |
rxvt_img *img = image.img->scale (w, h); |
304 |
sf-exg |
1.55 |
|
305 |
sf-exg |
1.236 |
if (image.flags & IM_TILE) |
306 |
|
|
img->repeat_mode (RepeatNormal); |
307 |
sf-exg |
1.152 |
else |
308 |
sf-exg |
1.236 |
img->repeat_mode (RepeatNone); |
309 |
sf-exg |
1.240 |
img->sub_rect (-x, -y, parent_width, parent_height)->replace (img); |
310 |
sf-exg |
1.154 |
|
311 |
sf-exg |
1.250 |
if (bg_img) |
312 |
sf-exg |
1.245 |
img->draw (bg_img, PictOpOver, image.alpha * 1. / 0xffff); |
313 |
sf-exg |
1.79 |
|
314 |
sf-exg |
1.236 |
XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
315 |
|
|
img->convert_format (format, pix_colors [Color_bg])->replace (img); |
316 |
sf-exg |
1.55 |
|
317 |
sf-exg |
1.236 |
delete bg_img; |
318 |
|
|
bg_img = img; |
319 |
sf-exg |
1.55 |
} |
320 |
|
|
|
321 |
sf-exg |
1.220 |
rxvt_image::rxvt_image () |
322 |
|
|
{ |
323 |
sf-exg |
1.224 |
alpha = 0xffff; |
324 |
|
|
flags = 0; |
325 |
sf-exg |
1.220 |
h_scale = |
326 |
sf-exg |
1.224 |
v_scale = defaultScale; |
327 |
sf-exg |
1.220 |
h_align = |
328 |
sf-exg |
1.224 |
v_align = defaultAlign; |
329 |
sf-exg |
1.220 |
|
330 |
sf-exg |
1.236 |
img = 0; |
331 |
sf-exg |
1.220 |
} |
332 |
|
|
|
333 |
sf-exg |
1.241 |
void |
334 |
sf-exg |
1.236 |
rxvt_image::set_file_geometry (rxvt_screen *s, const char *file) |
335 |
sasha |
1.1 |
{ |
336 |
sf-exg |
1.107 |
if (!file || !*file) |
337 |
sf-exg |
1.241 |
return; |
338 |
sasha |
1.1 |
|
339 |
sf-exg |
1.167 |
const char *p = strchr (file, ';'); |
340 |
|
|
|
341 |
|
|
if (p) |
342 |
sasha |
1.1 |
{ |
343 |
sf-exg |
1.107 |
size_t len = p - file; |
344 |
|
|
char *f = rxvt_temp_buf<char> (len + 1); |
345 |
|
|
memcpy (f, file, len); |
346 |
|
|
f[len] = '\0'; |
347 |
|
|
file = f; |
348 |
|
|
} |
349 |
root |
1.25 |
|
350 |
sf-exg |
1.241 |
set_file (s, file); |
351 |
sf-exg |
1.220 |
alpha = 0x8000; |
352 |
sf-exg |
1.241 |
set_geometry (p ? p + 1 : ""); |
353 |
sf-exg |
1.220 |
} |
354 |
|
|
|
355 |
sf-exg |
1.241 |
void |
356 |
sf-exg |
1.236 |
rxvt_image::set_file (rxvt_screen *s, const char *file) |
357 |
sf-exg |
1.220 |
{ |
358 |
sf-exg |
1.241 |
rxvt_img *img2 = rxvt_img::new_from_file (s, file); |
359 |
sf-exg |
1.236 |
delete img; |
360 |
sf-exg |
1.241 |
img = img2; |
361 |
sasha |
1.1 |
} |
362 |
|
|
|
363 |
ayin |
1.12 |
# endif /* BG_IMAGE_FROM_FILE */ |
364 |
sasha |
1.1 |
|
365 |
ayin |
1.10 |
bool |
366 |
sf-exg |
1.226 |
image_effects::set_blur (const char *geom) |
367 |
sasha |
1.1 |
{ |
368 |
sf-exg |
1.110 |
bool changed = false; |
369 |
sasha |
1.1 |
unsigned int hr, vr; |
370 |
|
|
int junk; |
371 |
|
|
int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
372 |
|
|
|
373 |
sf-exg |
1.52 |
if (!(geom_flags & WidthValue)) |
374 |
sasha |
1.1 |
hr = 1; |
375 |
sf-exg |
1.52 |
if (!(geom_flags & HeightValue)) |
376 |
sasha |
1.1 |
vr = hr; |
377 |
|
|
|
378 |
sf-exg |
1.80 |
min_it (hr, 128); |
379 |
|
|
min_it (vr, 128); |
380 |
|
|
|
381 |
sasha |
1.1 |
if (h_blurRadius != hr) |
382 |
|
|
{ |
383 |
sf-exg |
1.110 |
changed = true; |
384 |
sasha |
1.1 |
h_blurRadius = hr; |
385 |
|
|
} |
386 |
|
|
|
387 |
|
|
if (v_blurRadius != vr) |
388 |
|
|
{ |
389 |
sf-exg |
1.110 |
changed = true; |
390 |
sasha |
1.1 |
v_blurRadius = vr; |
391 |
|
|
} |
392 |
ayin |
1.10 |
|
393 |
sf-exg |
1.110 |
return changed; |
394 |
sasha |
1.1 |
} |
395 |
|
|
|
396 |
|
|
bool |
397 |
sf-exg |
1.226 |
image_effects::set_tint (const rxvt_color &new_tint) |
398 |
sasha |
1.1 |
{ |
399 |
sf-exg |
1.226 |
if (!tint_set || tint != new_tint) |
400 |
sasha |
1.1 |
{ |
401 |
|
|
tint = new_tint; |
402 |
sf-exg |
1.226 |
tint_set = true; |
403 |
sf-exg |
1.203 |
|
404 |
sasha |
1.1 |
return true; |
405 |
|
|
} |
406 |
root |
1.20 |
|
407 |
sasha |
1.1 |
return false; |
408 |
|
|
} |
409 |
|
|
|
410 |
|
|
bool |
411 |
sf-exg |
1.226 |
image_effects::set_shade (const char *shade_str) |
412 |
sasha |
1.1 |
{ |
413 |
sf-exg |
1.186 |
int new_shade = atoi (shade_str); |
414 |
sasha |
1.1 |
|
415 |
sf-exg |
1.75 |
clamp_it (new_shade, -100, 200); |
416 |
|
|
if (new_shade < 0) |
417 |
root |
1.20 |
new_shade = 200 - (100 + new_shade); |
418 |
sasha |
1.1 |
|
419 |
|
|
if (new_shade != shade) |
420 |
|
|
{ |
421 |
|
|
shade = new_shade; |
422 |
|
|
return true; |
423 |
|
|
} |
424 |
root |
1.20 |
|
425 |
sasha |
1.1 |
return false; |
426 |
|
|
} |
427 |
|
|
|
428 |
sf-exg |
1.246 |
# if BG_IMAGE_FROM_ROOT |
429 |
sf-exg |
1.149 |
/* |
430 |
sf-exg |
1.100 |
* Builds a pixmap of the same size as the terminal window that contains |
431 |
|
|
* the tiled portion of the root pixmap that is supposed to be covered by |
432 |
sasha |
1.1 |
* our window. |
433 |
|
|
*/ |
434 |
sf-exg |
1.256 |
void |
435 |
sf-exg |
1.228 |
rxvt_term::render_root_image () |
436 |
sasha |
1.1 |
{ |
437 |
sf-exg |
1.39 |
/* root dimensions may change from call to call - but Display structure should |
438 |
sasha |
1.1 |
* be always up-to-date, so let's use it : |
439 |
|
|
*/ |
440 |
sf-exg |
1.142 |
int screen = display->screen; |
441 |
sasha |
1.1 |
int root_width = DisplayWidth (dpy, screen); |
442 |
|
|
int root_height = DisplayHeight (dpy, screen); |
443 |
sf-exg |
1.240 |
int parent_width = szHint.width; |
444 |
|
|
int parent_height = szHint.height; |
445 |
sasha |
1.1 |
int sx, sy; |
446 |
|
|
|
447 |
sf-exg |
1.239 |
sx = parent_x; |
448 |
|
|
sy = parent_y; |
449 |
sasha |
1.1 |
|
450 |
|
|
/* check if we are outside of the visible part of the virtual screen : */ |
451 |
sf-exg |
1.240 |
if (sx + parent_width <= 0 || sy + parent_height <= 0 |
452 |
sasha |
1.1 |
|| sx >= root_width || sy >= root_height) |
453 |
sf-exg |
1.256 |
return; |
454 |
sasha |
1.1 |
|
455 |
sf-exg |
1.236 |
while (sx < 0) sx += root_img->w; |
456 |
|
|
while (sy < 0) sy += root_img->h; |
457 |
sf-exg |
1.103 |
|
458 |
sf-exg |
1.240 |
rxvt_img *img = root_img->sub_rect (sx, sy, parent_width, parent_height); |
459 |
sf-exg |
1.103 |
|
460 |
sf-exg |
1.236 |
if (root_effects.need_blur ()) |
461 |
|
|
img->blur (root_effects.h_blurRadius, root_effects.v_blurRadius)->replace (img); |
462 |
sf-exg |
1.103 |
|
463 |
sf-exg |
1.236 |
if (root_effects.need_tint ()) |
464 |
sf-exg |
1.257 |
{ |
465 |
|
|
rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
466 |
|
|
|
467 |
|
|
if (root_effects.tint_set) |
468 |
|
|
root_effects.tint.get (c); |
469 |
|
|
rxvt_img::nv factor = root_effects.shade / 100. - 1.; |
470 |
|
|
img->shade (factor, c)->replace (img); |
471 |
|
|
} |
472 |
sf-exg |
1.103 |
|
473 |
sf-exg |
1.236 |
XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
474 |
|
|
img->convert_format (format, pix_colors [Color_bg])->replace (img); |
475 |
sf-exg |
1.103 |
|
476 |
sf-exg |
1.236 |
delete bg_img; |
477 |
|
|
bg_img = img; |
478 |
sasha |
1.1 |
} |
479 |
sf-exg |
1.246 |
# endif /* BG_IMAGE_FROM_ROOT */ |
480 |
sasha |
1.1 |
|
481 |
sf-exg |
1.234 |
void |
482 |
sf-exg |
1.142 |
rxvt_term::bg_render () |
483 |
sasha |
1.1 |
{ |
484 |
sf-exg |
1.235 |
if (bg_flags & BG_INHIBIT_RENDER) |
485 |
|
|
return; |
486 |
|
|
|
487 |
sf-exg |
1.250 |
delete bg_img; |
488 |
|
|
bg_img = 0; |
489 |
sf-exg |
1.251 |
bg_flags = 0; |
490 |
sf-exg |
1.249 |
|
491 |
sf-exg |
1.252 |
if (!mapped) |
492 |
|
|
return; |
493 |
|
|
|
494 |
sf-exg |
1.246 |
# if BG_IMAGE_FROM_ROOT |
495 |
sf-exg |
1.254 |
if (root_img) |
496 |
sf-exg |
1.256 |
{ |
497 |
|
|
render_root_image (); |
498 |
sf-exg |
1.253 |
bg_flags |= BG_IS_TRANSPARENT; |
499 |
sf-exg |
1.256 |
} |
500 |
sasha |
1.1 |
# endif |
501 |
|
|
|
502 |
root |
1.232 |
# if BG_IMAGE_FROM_FILE |
503 |
sf-exg |
1.236 |
if (fimage.img) |
504 |
sf-exg |
1.253 |
render_image (fimage); |
505 |
sf-exg |
1.46 |
# endif |
506 |
sasha |
1.7 |
|
507 |
sf-exg |
1.142 |
scr_recolour (false); |
508 |
sf-exg |
1.143 |
bg_flags |= BG_NEEDS_REFRESH; |
509 |
sasha |
1.1 |
|
510 |
sf-exg |
1.142 |
bg_valid_since = ev::now (); |
511 |
sasha |
1.1 |
} |
512 |
|
|
|
513 |
sf-exg |
1.106 |
void |
514 |
sf-exg |
1.142 |
rxvt_term::bg_init () |
515 |
sasha |
1.1 |
{ |
516 |
sf-exg |
1.246 |
#if BG_IMAGE_FROM_ROOT |
517 |
sf-exg |
1.242 |
if (option (Opt_transparent)) |
518 |
|
|
{ |
519 |
|
|
if (rs [Rs_blurradius]) |
520 |
|
|
root_effects.set_blur (rs [Rs_blurradius]); |
521 |
|
|
|
522 |
|
|
if (ISSET_PIXCOLOR (Color_tint)) |
523 |
|
|
root_effects.set_tint (pix_colors_focused [Color_tint]); |
524 |
|
|
|
525 |
|
|
if (rs [Rs_shade]) |
526 |
|
|
root_effects.set_shade (rs [Rs_shade]); |
527 |
|
|
|
528 |
sf-exg |
1.255 |
rxvt_img::new_from_root (this)->replace (root_img); |
529 |
sf-exg |
1.242 |
XSelectInput (dpy, display->root, PropertyChangeMask); |
530 |
|
|
rootwin_ev.start (display, display->root); |
531 |
|
|
} |
532 |
|
|
#endif |
533 |
|
|
|
534 |
root |
1.232 |
#if BG_IMAGE_FROM_FILE |
535 |
sf-exg |
1.220 |
if (rs[Rs_backgroundPixmap]) |
536 |
|
|
{ |
537 |
sf-exg |
1.241 |
fimage.set_file_geometry (this, rs[Rs_backgroundPixmap]); |
538 |
|
|
if (!bg_window_position_sensitive ()) |
539 |
sf-exg |
1.233 |
update_background (); |
540 |
sf-exg |
1.220 |
} |
541 |
|
|
#endif |
542 |
sasha |
1.1 |
} |
543 |
|
|
|
544 |
sf-exg |
1.226 |
#endif /* HAVE_BG_PIXMAP */ |