… | |
… | |
30 | # include <X11/extensions/Xrender.h> |
30 | # include <X11/extensions/Xrender.h> |
31 | #endif |
31 | #endif |
32 | |
32 | |
33 | #ifndef FilterConvolution |
33 | #ifndef FilterConvolution |
34 | #define FilterConvolution "convolution" |
34 | #define FilterConvolution "convolution" |
35 | #endif |
|
|
36 | |
|
|
37 | #define DO_TIMING_TEST 0 |
|
|
38 | |
|
|
39 | #if DO_TIMING_TEST |
|
|
40 | # include <sys/time.h> |
|
|
41 | #define TIMING_TEST_START(id) \ |
|
|
42 | struct timeval timing_test_##id##_stv; \ |
|
|
43 | gettimeofday (&timing_test_##id##_stv, NULL); |
|
|
44 | |
|
|
45 | #define TIMING_TEST_PRINT_RESULT(id) \ |
|
|
46 | do { \ |
|
|
47 | struct timeval tv; \ |
|
|
48 | gettimeofday (&tv, NULL); \ |
|
|
49 | tv.tv_sec -= (timing_test_##id##_stv).tv_sec; \ |
|
|
50 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__, \ |
|
|
51 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec); \ |
|
|
52 | } while (0) |
|
|
53 | |
|
|
54 | #else |
|
|
55 | #define TIMING_TEST_START(id) do {} while (0) |
|
|
56 | #define TIMING_TEST_PRINT_RESULT(id) do {} while (0) |
|
|
57 | #endif |
35 | #endif |
58 | |
36 | |
59 | /* |
37 | /* |
60 | * Pixmap geometry string interpretation : |
38 | * Pixmap geometry string interpretation : |
61 | * Each geometry string contains zero or one scale/position |
39 | * Each geometry string contains zero or one scale/position |
… | |
… | |
81 | * scale Scale both up and down |
59 | * scale Scale both up and down |
82 | * auto Same as 100x100+50+50 |
60 | * auto Same as 100x100+50+50 |
83 | */ |
61 | */ |
84 | |
62 | |
85 | #ifdef HAVE_BG_PIXMAP |
63 | #ifdef HAVE_BG_PIXMAP |
86 | bgPixmap_t::bgPixmap_t () |
|
|
87 | { |
|
|
88 | // this is basically redundant as bgPixmap_t is only used in |
|
|
89 | // zero_initialised-derived structs |
|
|
90 | #ifdef HAVE_AFTERIMAGE |
|
|
91 | original_asim = NULL; |
|
|
92 | #endif |
|
|
93 | #ifdef HAVE_PIXBUF |
|
|
94 | pixbuf = NULL; |
|
|
95 | #endif |
|
|
96 | #ifdef BG_IMAGE_FROM_FILE |
|
|
97 | have_image = false; |
|
|
98 | h_scale = v_scale = 0; |
|
|
99 | h_align = v_align = 0; |
|
|
100 | #endif |
|
|
101 | #ifdef ENABLE_TRANSPARENCY |
|
|
102 | shade = 100; |
|
|
103 | #endif |
|
|
104 | flags = 0; |
|
|
105 | pixmap = None; |
|
|
106 | valid_since = invalid_since = 0; |
|
|
107 | target = 0; |
|
|
108 | target_x = target_y = 0; |
|
|
109 | } |
|
|
110 | |
|
|
111 | void |
64 | void |
112 | bgPixmap_t::destroy () |
65 | rxvt_term::bg_destroy () |
113 | { |
66 | { |
114 | #ifdef HAVE_AFTERIMAGE |
67 | #ifdef HAVE_AFTERIMAGE |
115 | if (original_asim) |
68 | if (original_asim) |
116 | safe_asimage_destroy (original_asim); |
69 | safe_asimage_destroy (original_asim); |
117 | #endif |
70 | #endif |
… | |
… | |
119 | #ifdef HAVE_PIXBUF |
72 | #ifdef HAVE_PIXBUF |
120 | if (pixbuf) |
73 | if (pixbuf) |
121 | g_object_unref (pixbuf); |
74 | g_object_unref (pixbuf); |
122 | #endif |
75 | #endif |
123 | |
76 | |
124 | if (pixmap && target) |
77 | if (bg_pixmap) |
125 | XFreePixmap (target->dpy, pixmap); |
78 | XFreePixmap (dpy, bg_pixmap); |
126 | } |
79 | } |
127 | |
80 | |
128 | bool |
81 | bool |
129 | bgPixmap_t::set_position (int x, int y) |
82 | rxvt_term::bg_set_position (int x, int y) |
130 | { |
83 | { |
131 | |
84 | |
132 | if (target_x != x |
85 | if (target_x != x |
133 | || target_y != y) |
86 | || target_y != y) |
134 | { |
87 | { |
… | |
… | |
138 | } |
91 | } |
139 | return false; |
92 | return false; |
140 | } |
93 | } |
141 | |
94 | |
142 | bool |
95 | bool |
143 | bgPixmap_t::window_size_sensitive () |
96 | rxvt_term::bg_window_size_sensitive () |
144 | { |
97 | { |
145 | # ifdef ENABLE_TRANSPARENCY |
98 | # ifdef ENABLE_TRANSPARENCY |
146 | if (flags & isTransparent) |
99 | if (bg_flags & BG_IS_TRANSPARENT) |
147 | return true; |
100 | return true; |
148 | # endif |
101 | # endif |
149 | |
102 | |
150 | # ifdef BG_IMAGE_FROM_FILE |
103 | # ifdef BG_IMAGE_FROM_FILE |
151 | if (have_image) |
104 | if (have_image) |
152 | { |
105 | { |
153 | if (flags & sizeSensitive) |
106 | if (bg_flags & BG_IS_SIZE_SENSITIVE) |
154 | return true; |
107 | return true; |
155 | } |
108 | } |
156 | # endif |
109 | # endif |
157 | |
110 | |
158 | return false; |
111 | return false; |
159 | } |
112 | } |
160 | |
113 | |
161 | bool |
114 | bool |
162 | bgPixmap_t::window_position_sensitive () |
115 | rxvt_term::bg_window_position_sensitive () |
163 | { |
116 | { |
164 | # ifdef ENABLE_TRANSPARENCY |
117 | # ifdef ENABLE_TRANSPARENCY |
165 | if (flags & isTransparent) |
118 | if (bg_flags & BG_IS_TRANSPARENT) |
166 | return true; |
119 | return true; |
167 | # endif |
120 | # endif |
168 | |
121 | |
169 | # ifdef BG_IMAGE_FROM_FILE |
122 | # ifdef BG_IMAGE_FROM_FILE |
170 | if (have_image) |
123 | if (have_image) |
171 | { |
124 | { |
172 | if (flags & rootAlign) |
125 | if (bg_flags & BG_ROOT_ALIGN) |
173 | return true; |
126 | return true; |
174 | } |
127 | } |
175 | # endif |
128 | # endif |
176 | |
129 | |
177 | return false; |
130 | return false; |
… | |
… | |
244 | dst_size = target_size - dst_pos; |
197 | dst_size = target_size - dst_pos; |
245 | return src_pos; |
198 | return src_pos; |
246 | } |
199 | } |
247 | |
200 | |
248 | bool |
201 | bool |
249 | bgPixmap_t::set_geometry (const char *geom, bool update) |
202 | rxvt_term::bg_set_geometry (const char *geom, bool update) |
250 | { |
203 | { |
251 | bool changed = false; |
204 | bool changed = false; |
252 | int geom_flags = 0; |
205 | int geom_flags = 0; |
253 | int x = 0, y = 0; |
206 | int x = 0, y = 0; |
254 | unsigned int w = 0, h = 0; |
207 | unsigned int w = 0, h = 0; |
255 | unsigned int n; |
208 | unsigned int n; |
256 | unsigned long new_flags = (flags & (~geometryFlags)); |
209 | unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS)); |
257 | const char *ops; |
210 | const char *ops; |
258 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
|
|
259 | |
211 | |
260 | if (geom == NULL) |
212 | if (geom == NULL) |
261 | return false; |
213 | return false; |
262 | |
214 | |
263 | char str[MAXLEN_GEOM]; |
215 | char str[256]; |
264 | |
216 | |
265 | ops = strchr (geom, ':'); |
217 | ops = strchr (geom, ':'); |
266 | if (ops == NULL) |
218 | if (ops == NULL) |
267 | n = strlen (geom); |
219 | n = strlen (geom); |
268 | else |
220 | else |
269 | n = ops - geom; |
221 | n = ops - geom; |
270 | |
222 | |
271 | if (n >= MAXLEN_GEOM) |
223 | if (n >= sizeof (str)) |
272 | return false; |
224 | return false; |
273 | |
225 | |
274 | memcpy (str, geom, n); |
226 | memcpy (str, geom, n); |
275 | str[n] = '\0'; |
227 | str[n] = '\0'; |
276 | rxvt_strtrim (str); |
228 | rxvt_strtrim (str); |
… | |
… | |
302 | { |
254 | { |
303 | char **arr = rxvt_strsplit (':', ops + 1); |
255 | char **arr = rxvt_strsplit (':', ops + 1); |
304 | |
256 | |
305 | for (int i = 0; arr[i]; i++) |
257 | for (int i = 0; arr[i]; i++) |
306 | { |
258 | { |
307 | # define CHECK_GEOM_OPS(op_str) (strcasecmp (arr[i], (op_str)) == 0) |
259 | if (!strcasecmp (arr[i], "tile")) |
308 | if (CHECK_GEOM_OPS ("tile")) |
|
|
309 | { |
260 | { |
310 | w = h = noScale; |
261 | w = h = noScale; |
311 | geom_flags |= WidthValue|HeightValue; |
262 | geom_flags |= WidthValue|HeightValue; |
312 | } |
263 | } |
313 | else if (CHECK_GEOM_OPS ("propscale")) |
264 | else if (!strcasecmp (arr[i], "propscale")) |
314 | { |
|
|
315 | new_flags |= propScale; |
|
|
316 | } |
265 | { |
317 | else if (CHECK_GEOM_OPS ("hscale")) |
266 | new_flags |= BG_PROP_SCALE; |
|
|
267 | } |
|
|
268 | else if (!strcasecmp (arr[i], "hscale")) |
318 | { |
269 | { |
319 | if (w == 0) w = windowScale; |
270 | if (w == 0) w = windowScale; |
320 | |
271 | |
321 | h = noScale; |
272 | h = noScale; |
322 | geom_flags |= WidthValue|HeightValue; |
273 | geom_flags |= WidthValue|HeightValue; |
323 | } |
274 | } |
324 | else if (CHECK_GEOM_OPS ("vscale")) |
275 | else if (!strcasecmp (arr[i], "vscale")) |
325 | { |
276 | { |
326 | if (h == 0) h = windowScale; |
277 | if (h == 0) h = windowScale; |
327 | |
278 | |
328 | w = noScale; |
279 | w = noScale; |
329 | geom_flags |= WidthValue|HeightValue; |
280 | geom_flags |= WidthValue|HeightValue; |
330 | } |
281 | } |
331 | else if (CHECK_GEOM_OPS ("scale")) |
282 | else if (!strcasecmp (arr[i], "scale")) |
332 | { |
283 | { |
333 | if (h == 0) h = windowScale; |
284 | if (h == 0) h = windowScale; |
334 | if (w == 0) w = windowScale; |
285 | if (w == 0) w = windowScale; |
335 | |
286 | |
336 | geom_flags |= WidthValue|HeightValue; |
287 | geom_flags |= WidthValue|HeightValue; |
337 | } |
288 | } |
338 | else if (CHECK_GEOM_OPS ("auto")) |
289 | else if (!strcasecmp (arr[i], "auto")) |
339 | { |
290 | { |
340 | w = h = windowScale; |
291 | w = h = windowScale; |
341 | x = y = centerAlign; |
292 | x = y = centerAlign; |
342 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
293 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
343 | } |
294 | } |
344 | else if (CHECK_GEOM_OPS ("root")) |
295 | else if (!strcasecmp (arr[i], "root")) |
345 | { |
296 | { |
346 | new_flags |= rootAlign; |
297 | new_flags |= BG_ROOT_ALIGN; |
347 | w = h = noScale; |
298 | w = h = noScale; |
348 | geom_flags |= WidthValue|HeightValue; |
299 | geom_flags |= WidthValue|HeightValue; |
349 | } |
300 | } |
350 | # undef CHECK_GEOM_OPS |
|
|
351 | } /* done parsing ops */ |
301 | } /* done parsing ops */ |
352 | |
302 | |
353 | rxvt_free_strsplit (arr); |
303 | rxvt_free_strsplit (arr); |
354 | } |
304 | } |
355 | |
305 | |
356 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
306 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
357 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
307 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
358 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
308 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
359 | if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; |
309 | if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; |
360 | |
310 | |
361 | if (new_flags != flags) |
311 | if (new_flags != bg_flags) |
362 | { |
312 | { |
363 | flags = new_flags; |
313 | bg_flags = new_flags; |
364 | changed = true; |
314 | changed = true; |
365 | } |
315 | } |
366 | |
316 | |
367 | return changed; |
317 | return changed; |
368 | } |
318 | } |
369 | |
319 | |
370 | void |
320 | void |
371 | bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
321 | rxvt_term::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
372 | { |
322 | { |
373 | int target_width = target->szHint.width; |
323 | int target_width = szHint.width; |
374 | int target_height = target->szHint.height; |
324 | int target_height = szHint.height; |
375 | |
325 | |
376 | if (flags & propScale) |
326 | if (bg_flags & BG_PROP_SCALE) |
377 | { |
327 | { |
378 | float scale = (float)target_width / image_width; |
328 | float scale = (float)target_width / image_width; |
379 | min_it (scale, (float)target_height / image_height); |
329 | min_it (scale, (float)target_height / image_height); |
380 | w = image_width * scale + 0.5; |
330 | w = image_width * scale + 0.5; |
381 | h = image_height * scale + 0.5; |
331 | h = image_height * scale + 0.5; |
… | |
… | |
387 | } |
337 | } |
388 | |
338 | |
389 | if (!w) w = image_width; |
339 | if (!w) w = image_width; |
390 | if (!h) h = image_height; |
340 | if (!h) h = image_height; |
391 | |
341 | |
392 | if (flags & rootAlign) |
342 | if (bg_flags & BG_ROOT_ALIGN) |
393 | { |
343 | { |
394 | x = -target_x; |
344 | x = -target_x; |
395 | y = -target_y; |
345 | y = -target_y; |
396 | } |
346 | } |
397 | else |
347 | else |
398 | { |
348 | { |
399 | x = make_align_position (h_align, target_width, w); |
349 | x = make_align_position (h_align, target_width, w); |
400 | y = make_align_position (v_align, target_height, h); |
350 | y = make_align_position (v_align, target_height, h); |
401 | } |
351 | } |
402 | |
352 | |
403 | flags &= ~sizeSensitive; |
353 | bg_flags &= ~BG_IS_SIZE_SENSITIVE; |
404 | if ((flags & propScale) || h_scale || v_scale |
354 | if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale |
405 | || (!(flags & rootAlign) && (h_align || v_align)) |
355 | || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) |
406 | || w > target_width || h > target_height) |
356 | || w > target_width || h > target_height) |
407 | flags |= sizeSensitive; |
357 | bg_flags |= BG_IS_SIZE_SENSITIVE; |
408 | } |
358 | } |
409 | |
359 | |
410 | # ifdef HAVE_AFTERIMAGE |
360 | # ifdef HAVE_AFTERIMAGE |
411 | bool |
361 | bool |
412 | bgPixmap_t::render_image (unsigned long background_flags) |
362 | rxvt_term::render_image (unsigned long tr_flags) |
413 | { |
363 | { |
414 | if (target == NULL) |
|
|
415 | return false; |
|
|
416 | |
|
|
417 | target->init_asv (); |
364 | init_asv (); |
418 | |
365 | |
419 | ASImage *background = NULL; |
366 | ASImage *background = NULL; |
420 | ARGB32 background_tint = TINT_LEAVE_SAME; |
367 | ARGB32 background_tint = TINT_LEAVE_SAME; |
421 | |
368 | |
422 | # ifdef ENABLE_TRANSPARENCY |
369 | # ifdef ENABLE_TRANSPARENCY |
423 | if (background_flags) |
370 | if (tr_flags) |
424 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
371 | background = pixmap2ximage (asv, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, 100); |
425 | |
372 | |
426 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
373 | if (tr_flags & BG_NEEDS_TINT) |
427 | { |
374 | { |
428 | ShadingInfo as_shade; |
375 | ShadingInfo as_shade; |
429 | as_shade.shading = shade; |
376 | as_shade.shading = shade; |
430 | |
377 | |
431 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
378 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
432 | if (flags & tintSet) |
379 | if (bg_flags & BG_TINT_SET) |
433 | tint.get (c); |
380 | tint.get (c); |
434 | as_shade.tintColor.red = c.r; |
381 | as_shade.tintColor.red = c.r; |
435 | as_shade.tintColor.green = c.g; |
382 | as_shade.tintColor.green = c.g; |
436 | as_shade.tintColor.blue = c.b; |
383 | as_shade.tintColor.blue = c.b; |
437 | |
384 | |
438 | background_tint = shading2tint32 (&as_shade); |
385 | background_tint = shading2tint32 (&as_shade); |
439 | } |
386 | } |
440 | |
387 | |
441 | if (!(background_flags & transpPmapBlurred) && (flags & blurNeeded) && background != NULL) |
388 | if ((tr_flags & BG_NEEDS_BLUR) && background != NULL) |
442 | { |
389 | { |
443 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
390 | ASImage *tmp = blur_asimage_gauss (asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
444 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
391 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
445 | 100, ASIMAGE_QUALITY_DEFAULT); |
392 | 100, ASIMAGE_QUALITY_DEFAULT); |
446 | if (tmp) |
393 | if (tmp) |
447 | { |
394 | { |
448 | destroy_asimage (&background); |
395 | destroy_asimage (&background); |
… | |
… | |
451 | } |
398 | } |
452 | # endif |
399 | # endif |
453 | |
400 | |
454 | ASImage *result = 0; |
401 | ASImage *result = 0; |
455 | |
402 | |
456 | int target_width = target->szHint.width; |
403 | int target_width = szHint.width; |
457 | int target_height = target->szHint.height; |
404 | int target_height = szHint.height; |
458 | int new_pmap_width = target_width; |
405 | int new_pmap_width = target_width; |
459 | int new_pmap_height = target_height; |
406 | int new_pmap_height = target_height; |
460 | |
407 | |
461 | int x = 0; |
408 | int x = 0; |
462 | int y = 0; |
409 | int y = 0; |
… | |
… | |
465 | |
412 | |
466 | if (original_asim) |
413 | if (original_asim) |
467 | get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); |
414 | get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); |
468 | |
415 | |
469 | if (!original_asim |
416 | if (!original_asim |
470 | || (!(flags & rootAlign) |
417 | || (!(bg_flags & BG_ROOT_ALIGN) |
471 | && (x >= target_width |
418 | && (x >= target_width |
472 | || y >= target_height |
419 | || y >= target_height |
473 | || (x + w <= 0) |
420 | || (x + w <= 0) |
474 | || (y + h <= 0)))) |
421 | || (y + h <= 0)))) |
475 | { |
422 | { |
… | |
… | |
479 | new_pmap_height = background->height; |
426 | new_pmap_height = background->height; |
480 | result = background; |
427 | result = background; |
481 | |
428 | |
482 | if (background_tint != TINT_LEAVE_SAME) |
429 | if (background_tint != TINT_LEAVE_SAME) |
483 | { |
430 | { |
484 | ASImage *tmp = tile_asimage (target->asv, background, 0, 0, |
431 | ASImage *tmp = tile_asimage (asv, background, 0, 0, |
485 | target_width, target_height, background_tint, |
432 | target_width, target_height, background_tint, |
486 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
433 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
487 | if (tmp) |
434 | if (tmp) |
488 | result = tmp; |
435 | result = tmp; |
489 | } |
436 | } |
… | |
… | |
496 | result = original_asim; |
443 | result = original_asim; |
497 | |
444 | |
498 | if ((w != original_asim->width) |
445 | if ((w != original_asim->width) |
499 | || (h != original_asim->height)) |
446 | || (h != original_asim->height)) |
500 | { |
447 | { |
501 | result = scale_asimage (target->asv, original_asim, |
448 | result = scale_asimage (asv, original_asim, |
502 | w, h, |
449 | w, h, |
503 | background ? ASA_ASImage : ASA_XImage, |
450 | background ? ASA_ASImage : ASA_XImage, |
504 | 100, ASIMAGE_QUALITY_DEFAULT); |
451 | 100, ASIMAGE_QUALITY_DEFAULT); |
505 | } |
452 | } |
506 | |
453 | |
… | |
… | |
512 | but there is no need to make it bigger than the window! */ |
459 | but there is no need to make it bigger than the window! */ |
513 | new_pmap_width = min (result->width, target_width); |
460 | new_pmap_width = min (result->width, target_width); |
514 | new_pmap_height = min (result->height, target_height); |
461 | new_pmap_height = min (result->height, target_height); |
515 | |
462 | |
516 | /* we also need to tile our image in both directions */ |
463 | /* we also need to tile our image in both directions */ |
517 | ASImage *tmp = tile_asimage (target->asv, result, |
464 | ASImage *tmp = tile_asimage (asv, result, |
518 | (int)result->width - x, |
465 | (int)result->width - x, |
519 | (int)result->height - y, |
466 | (int)result->height - y, |
520 | new_pmap_width, |
467 | new_pmap_width, |
521 | new_pmap_height, |
468 | new_pmap_height, |
522 | TINT_LEAVE_SAME, ASA_XImage, |
469 | TINT_LEAVE_SAME, ASA_XImage, |
… | |
… | |
565 | { |
512 | { |
566 | layers[1].dst_y = y; |
513 | layers[1].dst_y = y; |
567 | layers[1].clip_height = result->height; |
514 | layers[1].clip_height = result->height; |
568 | } |
515 | } |
569 | |
516 | |
570 | if (target->rs[Rs_blendtype]) |
517 | if (rs[Rs_blendtype]) |
571 | { |
518 | { |
572 | layers[1].merge_scanlines = blend_scanlines_name2func (target->rs[Rs_blendtype]); |
519 | layers[1].merge_scanlines = blend_scanlines_name2func (rs[Rs_blendtype]); |
573 | if (layers[1].merge_scanlines == NULL) |
520 | if (layers[1].merge_scanlines == NULL) |
574 | layers[1].merge_scanlines = alphablend_scanlines; |
521 | layers[1].merge_scanlines = alphablend_scanlines; |
575 | } |
522 | } |
576 | |
523 | |
577 | ASImage *tmp = merge_layers (target->asv, layers, 2, target_width, target_height, |
524 | ASImage *tmp = merge_layers (asv, layers, 2, target_width, target_height, |
578 | ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
525 | ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
579 | |
526 | |
580 | if (tmp) |
527 | if (tmp) |
581 | { |
528 | { |
582 | if (result != original_asim) |
529 | if (result != original_asim) |
… | |
… | |
595 | { |
542 | { |
596 | XGCValues gcv; |
543 | XGCValues gcv; |
597 | GC gc; |
544 | GC gc; |
598 | |
545 | |
599 | /* create Pixmap */ |
546 | /* create Pixmap */ |
600 | if (pixmap == None |
547 | if (bg_pixmap == None |
601 | || pmap_width != new_pmap_width |
548 | || bg_pmap_width != new_pmap_width |
602 | || pmap_height != new_pmap_height |
549 | || bg_pmap_height != new_pmap_height) |
603 | || pmap_depth != target->depth) |
|
|
604 | { |
550 | { |
605 | if (pixmap) |
551 | if (bg_pixmap) |
606 | XFreePixmap (target->dpy, pixmap); |
552 | XFreePixmap (dpy, bg_pixmap); |
607 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
553 | bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); |
608 | pmap_width = new_pmap_width; |
554 | bg_pmap_width = new_pmap_width; |
609 | pmap_height = new_pmap_height; |
555 | bg_pmap_height = new_pmap_height; |
610 | pmap_depth = target->depth; |
|
|
611 | } |
556 | } |
612 | /* fill with background color (if result's not completely overlapping it) */ |
557 | /* fill with background color (if result's not completely overlapping it) */ |
613 | gcv.foreground = target->pix_colors[Color_bg]; |
558 | gcv.foreground = pix_colors[Color_bg]; |
614 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
559 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
615 | |
560 | |
616 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
561 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
617 | int dst_width = result->width, dst_height = result->height; |
562 | int dst_width = result->width, dst_height = result->height; |
618 | if (background == NULL) |
563 | if (background == NULL) |
619 | { |
564 | { |
… | |
… | |
624 | } |
569 | } |
625 | |
570 | |
626 | if (dst_x > 0 || dst_y > 0 |
571 | if (dst_x > 0 || dst_y > 0 |
627 | || dst_x + dst_width < new_pmap_width |
572 | || dst_x + dst_width < new_pmap_width |
628 | || dst_y + dst_height < new_pmap_height) |
573 | || dst_y + dst_height < new_pmap_height) |
629 | XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
574 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
630 | } |
575 | } |
631 | |
576 | |
632 | /* put result on pixmap */ |
577 | /* put result on pixmap */ |
633 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
578 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
634 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
579 | asimage2drawable (asv, bg_pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
635 | |
580 | |
636 | if (result != background && result != original_asim) |
581 | if (result != background && result != original_asim) |
637 | destroy_asimage (&result); |
582 | destroy_asimage (&result); |
638 | |
583 | |
639 | XFreeGC (target->dpy, gc); |
584 | XFreeGC (dpy, gc); |
640 | |
585 | |
641 | ret = true; |
586 | ret = true; |
642 | } |
587 | } |
643 | |
588 | |
644 | if (background) |
589 | if (background) |
… | |
… | |
648 | } |
593 | } |
649 | # endif /* HAVE_AFTERIMAGE */ |
594 | # endif /* HAVE_AFTERIMAGE */ |
650 | |
595 | |
651 | # ifdef HAVE_PIXBUF |
596 | # ifdef HAVE_PIXBUF |
652 | bool |
597 | bool |
653 | bgPixmap_t::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, |
598 | rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, |
654 | int src_x, int src_y, int dst_x, int dst_y, |
599 | int src_x, int src_y, int dst_x, int dst_y, |
655 | unsigned int width, unsigned int height) |
600 | unsigned int width, unsigned int height) |
656 | { |
601 | { |
657 | XImage *ximage; |
602 | XImage *ximage; |
658 | char *data, *line; |
603 | char *data, *line; |
659 | int bytes_per_pixel; |
604 | int bytes_per_pixel; |
660 | int width_r, width_g, width_b; |
605 | int width_r, width_g, width_b; |
661 | int sh_r, sh_g, sh_b; |
606 | int sh_r, sh_g, sh_b; |
662 | int rowstride; |
607 | int rowstride; |
663 | int channels; |
608 | int channels; |
664 | unsigned char *row; |
609 | unsigned char *row; |
665 | Visual *visual = target->visual; |
|
|
666 | int depth = target->depth; |
|
|
667 | |
610 | |
668 | if (visual->c_class != TrueColor) |
611 | if (visual->c_class != TrueColor) |
669 | return false; |
612 | return false; |
670 | |
613 | |
671 | if (depth == 24 || depth == 32) |
614 | if (depth == 24 || depth == 32) |
… | |
… | |
691 | |
634 | |
692 | data = (char *)malloc (width * height * bytes_per_pixel); |
635 | data = (char *)malloc (width * height * bytes_per_pixel); |
693 | if (!data) |
636 | if (!data) |
694 | return false; |
637 | return false; |
695 | |
638 | |
696 | ximage = XCreateImage (target->dpy, visual, depth, ZPixmap, 0, data, |
639 | ximage = XCreateImage (dpy, visual, depth, ZPixmap, 0, data, |
697 | width, height, bytes_per_pixel * 8, 0); |
640 | width, height, bytes_per_pixel * 8, 0); |
698 | if (!ximage) |
641 | if (!ximage) |
699 | { |
642 | { |
700 | free (data); |
643 | free (data); |
701 | return false; |
644 | return false; |
… | |
… | |
727 | |
670 | |
728 | row += rowstride; |
671 | row += rowstride; |
729 | line += ximage->bytes_per_line; |
672 | line += ximage->bytes_per_line; |
730 | } |
673 | } |
731 | |
674 | |
732 | XPutImage (target->dpy, pixmap, gc, ximage, 0, 0, dst_x, dst_y, width, height); |
675 | XPutImage (dpy, pixmap, gc, ximage, 0, 0, dst_x, dst_y, width, height); |
733 | XDestroyImage (ximage); |
676 | XDestroyImage (ximage); |
734 | return true; |
677 | return true; |
735 | } |
678 | } |
736 | |
679 | |
737 | bool |
680 | bool |
738 | bgPixmap_t::render_image (unsigned long background_flags) |
681 | rxvt_term::render_image (unsigned long tr_flags) |
739 | { |
682 | { |
740 | if (target == NULL) |
|
|
741 | return false; |
|
|
742 | |
|
|
743 | if (!pixbuf) |
683 | if (!pixbuf) |
744 | return false; |
684 | return false; |
745 | |
685 | |
746 | if (background_flags |
686 | if (tr_flags |
747 | && !(flags & HAS_RENDER)) |
687 | && !(bg_flags & BG_HAS_RENDER)) |
748 | return false; |
688 | return false; |
749 | |
689 | |
750 | GdkPixbuf *result; |
690 | GdkPixbuf *result; |
751 | |
691 | |
752 | int image_width = gdk_pixbuf_get_width (pixbuf); |
692 | int image_width = gdk_pixbuf_get_width (pixbuf); |
753 | int image_height = gdk_pixbuf_get_height (pixbuf); |
693 | int image_height = gdk_pixbuf_get_height (pixbuf); |
754 | |
694 | |
755 | int target_width = target->szHint.width; |
695 | int target_width = szHint.width; |
756 | int target_height = target->szHint.height; |
696 | int target_height = szHint.height; |
757 | int new_pmap_width = target_width; |
697 | int new_pmap_width = target_width; |
758 | int new_pmap_height = target_height; |
698 | int new_pmap_height = target_height; |
759 | |
699 | |
760 | int x = 0; |
700 | int x = 0; |
761 | int y = 0; |
701 | int y = 0; |
762 | int w = 0; |
702 | int w = 0; |
763 | int h = 0; |
703 | int h = 0; |
764 | |
704 | |
765 | get_image_geometry (image_width, image_height, w, h, x, y); |
705 | get_image_geometry (image_width, image_height, w, h, x, y); |
766 | |
706 | |
767 | if (!(flags & rootAlign) |
707 | if (!(bg_flags & BG_ROOT_ALIGN) |
768 | && (x >= target_width |
708 | && (x >= target_width |
769 | || y >= target_height |
709 | || y >= target_height |
770 | || (x + w <= 0) |
710 | || (x + w <= 0) |
771 | || (y + h <= 0))) |
711 | || (y + h <= 0))) |
772 | return false; |
712 | return false; |
… | |
… | |
790 | Pixmap root_pmap; |
730 | Pixmap root_pmap; |
791 | |
731 | |
792 | image_width = gdk_pixbuf_get_width (result); |
732 | image_width = gdk_pixbuf_get_width (result); |
793 | image_height = gdk_pixbuf_get_height (result); |
733 | image_height = gdk_pixbuf_get_height (result); |
794 | |
734 | |
795 | if (background_flags) |
735 | if (tr_flags) |
796 | { |
736 | { |
797 | root_pmap = pixmap; |
737 | root_pmap = bg_pixmap; |
798 | pixmap = None; |
738 | bg_pixmap = None; |
799 | } |
739 | } |
800 | else |
740 | else |
801 | { |
741 | { |
802 | if (h_scale == 0 || v_scale == 0) |
742 | if (h_scale == 0 || v_scale == 0) |
803 | { |
743 | { |
804 | new_pmap_width = min (image_width, target_width); |
744 | new_pmap_width = min (image_width, target_width); |
805 | new_pmap_height = min (image_height, target_height); |
745 | new_pmap_height = min (image_height, target_height); |
806 | } |
746 | } |
807 | } |
747 | } |
808 | |
748 | |
809 | if (pixmap == None |
749 | if (bg_pixmap == None |
810 | || pmap_width != new_pmap_width |
750 | || bg_pmap_width != new_pmap_width |
811 | || pmap_height != new_pmap_height |
751 | || bg_pmap_height != new_pmap_height) |
812 | || pmap_depth != target->depth) |
|
|
813 | { |
752 | { |
814 | if (pixmap) |
753 | if (bg_pixmap) |
815 | XFreePixmap (target->dpy, pixmap); |
754 | XFreePixmap (dpy, bg_pixmap); |
816 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
755 | bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); |
817 | pmap_width = new_pmap_width; |
756 | bg_pmap_width = new_pmap_width; |
818 | pmap_height = new_pmap_height; |
757 | bg_pmap_height = new_pmap_height; |
819 | pmap_depth = target->depth; |
|
|
820 | } |
758 | } |
821 | |
759 | |
822 | gcv.foreground = target->pix_colors[Color_bg]; |
760 | gcv.foreground = pix_colors[Color_bg]; |
823 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
761 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
824 | |
762 | |
825 | if (h_scale == 0 || v_scale == 0) |
763 | if (h_scale == 0 || v_scale == 0) |
826 | { |
764 | { |
827 | Pixmap tile = XCreatePixmap (target->dpy, target->vt, image_width, image_height, target->depth); |
765 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
828 | pixbuf_to_pixmap (result, tile, gc, |
766 | pixbuf_to_pixmap (result, tile, gc, |
829 | 0, 0, |
767 | 0, 0, |
830 | 0, 0, |
768 | 0, 0, |
831 | image_width, image_height); |
769 | image_width, image_height); |
832 | |
770 | |
833 | gcv.tile = tile; |
771 | gcv.tile = tile; |
834 | gcv.fill_style = FillTiled; |
772 | gcv.fill_style = FillTiled; |
835 | gcv.ts_x_origin = x; |
773 | gcv.ts_x_origin = x; |
836 | gcv.ts_y_origin = y; |
774 | gcv.ts_y_origin = y; |
837 | XChangeGC (target->dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
775 | XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
838 | |
776 | |
839 | XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
777 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
840 | XFreePixmap (target->dpy, tile); |
778 | XFreePixmap (dpy, tile); |
841 | } |
779 | } |
842 | else |
780 | else |
843 | { |
781 | { |
844 | int src_x, src_y, dst_x, dst_y; |
782 | int src_x, src_y, dst_x, dst_y; |
845 | int dst_width, dst_height; |
783 | int dst_width, dst_height; |
… | |
… | |
848 | src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height); |
786 | src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height); |
849 | |
787 | |
850 | if (dst_x > 0 || dst_y > 0 |
788 | if (dst_x > 0 || dst_y > 0 |
851 | || dst_x + dst_width < new_pmap_width |
789 | || dst_x + dst_width < new_pmap_width |
852 | || dst_y + dst_height < new_pmap_height) |
790 | || dst_y + dst_height < new_pmap_height) |
853 | XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
791 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
854 | |
792 | |
855 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
793 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
856 | pixbuf_to_pixmap (result, pixmap, gc, |
794 | pixbuf_to_pixmap (result, bg_pixmap, gc, |
857 | src_x, src_y, |
795 | src_x, src_y, |
858 | dst_x, dst_y, |
796 | dst_x, dst_y, |
859 | dst_width, dst_height); |
797 | dst_width, dst_height); |
860 | } |
798 | } |
861 | |
799 | |
862 | #if XRENDER |
800 | #if XRENDER |
863 | if (background_flags) |
801 | if (tr_flags) |
864 | { |
802 | { |
865 | Display *dpy = target->dpy; |
|
|
866 | XRenderPictureAttributes pa; |
803 | XRenderPictureAttributes pa; |
867 | |
804 | |
868 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, target->visual); |
805 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); |
869 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
806 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
870 | |
807 | |
871 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); |
808 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
872 | Picture dst = XRenderCreatePicture (dpy, pixmap, dst_format, 0, &pa); |
809 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); |
873 | |
810 | |
874 | pa.repeat = True; |
811 | pa.repeat = True; |
875 | Pixmap mask_pmap = XCreatePixmap (dpy, target->vt, 1, 1, 8); |
812 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
876 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
813 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
877 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
814 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
878 | XFreePixmap (dpy, mask_pmap); |
815 | XFreePixmap (dpy, mask_pmap); |
879 | |
816 | |
880 | if (src && dst && mask) |
817 | if (src && dst && mask) |
… | |
… | |
898 | #endif |
835 | #endif |
899 | |
836 | |
900 | if (result != pixbuf) |
837 | if (result != pixbuf) |
901 | g_object_unref (result); |
838 | g_object_unref (result); |
902 | |
839 | |
903 | XFreeGC (target->dpy, gc); |
840 | XFreeGC (dpy, gc); |
904 | |
841 | |
905 | ret = true; |
842 | ret = true; |
906 | } |
843 | } |
907 | |
844 | |
908 | return ret; |
845 | return ret; |
909 | } |
846 | } |
910 | # endif /* HAVE_PIXBUF */ |
847 | # endif /* HAVE_PIXBUF */ |
911 | |
848 | |
912 | bool |
849 | bool |
913 | bgPixmap_t::set_file (const char *file) |
850 | rxvt_term::bg_set_file (const char *file) |
914 | { |
851 | { |
915 | if (!file || !*file) |
852 | if (!file || !*file) |
916 | return false; |
853 | return false; |
917 | |
854 | |
918 | if (const char *p = strchr (file, ';')) |
855 | if (const char *p = strchr (file, ';')) |
… | |
… | |
923 | f[len] = '\0'; |
860 | f[len] = '\0'; |
924 | file = f; |
861 | file = f; |
925 | } |
862 | } |
926 | |
863 | |
927 | # ifdef HAVE_AFTERIMAGE |
864 | # ifdef HAVE_AFTERIMAGE |
928 | if (!target->asimman) |
865 | if (!asimman) |
929 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
866 | asimman = create_generic_imageman (rs[Rs_path]); |
930 | ASImage *image = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
867 | ASImage *image = get_asimage (asimman, file, 0xFFFFFFFF, 100); |
931 | if (image) |
868 | if (image) |
932 | { |
869 | { |
933 | if (original_asim) |
870 | if (original_asim) |
934 | safe_asimage_destroy (original_asim); |
871 | safe_asimage_destroy (original_asim); |
935 | original_asim = image; |
872 | original_asim = image; |
936 | flags |= CLIENT_RENDER; |
873 | bg_flags |= BG_CLIENT_RENDER; |
937 | have_image = true; |
874 | have_image = true; |
938 | return true; |
875 | return true; |
939 | } |
876 | } |
940 | # endif |
877 | # endif |
941 | |
878 | |
… | |
… | |
956 | |
893 | |
957 | # endif /* BG_IMAGE_FROM_FILE */ |
894 | # endif /* BG_IMAGE_FROM_FILE */ |
958 | |
895 | |
959 | # ifdef ENABLE_TRANSPARENCY |
896 | # ifdef ENABLE_TRANSPARENCY |
960 | bool |
897 | bool |
961 | bgPixmap_t::set_transparent () |
898 | rxvt_term::bg_set_transparent () |
962 | { |
899 | { |
963 | if (!(flags & isTransparent)) |
900 | if (!(bg_flags & BG_IS_TRANSPARENT)) |
964 | { |
901 | { |
965 | flags |= isTransparent; |
902 | bg_flags |= BG_IS_TRANSPARENT; |
966 | return true; |
903 | return true; |
967 | } |
904 | } |
968 | |
905 | |
969 | return false; |
906 | return false; |
970 | } |
907 | } |
971 | |
908 | |
972 | bool |
909 | bool |
973 | bgPixmap_t::set_blur_radius (const char *geom) |
910 | rxvt_term::bg_set_blur (const char *geom) |
974 | { |
911 | { |
975 | bool changed = false; |
912 | bool changed = false; |
976 | unsigned int hr, vr; |
913 | unsigned int hr, vr; |
977 | int junk; |
914 | int junk; |
978 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
915 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
… | |
… | |
996 | changed = true; |
933 | changed = true; |
997 | v_blurRadius = vr; |
934 | v_blurRadius = vr; |
998 | } |
935 | } |
999 | |
936 | |
1000 | if (v_blurRadius == 0 && h_blurRadius == 0) |
937 | if (v_blurRadius == 0 && h_blurRadius == 0) |
1001 | flags &= ~blurNeeded; |
938 | bg_flags &= ~BG_NEEDS_BLUR; |
1002 | else |
939 | else |
1003 | flags |= blurNeeded; |
940 | bg_flags |= BG_NEEDS_BLUR; |
1004 | |
941 | |
1005 | return changed; |
942 | return changed; |
1006 | } |
943 | } |
1007 | |
944 | |
1008 | static inline unsigned long |
945 | static inline unsigned long |
… | |
… | |
1013 | bool has_shade = shade != 100; |
950 | bool has_shade = shade != 100; |
1014 | |
951 | |
1015 | if (tint) |
952 | if (tint) |
1016 | { |
953 | { |
1017 | tint->get (c); |
954 | tint->get (c); |
1018 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x00ff || (cmp) >= 0xff00) |
|
|
1019 | if (!has_shade |
955 | if (!has_shade |
1020 | && IS_COMPONENT_WHOLESOME (c.r) |
956 | && (c.r <= 0x00ff || c.r >= 0xff00) |
1021 | && IS_COMPONENT_WHOLESOME (c.g) |
957 | && (c.g <= 0x00ff || c.g >= 0xff00) |
1022 | && IS_COMPONENT_WHOLESOME (c.b)) |
958 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
1023 | flags |= bgPixmap_t::tintWholesome; |
959 | flags |= rxvt_term::BG_TINT_BITAND; |
1024 | # undef IS_COMPONENT_WHOLESOME |
|
|
1025 | } |
960 | } |
1026 | |
961 | |
1027 | if (has_shade || tint) |
962 | if (has_shade || tint) |
1028 | flags |= bgPixmap_t::tintNeeded; |
963 | flags |= rxvt_term::BG_NEEDS_TINT; |
1029 | |
964 | |
1030 | return flags; |
965 | return flags; |
1031 | } |
966 | } |
1032 | |
967 | |
1033 | bool |
968 | bool |
1034 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
969 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
1035 | { |
970 | { |
1036 | if (!(flags & tintSet) || tint != new_tint) |
971 | if (!(bg_flags & BG_TINT_SET) || tint != new_tint) |
1037 | { |
972 | { |
1038 | unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); |
973 | unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); |
1039 | tint = new_tint; |
974 | tint = new_tint; |
1040 | flags = (flags & ~tintFlags) | new_flags | tintSet; |
975 | bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags | BG_TINT_SET; |
1041 | return true; |
976 | return true; |
1042 | } |
977 | } |
1043 | |
978 | |
1044 | return false; |
979 | return false; |
1045 | } |
980 | } |
1046 | |
981 | |
1047 | bool |
982 | bool |
1048 | bgPixmap_t::set_shade (const char *shade_str) |
983 | rxvt_term::bg_set_shade (const char *shade_str) |
1049 | { |
984 | { |
1050 | int new_shade = (shade_str) ? atoi (shade_str) : 100; |
985 | int new_shade = (shade_str) ? atoi (shade_str) : 100; |
1051 | |
986 | |
1052 | clamp_it (new_shade, -100, 200); |
987 | clamp_it (new_shade, -100, 200); |
1053 | if (new_shade < 0) |
988 | if (new_shade < 0) |
1054 | new_shade = 200 - (100 + new_shade); |
989 | new_shade = 200 - (100 + new_shade); |
1055 | |
990 | |
1056 | if (new_shade != shade) |
991 | if (new_shade != shade) |
1057 | { |
992 | { |
1058 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
993 | unsigned long new_flags = compute_tint_shade_flags ((bg_flags & BG_TINT_SET) ? &tint : NULL, new_shade); |
1059 | shade = new_shade; |
994 | shade = new_shade; |
1060 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
995 | bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags; |
1061 | return true; |
996 | return true; |
1062 | } |
997 | } |
1063 | |
998 | |
1064 | return false; |
999 | return false; |
1065 | } |
1000 | } |
… | |
… | |
1086 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
1021 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
1087 | } |
1022 | } |
1088 | #endif |
1023 | #endif |
1089 | |
1024 | |
1090 | bool |
1025 | bool |
1091 | bgPixmap_t::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1026 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1092 | { |
1027 | { |
1093 | bool ret = false; |
1028 | bool ret = false; |
1094 | #if XRENDER |
1029 | #if XRENDER |
1095 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1030 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1096 | double *kernel = (double *)malloc (size * sizeof (double)); |
1031 | double *kernel = (double *)malloc (size * sizeof (double)); |
1097 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1032 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1098 | |
1033 | |
1099 | Display *dpy = target->dpy; |
|
|
1100 | XRenderPictureAttributes pa; |
1034 | XRenderPictureAttributes pa; |
1101 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1035 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1102 | |
1036 | |
1103 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1037 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1104 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1038 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
… | |
… | |
1124 | |
1058 | |
1125 | if (v_blurRadius) |
1059 | if (v_blurRadius) |
1126 | { |
1060 | { |
1127 | size = v_blurRadius * 2 + 1; |
1061 | size = v_blurRadius * 2 + 1; |
1128 | get_gaussian_kernel (v_blurRadius, size, kernel, params); |
1062 | get_gaussian_kernel (v_blurRadius, size, kernel, params); |
1129 | swap (params[0], params[1]); |
1063 | ::swap (params[0], params[1]); |
1130 | |
1064 | |
1131 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1065 | XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); |
1132 | XRenderComposite (dpy, |
1066 | XRenderComposite (dpy, |
1133 | PictOpSrc, |
1067 | PictOpSrc, |
1134 | src, |
1068 | src, |
… | |
… | |
1150 | #endif |
1084 | #endif |
1151 | return ret; |
1085 | return ret; |
1152 | } |
1086 | } |
1153 | |
1087 | |
1154 | bool |
1088 | bool |
1155 | bgPixmap_t::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1089 | rxvt_term::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1156 | { |
1090 | { |
1157 | Display *dpy = target->dpy; |
|
|
1158 | bool ret = false; |
1091 | bool ret = false; |
1159 | |
1092 | |
1160 | if (flags & tintWholesome) |
1093 | if (bg_flags & BG_TINT_BITAND) |
1161 | { |
1094 | { |
1162 | XGCValues gcv; |
1095 | XGCValues gcv; |
1163 | GC gc; |
1096 | GC gc; |
1164 | |
1097 | |
1165 | /* In this case we can tint image server-side getting significant |
1098 | /* In this case we can tint image server-side getting significant |
… | |
… | |
1179 | else |
1112 | else |
1180 | { |
1113 | { |
1181 | # if XRENDER |
1114 | # if XRENDER |
1182 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1115 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1183 | |
1116 | |
1184 | if (flags & tintSet) |
1117 | if (bg_flags & BG_TINT_SET) |
1185 | tint.get (c); |
1118 | tint.get (c); |
1186 | |
1119 | |
1187 | if (shade <= 100) |
1120 | if (shade <= 100) |
1188 | { |
1121 | { |
1189 | c.r = (c.r * shade) / 100; |
1122 | c.r = (c.r * shade) / 100; |
… | |
… | |
1254 | * Builds a pixmap of the same size as the terminal window that contains |
1187 | * Builds a pixmap of the same size as the terminal window that contains |
1255 | * the tiled portion of the root pixmap that is supposed to be covered by |
1188 | * the tiled portion of the root pixmap that is supposed to be covered by |
1256 | * our window. |
1189 | * our window. |
1257 | */ |
1190 | */ |
1258 | unsigned long |
1191 | unsigned long |
1259 | bgPixmap_t::make_transparency_pixmap () |
1192 | rxvt_term::make_transparency_pixmap () |
1260 | { |
1193 | { |
1261 | unsigned long result = 0; |
1194 | unsigned long result = 0; |
1262 | |
|
|
1263 | if (target == NULL) |
|
|
1264 | return 0; |
|
|
1265 | |
1195 | |
1266 | /* root dimensions may change from call to call - but Display structure should |
1196 | /* root dimensions may change from call to call - but Display structure should |
1267 | * be always up-to-date, so let's use it : |
1197 | * be always up-to-date, so let's use it : |
1268 | */ |
1198 | */ |
1269 | int screen = target->display->screen; |
1199 | int screen = display->screen; |
1270 | Display *dpy = target->dpy; |
|
|
1271 | int root_depth = DefaultDepth (dpy, screen); |
1200 | int root_depth = DefaultDepth (dpy, screen); |
1272 | int root_width = DisplayWidth (dpy, screen); |
1201 | int root_width = DisplayWidth (dpy, screen); |
1273 | int root_height = DisplayHeight (dpy, screen); |
1202 | int root_height = DisplayHeight (dpy, screen); |
1274 | unsigned int root_pmap_width, root_pmap_height; |
1203 | unsigned int root_pmap_width, root_pmap_height; |
1275 | int window_width = target->szHint.width; |
1204 | int window_width = szHint.width; |
1276 | int window_height = target->szHint.height; |
1205 | int window_height = szHint.height; |
1277 | int sx, sy; |
1206 | int sx, sy; |
1278 | XGCValues gcv; |
1207 | XGCValues gcv; |
1279 | GC gc; |
1208 | GC gc; |
1280 | |
1209 | |
1281 | sx = target_x; |
1210 | sx = target_x; |
… | |
… | |
1291 | { |
1220 | { |
1292 | Window wdummy; |
1221 | Window wdummy; |
1293 | int idummy; |
1222 | int idummy; |
1294 | unsigned int udummy; |
1223 | unsigned int udummy; |
1295 | |
1224 | |
1296 | target->allowedxerror = -1; |
1225 | allowedxerror = -1; |
1297 | |
1226 | |
1298 | if (!XGetGeometry (dpy, root_pixmap, &wdummy, &idummy, &idummy, &root_pmap_width, &root_pmap_height, &udummy, &udummy)) |
1227 | if (!XGetGeometry (dpy, root_pixmap, &wdummy, &idummy, &idummy, &root_pmap_width, &root_pmap_height, &udummy, &udummy)) |
1299 | root_pixmap = None; |
1228 | root_pixmap = None; |
1300 | |
1229 | |
1301 | target->allowedxerror = 0; |
1230 | allowedxerror = 0; |
1302 | } |
1231 | } |
1303 | |
1232 | |
1304 | Pixmap recoded_root_pmap = root_pixmap; |
1233 | Pixmap recoded_root_pmap = root_pixmap; |
1305 | |
1234 | |
1306 | if (root_pixmap != None && root_depth != target->depth) |
1235 | if (root_pixmap != None && root_depth != depth) |
1307 | { |
1236 | { |
1308 | #if XRENDER |
1237 | #if XRENDER |
1309 | if (flags & HAS_RENDER) |
1238 | if (bg_flags & BG_HAS_RENDER) |
1310 | { |
1239 | { |
1311 | XRenderPictureAttributes pa; |
1240 | XRenderPictureAttributes pa; |
1312 | |
1241 | |
1313 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1242 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1314 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1243 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1315 | |
1244 | |
1316 | recoded_root_pmap = XCreatePixmap (dpy, target->vt, root_pmap_width, root_pmap_height, target->depth); |
1245 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
1317 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); |
1246 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1318 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1247 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1319 | |
1248 | |
1320 | if (src && dst) |
1249 | if (src && dst) |
1321 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1250 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1322 | else |
1251 | else |
… | |
… | |
1334 | } |
1263 | } |
1335 | |
1264 | |
1336 | if (root_pixmap == None) |
1265 | if (root_pixmap == None) |
1337 | return 0; |
1266 | return 0; |
1338 | |
1267 | |
|
|
1268 | if (bg_pixmap == None |
|
|
1269 | || bg_pmap_width != window_width |
|
|
1270 | || bg_pmap_height != window_height) |
|
|
1271 | { |
|
|
1272 | if (bg_pixmap) |
|
|
1273 | XFreePixmap (dpy, bg_pixmap); |
1339 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, target->vt, window_width, window_height, target->depth); |
1274 | bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); |
|
|
1275 | bg_pmap_width = window_width; |
|
|
1276 | bg_pmap_height = window_height; |
|
|
1277 | } |
1340 | |
1278 | |
1341 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
1279 | if (bg_pixmap == None) |
1342 | return 0; |
1280 | return 0; |
1343 | |
1281 | |
1344 | /* straightforward pixmap copy */ |
1282 | /* straightforward pixmap copy */ |
1345 | while (sx < 0) sx += (int)root_width; |
1283 | while (sx < 0) sx += (int)root_width; |
1346 | while (sy < 0) sy += (int)root_height; |
1284 | while (sy < 0) sy += (int)root_height; |
1347 | |
1285 | |
1348 | gcv.tile = recoded_root_pmap; |
1286 | gcv.tile = recoded_root_pmap; |
1349 | gcv.fill_style = FillTiled; |
1287 | gcv.fill_style = FillTiled; |
1350 | gcv.ts_x_origin = -sx; |
1288 | gcv.ts_x_origin = -sx; |
1351 | gcv.ts_y_origin = -sy; |
1289 | gcv.ts_y_origin = -sy; |
1352 | gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1290 | gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1353 | |
1291 | |
1354 | if (gc) |
1292 | if (gc) |
1355 | { |
1293 | { |
1356 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
1294 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1357 | result |= transpPmapTiled; |
1295 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1358 | XFreeGC (dpy, gc); |
1296 | XFreeGC (dpy, gc); |
1359 | |
1297 | |
1360 | if (!(flags & CLIENT_RENDER)) |
1298 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1361 | { |
1299 | { |
1362 | if ((flags & blurNeeded) |
1300 | if ((bg_flags & BG_NEEDS_BLUR) |
1363 | && (flags & HAS_RENDER_CONV)) |
1301 | && (bg_flags & BG_HAS_RENDER_CONV)) |
1364 | { |
|
|
1365 | if (blur_pixmap (tiled_root_pmap, target->visual, window_width, window_height)) |
|
|
1366 | result |= transpPmapBlurred; |
|
|
1367 | } |
1302 | { |
1368 | if ((flags & tintNeeded) |
1303 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1369 | && (flags & (tintWholesome | HAS_RENDER))) |
1304 | result &= ~BG_NEEDS_BLUR; |
1370 | { |
1305 | } |
|
|
1306 | if ((bg_flags & BG_NEEDS_TINT) |
|
|
1307 | && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) |
|
|
1308 | { |
1371 | if (tint_pixmap (tiled_root_pmap, target->visual, window_width, window_height)) |
1309 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1372 | result |= transpPmapTinted; |
1310 | result &= ~BG_NEEDS_TINT; |
1373 | } |
1311 | } |
1374 | } /* server side rendering completed */ |
1312 | } /* server side rendering completed */ |
1375 | |
|
|
1376 | if (pixmap) |
|
|
1377 | XFreePixmap (dpy, pixmap); |
|
|
1378 | |
|
|
1379 | pixmap = tiled_root_pmap; |
|
|
1380 | pmap_width = window_width; |
|
|
1381 | pmap_height = window_height; |
|
|
1382 | pmap_depth = target->depth; |
|
|
1383 | } |
1313 | } |
1384 | else |
|
|
1385 | XFreePixmap (dpy, tiled_root_pmap); |
|
|
1386 | |
1314 | |
1387 | if (recoded_root_pmap != root_pixmap) |
1315 | if (recoded_root_pmap != root_pixmap) |
1388 | XFreePixmap (dpy, recoded_root_pmap); |
1316 | XFreePixmap (dpy, recoded_root_pmap); |
1389 | |
1317 | |
1390 | return result; |
1318 | return result; |
1391 | } |
1319 | } |
1392 | |
1320 | |
1393 | void |
1321 | void |
1394 | bgPixmap_t::set_root_pixmap () |
1322 | rxvt_term::bg_set_root_pixmap () |
1395 | { |
1323 | { |
1396 | Pixmap new_root_pixmap = target->get_pixmap_property (target->xa[XA_XROOTPMAP_ID]); |
1324 | Pixmap new_root_pixmap = get_pixmap_property (xa[XA_XROOTPMAP_ID]); |
1397 | if (new_root_pixmap == None) |
1325 | if (new_root_pixmap == None) |
1398 | new_root_pixmap = target->get_pixmap_property (target->xa[XA_ESETROOT_PMAP_ID]); |
1326 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1399 | |
1327 | |
1400 | root_pixmap = new_root_pixmap; |
1328 | root_pixmap = new_root_pixmap; |
1401 | } |
1329 | } |
1402 | # endif /* ENABLE_TRANSPARENCY */ |
1330 | # endif /* ENABLE_TRANSPARENCY */ |
1403 | |
1331 | |
1404 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1332 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1405 | static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c); |
1333 | static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c); |
1406 | # endif |
1334 | # endif |
1407 | |
1335 | |
1408 | bool |
1336 | bool |
1409 | bgPixmap_t::render () |
1337 | rxvt_term::bg_render () |
1410 | { |
1338 | { |
1411 | unsigned long background_flags = 0; |
1339 | unsigned long tr_flags = 0; |
1412 | |
1340 | |
1413 | if (target == NULL) |
|
|
1414 | return false; |
|
|
1415 | |
|
|
1416 | invalidate (); |
1341 | bg_invalidate (); |
1417 | # ifdef ENABLE_TRANSPARENCY |
1342 | # ifdef ENABLE_TRANSPARENCY |
1418 | if (flags & isTransparent) |
1343 | if (bg_flags & BG_IS_TRANSPARENT) |
1419 | { |
1344 | { |
1420 | /* we need to re-generate transparency pixmap in that case ! */ |
1345 | /* we need to re-generate transparency pixmap in that case ! */ |
1421 | background_flags = make_transparency_pixmap (); |
1346 | tr_flags = make_transparency_pixmap (); |
1422 | if (background_flags == 0) |
1347 | if (tr_flags == 0) |
1423 | return false; |
1348 | return false; |
1424 | else if ((background_flags & transpTransformations) == (flags & transpTransformations)) |
1349 | else if (!(tr_flags & BG_EFFECTS_FLAGS)) |
1425 | flags &= ~isInvalid; |
1350 | bg_flags |= BG_IS_VALID; |
1426 | } |
1351 | } |
1427 | # endif |
1352 | # endif |
1428 | |
1353 | |
1429 | # ifdef BG_IMAGE_FROM_FILE |
1354 | # ifdef BG_IMAGE_FROM_FILE |
1430 | if (have_image |
1355 | if (have_image |
1431 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1356 | || (tr_flags & BG_EFFECTS_FLAGS)) |
1432 | { |
1357 | { |
1433 | if (render_image (background_flags)) |
1358 | if (render_image (tr_flags)) |
1434 | flags &= ~isInvalid; |
1359 | bg_flags |= BG_IS_VALID; |
1435 | } |
1360 | } |
1436 | # endif |
1361 | # endif |
1437 | |
1362 | |
1438 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1363 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1439 | XImage *result = NULL; |
1364 | XImage *result = NULL; |
1440 | |
1365 | |
1441 | if (background_flags && (flags & isInvalid)) |
1366 | if (tr_flags && !(bg_flags & BG_IS_VALID)) |
1442 | { |
1367 | { |
1443 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1368 | result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
1444 | } |
1369 | } |
1445 | |
1370 | |
1446 | if (result) |
1371 | if (result) |
1447 | { |
1372 | { |
1448 | /* our own client-side tinting */ |
1373 | /* our own client-side tinting */ |
1449 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1374 | if (tr_flags & BG_NEEDS_TINT) |
1450 | { |
1375 | { |
1451 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1376 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1452 | if (flags & tintSet) |
1377 | if (bg_flags & BG_TINT_SET) |
1453 | tint.get (c); |
1378 | tint.get (c); |
1454 | shade_ximage (DefaultVisual (target->dpy, target->display->screen), result, shade, c); |
1379 | shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); |
1455 | } |
1380 | } |
1456 | |
1381 | |
1457 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1382 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
1458 | |
1383 | |
1459 | if (gc) |
1384 | if (gc) |
1460 | { |
1385 | { |
1461 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1386 | XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1462 | |
1387 | |
1463 | XFreeGC (target->dpy, gc); |
1388 | XFreeGC (dpy, gc); |
1464 | flags &= ~isInvalid; |
1389 | bg_flags |= BG_IS_VALID; |
1465 | } |
1390 | } |
1466 | |
1391 | |
1467 | XDestroyImage (result); |
1392 | XDestroyImage (result); |
1468 | } |
1393 | } |
1469 | # endif |
1394 | # endif |
1470 | |
1395 | |
1471 | if (flags & isInvalid) |
1396 | if (!(bg_flags & BG_IS_VALID)) |
1472 | { |
1397 | { |
1473 | if (pixmap != None) |
1398 | if (bg_pixmap != None) |
1474 | { |
1399 | { |
1475 | XFreePixmap (target->dpy, pixmap); |
1400 | XFreePixmap (dpy, bg_pixmap); |
1476 | pixmap = None; |
1401 | bg_pixmap = None; |
1477 | } |
1402 | } |
1478 | } |
1403 | } |
1479 | |
1404 | |
1480 | apply (); |
1405 | scr_recolour (false); |
|
|
1406 | bg_flags |= BG_NEEDS_REFRESH; |
1481 | |
1407 | |
1482 | valid_since = ev::now (); |
1408 | bg_valid_since = ev::now (); |
1483 | |
1409 | |
1484 | return true; |
1410 | return true; |
1485 | } |
1411 | } |
1486 | |
1412 | |
1487 | void |
1413 | void |
1488 | bgPixmap_t::set_target (rxvt_term *new_target) |
1414 | rxvt_term::bg_init () |
1489 | { |
1415 | { |
1490 | target = new_target; |
1416 | #ifdef ENABLE_TRANSPARENCY |
|
|
1417 | shade = 100; |
|
|
1418 | #endif |
1491 | |
1419 | |
1492 | flags &= ~(HAS_RENDER | HAS_RENDER_CONV); |
1420 | bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); |
1493 | #if XRENDER |
1421 | #if XRENDER |
1494 | int major, minor; |
1422 | int major, minor; |
1495 | if (XRenderQueryVersion (target->dpy, &major, &minor)) |
1423 | if (XRenderQueryVersion (dpy, &major, &minor)) |
1496 | flags |= HAS_RENDER; |
1424 | bg_flags |= BG_HAS_RENDER; |
1497 | XFilters *filters = XRenderQueryFilters (target->dpy, target->vt); |
1425 | XFilters *filters = XRenderQueryFilters (dpy, vt); |
1498 | if (filters) |
1426 | if (filters) |
1499 | { |
1427 | { |
1500 | for (int i = 0; i < filters->nfilter; i++) |
1428 | for (int i = 0; i < filters->nfilter; i++) |
1501 | if (!strcmp (filters->filter[i], FilterConvolution)) |
1429 | if (!strcmp (filters->filter[i], FilterConvolution)) |
1502 | flags |= HAS_RENDER_CONV; |
1430 | bg_flags |= BG_HAS_RENDER_CONV; |
1503 | |
1431 | |
1504 | XFree (filters); |
1432 | XFree (filters); |
1505 | } |
1433 | } |
1506 | #endif |
1434 | #endif |
1507 | } |
|
|
1508 | |
|
|
1509 | void |
|
|
1510 | bgPixmap_t::apply () |
|
|
1511 | { |
|
|
1512 | if (target == NULL) |
|
|
1513 | return; |
|
|
1514 | |
|
|
1515 | if (pixmap != None) |
|
|
1516 | { |
|
|
1517 | /* set target's background to pixmap */ |
|
|
1518 | # ifdef ENABLE_TRANSPARENCY |
|
|
1519 | if (flags & isTransparent) |
|
|
1520 | { |
|
|
1521 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
|
|
1522 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
|
|
1523 | |
|
|
1524 | if (target->scrollBar.win) |
|
|
1525 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
|
|
1526 | } |
|
|
1527 | else |
|
|
1528 | # endif |
|
|
1529 | { |
|
|
1530 | /* force old pixmap dereference in case it was transparent before :*/ |
|
|
1531 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
|
|
1532 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
|
|
1533 | /* do we also need to set scrollbar's background here ? */ |
|
|
1534 | |
|
|
1535 | if (target->scrollBar.win) |
|
|
1536 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
|
|
1537 | } |
|
|
1538 | } |
|
|
1539 | else |
|
|
1540 | { |
|
|
1541 | /* set target background to a pixel */ |
|
|
1542 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
|
|
1543 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
|
|
1544 | /* do we also need to set scrollbar's background here ? */ |
|
|
1545 | if (target->scrollBar.win) |
|
|
1546 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
|
|
1547 | } |
|
|
1548 | |
|
|
1549 | /* don't want Expose on the parent or vt. It is better to use |
|
|
1550 | scr_touch or we get a great deal of flicker otherwise: */ |
|
|
1551 | XClearWindow (target->dpy, target->parent[0]); |
|
|
1552 | |
|
|
1553 | if (target->scrollBar.state && target->scrollBar.win) |
|
|
1554 | { |
|
|
1555 | target->scrollBar.state = STATE_IDLE; |
|
|
1556 | target->scrollBar.show (0); |
|
|
1557 | } |
|
|
1558 | |
|
|
1559 | target->want_refresh = 1; |
|
|
1560 | flags |= hasChanged; |
|
|
1561 | } |
1435 | } |
1562 | |
1436 | |
1563 | #endif /* HAVE_BG_PIXMAP */ |
1437 | #endif /* HAVE_BG_PIXMAP */ |
1564 | |
1438 | |
1565 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1439 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |