… | |
… | |
58 | # endif |
58 | # endif |
59 | |
59 | |
60 | void |
60 | void |
61 | rxvt_term::bg_destroy () |
61 | rxvt_term::bg_destroy () |
62 | { |
62 | { |
63 | #ifdef HAVE_PIXBUF |
|
|
64 | if (pixbuf) |
|
|
65 | g_object_unref (pixbuf); |
|
|
66 | #endif |
|
|
67 | |
|
|
68 | if (bg_pixmap) |
63 | if (bg_pixmap) |
69 | XFreePixmap (dpy, bg_pixmap); |
64 | XFreePixmap (dpy, bg_pixmap); |
70 | } |
65 | } |
71 | |
66 | |
72 | bool |
67 | bool |
… | |
… | |
90 | if (bg_flags & BG_IS_TRANSPARENT) |
85 | if (bg_flags & BG_IS_TRANSPARENT) |
91 | return true; |
86 | return true; |
92 | # endif |
87 | # endif |
93 | |
88 | |
94 | # ifdef BG_IMAGE_FROM_FILE |
89 | # ifdef BG_IMAGE_FROM_FILE |
95 | if (bg_flags & BG_IS_FROM_FILE) |
90 | if (bg_image.flags & IM_IS_SET) |
96 | { |
91 | { |
97 | if (bg_flags & BG_IS_SIZE_SENSITIVE) |
92 | if ((bg_image.flags & IM_IS_SIZE_SENSITIVE) |
|
|
93 | || bg_image.width () > szHint.width |
|
|
94 | || bg_image.height () > szHint.height) |
98 | return true; |
95 | return true; |
99 | } |
96 | } |
100 | # endif |
97 | # endif |
101 | |
98 | |
102 | return false; |
99 | return false; |
… | |
… | |
109 | if (bg_flags & BG_IS_TRANSPARENT) |
106 | if (bg_flags & BG_IS_TRANSPARENT) |
110 | return true; |
107 | return true; |
111 | # endif |
108 | # endif |
112 | |
109 | |
113 | # ifdef BG_IMAGE_FROM_FILE |
110 | # ifdef BG_IMAGE_FROM_FILE |
114 | if (bg_flags & BG_IS_FROM_FILE) |
111 | if (bg_image.flags & IM_IS_SET) |
115 | { |
112 | { |
116 | if (bg_flags & BG_ROOT_ALIGN) |
113 | if (bg_image.flags & IM_ROOT_ALIGN) |
117 | return true; |
114 | return true; |
118 | } |
115 | } |
119 | # endif |
116 | # endif |
120 | |
117 | |
121 | return false; |
118 | return false; |
… | |
… | |
149 | min_it (dst_size, target_size - dst_pos); |
146 | min_it (dst_size, target_size - dst_pos); |
150 | return src_pos; |
147 | return src_pos; |
151 | } |
148 | } |
152 | |
149 | |
153 | bool |
150 | bool |
154 | rxvt_term::bg_set_geometry (const char *geom, bool update) |
151 | rxvt_image::set_geometry (const char *geom, bool update) |
155 | { |
152 | { |
156 | bool changed = false; |
153 | bool changed = false; |
157 | int geom_flags = 0; |
154 | int geom_flags = 0; |
158 | int x = h_align; |
155 | int x = h_align; |
159 | int y = v_align; |
156 | int y = v_align; |
… | |
… | |
170 | |
167 | |
171 | for (int i = 0; arr[i]; i++) |
168 | for (int i = 0; arr[i]; i++) |
172 | { |
169 | { |
173 | if (!strcasecmp (arr[i], "style=tiled")) |
170 | if (!strcasecmp (arr[i], "style=tiled")) |
174 | { |
171 | { |
175 | new_flags = BG_TILE; |
172 | new_flags = IM_TILE; |
176 | w = h = noScale; |
173 | w = h = noScale; |
177 | x = y = 0; |
174 | x = y = 0; |
178 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
175 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
179 | } |
176 | } |
180 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
177 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
181 | { |
178 | { |
182 | new_flags = BG_KEEP_ASPECT; |
179 | new_flags = IM_KEEP_ASPECT; |
183 | w = h = windowScale; |
180 | w = h = windowScale; |
184 | x = y = centerAlign; |
181 | x = y = centerAlign; |
185 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
182 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
186 | } |
183 | } |
187 | else if (!strcasecmp (arr[i], "style=stretched")) |
184 | else if (!strcasecmp (arr[i], "style=stretched")) |
… | |
… | |
197 | x = y = centerAlign; |
194 | x = y = centerAlign; |
198 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
195 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
199 | } |
196 | } |
200 | else if (!strcasecmp (arr[i], "style=root-tiled")) |
197 | else if (!strcasecmp (arr[i], "style=root-tiled")) |
201 | { |
198 | { |
202 | new_flags = BG_TILE|BG_ROOT_ALIGN; |
199 | new_flags = IM_TILE|IM_ROOT_ALIGN; |
203 | w = h = noScale; |
200 | w = h = noScale; |
204 | geom_flags = WidthValue|HeightValue; |
201 | geom_flags = WidthValue|HeightValue; |
205 | } |
202 | } |
206 | else if (!strcasecmp (arr[i], "op=tile")) |
203 | else if (!strcasecmp (arr[i], "op=tile")) |
207 | new_flags |= BG_TILE; |
204 | new_flags |= IM_TILE; |
208 | else if (!strcasecmp (arr[i], "op=keep-aspect")) |
205 | else if (!strcasecmp (arr[i], "op=keep-aspect")) |
209 | new_flags |= BG_KEEP_ASPECT; |
206 | new_flags |= IM_KEEP_ASPECT; |
210 | else if (!strcasecmp (arr[i], "op=root-align")) |
207 | else if (!strcasecmp (arr[i], "op=root-align")) |
211 | new_flags |= BG_ROOT_ALIGN; |
208 | new_flags |= IM_ROOT_ALIGN; |
212 | |
209 | |
213 | // deprecated |
210 | // deprecated |
214 | else if (!strcasecmp (arr[i], "tile")) |
211 | else if (!strcasecmp (arr[i], "tile")) |
215 | { |
212 | { |
216 | new_flags |= BG_TILE; |
213 | new_flags |= IM_TILE; |
217 | w = h = noScale; |
214 | w = h = noScale; |
218 | geom_flags |= WidthValue|HeightValue; |
215 | geom_flags |= WidthValue|HeightValue; |
219 | } |
216 | } |
220 | else if (!strcasecmp (arr[i], "propscale")) |
217 | else if (!strcasecmp (arr[i], "propscale")) |
221 | { |
218 | { |
222 | new_flags |= BG_KEEP_ASPECT; |
219 | new_flags |= IM_KEEP_ASPECT; |
223 | w = h = windowScale; |
220 | w = h = windowScale; |
224 | geom_flags |= WidthValue|HeightValue; |
221 | geom_flags |= WidthValue|HeightValue; |
225 | } |
222 | } |
226 | else if (!strcasecmp (arr[i], "hscale")) |
223 | else if (!strcasecmp (arr[i], "hscale")) |
227 | { |
224 | { |
228 | new_flags |= BG_TILE; |
225 | new_flags |= IM_TILE; |
229 | w = windowScale; |
226 | w = windowScale; |
230 | h = noScale; |
227 | h = noScale; |
231 | geom_flags |= WidthValue|HeightValue; |
228 | geom_flags |= WidthValue|HeightValue; |
232 | } |
229 | } |
233 | else if (!strcasecmp (arr[i], "vscale")) |
230 | else if (!strcasecmp (arr[i], "vscale")) |
234 | { |
231 | { |
235 | new_flags |= BG_TILE; |
232 | new_flags |= IM_TILE; |
236 | h = windowScale; |
233 | h = windowScale; |
237 | w = noScale; |
234 | w = noScale; |
238 | geom_flags |= WidthValue|HeightValue; |
235 | geom_flags |= WidthValue|HeightValue; |
239 | } |
236 | } |
240 | else if (!strcasecmp (arr[i], "scale")) |
237 | else if (!strcasecmp (arr[i], "scale")) |
… | |
… | |
248 | x = y = centerAlign; |
245 | x = y = centerAlign; |
249 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
246 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
250 | } |
247 | } |
251 | else if (!strcasecmp (arr[i], "root")) |
248 | else if (!strcasecmp (arr[i], "root")) |
252 | { |
249 | { |
253 | new_flags |= BG_TILE|BG_ROOT_ALIGN; |
250 | new_flags |= IM_TILE|IM_ROOT_ALIGN; |
254 | w = h = noScale; |
251 | w = h = noScale; |
255 | geom_flags |= WidthValue|HeightValue; |
252 | geom_flags |= WidthValue|HeightValue; |
256 | } |
253 | } |
257 | |
254 | |
258 | else |
255 | else |
… | |
… | |
260 | } /* done parsing ops */ |
257 | } /* done parsing ops */ |
261 | |
258 | |
262 | rxvt_free_strsplit (arr); |
259 | rxvt_free_strsplit (arr); |
263 | } |
260 | } |
264 | |
261 | |
265 | new_flags |= bg_flags & ~BG_GEOMETRY_FLAGS; |
262 | new_flags |= flags & ~IM_GEOMETRY_FLAGS; |
266 | |
263 | |
267 | if (!update) |
264 | if (!update) |
268 | { |
265 | { |
269 | if (!(geom_flags & XValue)) |
266 | if (!(geom_flags & XValue)) |
270 | x = y = defaultAlign; |
267 | x = y = defaultAlign; |
… | |
… | |
282 | min_it (w, 1000); |
279 | min_it (w, 1000); |
283 | min_it (h, 1000); |
280 | min_it (h, 1000); |
284 | clamp_it (x, -100, 200); |
281 | clamp_it (x, -100, 200); |
285 | clamp_it (y, -100, 200); |
282 | clamp_it (y, -100, 200); |
286 | |
283 | |
287 | if (bg_flags != new_flags |
284 | if (flags != new_flags |
288 | || h_scale != w |
285 | || h_scale != w |
289 | || v_scale != h |
286 | || v_scale != h |
290 | || h_align != x |
287 | || h_align != x |
291 | || v_align != y) |
288 | || v_align != y) |
292 | { |
289 | { |
293 | bg_flags = new_flags; |
290 | flags = new_flags; |
294 | h_scale = w; |
291 | h_scale = w; |
295 | v_scale = h; |
292 | v_scale = h; |
296 | h_align = x; |
293 | h_align = x; |
297 | v_align = y; |
294 | v_align = y; |
298 | changed = true; |
295 | changed = true; |
299 | } |
296 | } |
300 | |
297 | |
|
|
298 | if (!(flags & IM_TILE) |
|
|
299 | || h_scale || v_scale |
|
|
300 | || (!(flags & IM_ROOT_ALIGN) && (h_align || v_align))) |
|
|
301 | flags |= IM_IS_SIZE_SENSITIVE; |
|
|
302 | else |
|
|
303 | flags &= ~IM_IS_SIZE_SENSITIVE; |
|
|
304 | |
301 | return changed; |
305 | return changed; |
302 | } |
306 | } |
303 | |
307 | |
304 | void |
308 | void |
305 | rxvt_term::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
309 | rxvt_term::get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y) |
306 | { |
310 | { |
|
|
311 | int image_width = image.width (); |
|
|
312 | int image_height = image.height (); |
307 | int target_width = szHint.width; |
313 | int target_width = szHint.width; |
308 | int target_height = szHint.height; |
314 | int target_height = szHint.height; |
309 | |
315 | |
310 | w = h_scale * target_width / 100; |
316 | w = image.h_scale * target_width / 100; |
311 | h = v_scale * target_height / 100; |
317 | h = image.v_scale * target_height / 100; |
312 | |
318 | |
313 | if (bg_flags & BG_KEEP_ASPECT) |
319 | if (image.flags & IM_KEEP_ASPECT) |
314 | { |
320 | { |
315 | float scale = (float)w / image_width; |
321 | float scale = (float)w / image_width; |
316 | min_it (scale, (float)h / image_height); |
322 | min_it (scale, (float)h / image_height); |
317 | w = image_width * scale + 0.5; |
323 | w = image_width * scale + 0.5; |
318 | h = image_height * scale + 0.5; |
324 | h = image_height * scale + 0.5; |
319 | } |
325 | } |
320 | |
326 | |
321 | if (!w) w = image_width; |
327 | if (!w) w = image_width; |
322 | if (!h) h = image_height; |
328 | if (!h) h = image_height; |
323 | |
329 | |
324 | if (bg_flags & BG_ROOT_ALIGN) |
330 | if (image.flags & IM_ROOT_ALIGN) |
325 | { |
331 | { |
326 | x = -target_x; |
332 | x = -target_x; |
327 | y = -target_y; |
333 | y = -target_y; |
328 | } |
334 | } |
329 | else |
335 | else |
330 | { |
336 | { |
331 | x = make_align_position (h_align, target_width, w); |
337 | x = make_align_position (image.h_align, target_width, w); |
332 | y = make_align_position (v_align, target_height, h); |
338 | y = make_align_position (image.v_align, target_height, h); |
333 | } |
339 | } |
334 | |
|
|
335 | if (!(bg_flags & BG_TILE) |
|
|
336 | || h_scale || v_scale |
|
|
337 | || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) |
|
|
338 | || image_width > target_width || image_height > target_height) |
|
|
339 | bg_flags |= BG_IS_SIZE_SENSITIVE; |
|
|
340 | else |
|
|
341 | bg_flags &= ~BG_IS_SIZE_SENSITIVE; |
|
|
342 | } |
340 | } |
343 | |
341 | |
344 | # ifdef HAVE_PIXBUF |
342 | # ifdef HAVE_PIXBUF |
345 | bool |
343 | bool |
346 | rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, |
344 | rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, |
… | |
… | |
454 | XDestroyImage (ximage); |
452 | XDestroyImage (ximage); |
455 | return true; |
453 | return true; |
456 | } |
454 | } |
457 | |
455 | |
458 | bool |
456 | bool |
459 | rxvt_term::render_image (bool transparent) |
457 | rxvt_term::render_image (rxvt_image &image) |
460 | { |
458 | { |
|
|
459 | GdkPixbuf *pixbuf = image.pixbuf; |
461 | if (!pixbuf) |
460 | if (!pixbuf) |
462 | return false; |
461 | return false; |
463 | |
462 | |
464 | if (transparent |
463 | bool need_blend = bg_flags & BG_IS_VALID; |
|
|
464 | |
|
|
465 | if (need_blend |
465 | && !(bg_flags & BG_HAS_RENDER)) |
466 | && !(bg_flags & BG_HAS_RENDER)) |
466 | return false; |
467 | return false; |
467 | |
468 | |
468 | GdkPixbuf *result; |
469 | GdkPixbuf *result; |
469 | |
470 | |
… | |
… | |
478 | int x = 0; |
479 | int x = 0; |
479 | int y = 0; |
480 | int y = 0; |
480 | int w = 0; |
481 | int w = 0; |
481 | int h = 0; |
482 | int h = 0; |
482 | |
483 | |
483 | get_image_geometry (image_width, image_height, w, h, x, y); |
484 | get_image_geometry (image, w, h, x, y); |
484 | |
485 | |
485 | if (!(bg_flags & BG_ROOT_ALIGN) |
486 | if (!(image.flags & IM_ROOT_ALIGN) |
486 | && (x >= target_width |
487 | && (x >= target_width |
487 | || y >= target_height |
488 | || y >= target_height |
488 | || x + w <= 0 |
489 | || x + w <= 0 |
489 | || y + h <= 0)) |
490 | || y + h <= 0)) |
490 | return false; |
491 | return false; |
… | |
… | |
504 | |
505 | |
505 | bool ret = false; |
506 | bool ret = false; |
506 | |
507 | |
507 | XGCValues gcv; |
508 | XGCValues gcv; |
508 | GC gc; |
509 | GC gc; |
509 | Pixmap root_pmap; |
510 | Pixmap tmp_pixmap; |
510 | |
511 | |
511 | image_width = gdk_pixbuf_get_width (result); |
512 | image_width = gdk_pixbuf_get_width (result); |
512 | image_height = gdk_pixbuf_get_height (result); |
513 | image_height = gdk_pixbuf_get_height (result); |
513 | |
514 | |
514 | if (transparent) |
515 | if (need_blend) |
515 | { |
516 | { |
516 | root_pmap = bg_pixmap; |
517 | tmp_pixmap = bg_pixmap; |
517 | bg_pixmap = None; |
518 | bg_pixmap = None; |
518 | } |
519 | } |
519 | else |
520 | else |
520 | { |
521 | { |
521 | if (bg_flags & BG_TILE) |
522 | if (image.flags & IM_TILE) |
522 | { |
523 | { |
523 | new_pmap_width = min (image_width, target_width); |
524 | new_pmap_width = min (image_width, target_width); |
524 | new_pmap_height = min (image_height, target_height); |
525 | new_pmap_height = min (image_height, target_height); |
525 | } |
526 | } |
526 | } |
527 | } |
… | |
… | |
539 | gcv.foreground = pix_colors[Color_bg]; |
540 | gcv.foreground = pix_colors[Color_bg]; |
540 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
541 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
541 | |
542 | |
542 | if (gc) |
543 | if (gc) |
543 | { |
544 | { |
544 | if (bg_flags & BG_TILE) |
545 | if (image.flags & IM_TILE) |
545 | { |
546 | { |
546 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
547 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
547 | pixbuf_to_pixmap (result, tile, gc, |
548 | pixbuf_to_pixmap (result, tile, gc, |
548 | 0, 0, |
549 | 0, 0, |
549 | 0, 0, |
550 | 0, 0, |
… | |
… | |
577 | dst_x, dst_y, |
578 | dst_x, dst_y, |
578 | dst_width, dst_height); |
579 | dst_width, dst_height); |
579 | } |
580 | } |
580 | |
581 | |
581 | #if XRENDER |
582 | #if XRENDER |
582 | if (transparent) |
583 | if (need_blend) |
583 | { |
584 | { |
584 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
585 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
585 | |
586 | |
586 | Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, 0); |
587 | Picture src = XRenderCreatePicture (dpy, tmp_pixmap, format, 0, 0); |
587 | |
588 | |
588 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); |
589 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); |
589 | |
590 | |
590 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
591 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
591 | |
592 | |
… | |
… | |
611 | } |
612 | } |
612 | |
613 | |
613 | if (result != pixbuf) |
614 | if (result != pixbuf) |
614 | g_object_unref (result); |
615 | g_object_unref (result); |
615 | |
616 | |
616 | if (transparent) |
617 | if (need_blend) |
617 | XFreePixmap (dpy, root_pmap); |
618 | XFreePixmap (dpy, tmp_pixmap); |
618 | |
619 | |
619 | return ret; |
620 | return ret; |
620 | } |
621 | } |
621 | # endif /* HAVE_PIXBUF */ |
622 | # endif /* HAVE_PIXBUF */ |
622 | |
623 | |
623 | bool |
624 | bool |
624 | rxvt_term::bg_set_file (const char *file) |
625 | rxvt_image::set_file (const char *file) |
625 | { |
626 | { |
626 | if (!file || !*file) |
627 | if (!file || !*file) |
627 | return false; |
628 | return false; |
628 | |
629 | |
629 | bool ret = false; |
630 | bool ret = false; |
… | |
… | |
643 | if (image) |
644 | if (image) |
644 | { |
645 | { |
645 | if (pixbuf) |
646 | if (pixbuf) |
646 | g_object_unref (pixbuf); |
647 | g_object_unref (pixbuf); |
647 | pixbuf = image; |
648 | pixbuf = image; |
648 | bg_flags |= BG_IS_FROM_FILE; |
|
|
649 | ret = true; |
649 | ret = true; |
650 | } |
650 | } |
651 | # endif |
651 | # endif |
652 | |
652 | |
653 | if (ret) |
653 | if (ret) |
654 | { |
654 | { |
|
|
655 | flags = IM_IS_SET | IM_IS_SIZE_SENSITIVE; |
|
|
656 | h_scale = v_scale = defaultScale; |
|
|
657 | h_align = v_align = defaultAlign; |
|
|
658 | |
655 | if (p) |
659 | if (p) |
656 | bg_set_geometry (p + 1); |
660 | set_geometry (p + 1); |
657 | else |
|
|
658 | bg_set_default_geometry (); |
|
|
659 | } |
661 | } |
660 | |
662 | |
661 | return ret; |
663 | return ret; |
662 | } |
664 | } |
663 | |
665 | |
… | |
… | |
758 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
760 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
759 | } |
761 | } |
760 | #endif |
762 | #endif |
761 | |
763 | |
762 | bool |
764 | bool |
763 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height, int depth) |
765 | rxvt_term::blur_pixmap (Pixmap pixmap, int width, int height) |
764 | { |
766 | { |
765 | bool ret = false; |
767 | bool ret = false; |
766 | #if XRENDER |
768 | #if XRENDER |
767 | if (!(bg_flags & BG_HAS_RENDER_CONV)) |
769 | if (!(bg_flags & BG_HAS_RENDER_CONV)) |
768 | return false; |
770 | return false; |
… | |
… | |
823 | #endif |
825 | #endif |
824 | return ret; |
826 | return ret; |
825 | } |
827 | } |
826 | |
828 | |
827 | bool |
829 | bool |
828 | rxvt_term::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
830 | rxvt_term::tint_pixmap (Pixmap pixmap, int width, int height) |
829 | { |
831 | { |
830 | bool ret = false; |
832 | bool ret = false; |
831 | |
833 | |
832 | if (shade == 100 && (bg_flags & BG_TINT_BITAND)) |
834 | if (shade == 100 && (bg_flags & BG_TINT_BITAND)) |
833 | { |
835 | { |
… | |
… | |
1020 | |
1022 | |
1021 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1023 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1022 | { |
1024 | { |
1023 | if (need_blur) |
1025 | if (need_blur) |
1024 | { |
1026 | { |
1025 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height, depth)) |
1027 | if (blur_pixmap (bg_pixmap, window_width, window_height)) |
1026 | need_blur = false; |
1028 | need_blur = false; |
1027 | } |
1029 | } |
1028 | if (need_tint) |
1030 | if (need_tint) |
1029 | { |
1031 | { |
1030 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1032 | if (tint_pixmap (bg_pixmap, window_width, window_height)) |
1031 | need_tint = false; |
1033 | need_tint = false; |
1032 | } |
1034 | } |
1033 | if (need_tint) |
1035 | if (need_tint) |
1034 | { |
1036 | { |
1035 | XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
1037 | XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
1036 | if (ximage) |
1038 | if (ximage) |
1037 | { |
1039 | { |
1038 | /* our own client-side tinting */ |
1040 | /* our own client-side tinting */ |
1039 | tint_ximage (DefaultVisual (dpy, display->screen), ximage); |
1041 | tint_ximage (ximage); |
1040 | |
1042 | |
1041 | XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height); |
1043 | XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height); |
1042 | XDestroyImage (ximage); |
1044 | XDestroyImage (ximage); |
1043 | } |
1045 | } |
1044 | } |
1046 | } |
… | |
… | |
1065 | # endif /* ENABLE_TRANSPARENCY */ |
1067 | # endif /* ENABLE_TRANSPARENCY */ |
1066 | |
1068 | |
1067 | bool |
1069 | bool |
1068 | rxvt_term::bg_render () |
1070 | rxvt_term::bg_render () |
1069 | { |
1071 | { |
1070 | bool transparent = false; |
|
|
1071 | |
|
|
1072 | bg_invalidate (); |
1072 | bg_invalidate (); |
1073 | # ifdef ENABLE_TRANSPARENCY |
1073 | # ifdef ENABLE_TRANSPARENCY |
1074 | if (bg_flags & BG_IS_TRANSPARENT) |
1074 | if (bg_flags & BG_IS_TRANSPARENT) |
1075 | { |
1075 | { |
1076 | /* we need to re-generate transparency pixmap in that case ! */ |
1076 | /* we need to re-generate transparency pixmap in that case ! */ |
1077 | transparent = make_transparency_pixmap (); |
1077 | if (make_transparency_pixmap ()) |
1078 | if (transparent) |
|
|
1079 | bg_flags |= BG_IS_VALID; |
1078 | bg_flags |= BG_IS_VALID; |
1080 | } |
1079 | } |
1081 | # endif |
1080 | # endif |
1082 | |
1081 | |
1083 | # ifdef BG_IMAGE_FROM_FILE |
1082 | # ifdef BG_IMAGE_FROM_FILE |
1084 | if (bg_flags & BG_IS_FROM_FILE) |
1083 | if (bg_image.flags & IM_IS_SET) |
1085 | { |
1084 | { |
1086 | if (render_image (transparent)) |
1085 | if (render_image (bg_image)) |
1087 | bg_flags |= BG_IS_VALID; |
1086 | bg_flags |= BG_IS_VALID; |
1088 | } |
1087 | } |
1089 | # endif |
1088 | # endif |
1090 | |
1089 | |
1091 | if (!(bg_flags & BG_IS_VALID)) |
1090 | if (!(bg_flags & BG_IS_VALID)) |
… | |
… | |
1145 | lookup[i] = (tmp / 0xffff) << sh; |
1144 | lookup[i] = (tmp / 0xffff) << sh; |
1146 | } |
1145 | } |
1147 | } |
1146 | } |
1148 | |
1147 | |
1149 | void |
1148 | void |
1150 | rxvt_term::tint_ximage (Visual *visual, XImage *ximage) |
1149 | rxvt_term::tint_ximage (XImage *ximage) |
1151 | { |
1150 | { |
1152 | unsigned int size_r, size_g, size_b; |
1151 | unsigned int size_r, size_g, size_b; |
1153 | int sh_r, sh_g, sh_b; |
1152 | int sh_r, sh_g, sh_b; |
1154 | uint32_t mask_r, mask_g, mask_b; |
1153 | uint32_t mask_r, mask_g, mask_b; |
1155 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1154 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |