1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: background.C - former xpm.C |
2 | * File: background.C - former xpm.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2008 Marc Lehmann <schmorp@schmorp.de> |
7 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
7 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
8 | * Copyright (c) 2010 Emanuele Giaquinta <e.giaquinta@glauco.it> |
8 | * Copyright (c) 2010 Emanuele Giaquinta <e.giaquinta@glauco.it> |
9 | * |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
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 |
11 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
65 | rxvt_term::bg_destroy () |
65 | rxvt_term::bg_destroy () |
66 | { |
66 | { |
67 | #ifdef HAVE_AFTERIMAGE |
67 | #ifdef HAVE_AFTERIMAGE |
68 | if (original_asim) |
68 | if (original_asim) |
69 | safe_asimage_destroy (original_asim); |
69 | safe_asimage_destroy (original_asim); |
|
|
70 | if (asv) |
|
|
71 | destroy_asvisual (asv, 0); |
|
|
72 | if (asimman) |
|
|
73 | destroy_image_manager (asimman, 0); |
70 | #endif |
74 | #endif |
71 | |
75 | |
72 | #ifdef HAVE_PIXBUF |
76 | #ifdef HAVE_PIXBUF |
73 | if (pixbuf) |
77 | if (pixbuf) |
74 | g_object_unref (pixbuf); |
78 | g_object_unref (pixbuf); |
… | |
… | |
94 | |
98 | |
95 | bool |
99 | bool |
96 | rxvt_term::bg_window_size_sensitive () |
100 | rxvt_term::bg_window_size_sensitive () |
97 | { |
101 | { |
98 | # ifdef ENABLE_TRANSPARENCY |
102 | # ifdef ENABLE_TRANSPARENCY |
99 | if (bg_flags & isTransparent) |
103 | if (bg_flags & BG_IS_TRANSPARENT) |
100 | return true; |
104 | return true; |
101 | # endif |
105 | # endif |
102 | |
106 | |
103 | # ifdef BG_IMAGE_FROM_FILE |
107 | # ifdef BG_IMAGE_FROM_FILE |
104 | if (have_image) |
108 | if (bg_flags & BG_IS_FROM_FILE) |
105 | { |
109 | { |
106 | if (bg_flags & sizeSensitive) |
110 | if (bg_flags & BG_IS_SIZE_SENSITIVE) |
107 | return true; |
111 | return true; |
108 | } |
112 | } |
109 | # endif |
113 | # endif |
110 | |
114 | |
111 | return false; |
115 | return false; |
… | |
… | |
113 | |
117 | |
114 | bool |
118 | bool |
115 | rxvt_term::bg_window_position_sensitive () |
119 | rxvt_term::bg_window_position_sensitive () |
116 | { |
120 | { |
117 | # ifdef ENABLE_TRANSPARENCY |
121 | # ifdef ENABLE_TRANSPARENCY |
118 | if (bg_flags & isTransparent) |
122 | if (bg_flags & BG_IS_TRANSPARENT) |
119 | return true; |
123 | return true; |
120 | # endif |
124 | # endif |
121 | |
125 | |
122 | # ifdef BG_IMAGE_FROM_FILE |
126 | # ifdef BG_IMAGE_FROM_FILE |
123 | if (have_image) |
127 | if (bg_flags & BG_IS_FROM_FILE) |
124 | { |
128 | { |
125 | if (bg_flags & rootAlign) |
129 | if (bg_flags & BG_ROOT_ALIGN) |
126 | return true; |
130 | return true; |
127 | } |
131 | } |
128 | # endif |
132 | # endif |
129 | |
133 | |
130 | return false; |
134 | return false; |
… | |
… | |
204 | bool changed = false; |
208 | bool changed = false; |
205 | int geom_flags = 0; |
209 | int geom_flags = 0; |
206 | int x = 0, y = 0; |
210 | int x = 0, y = 0; |
207 | unsigned int w = 0, h = 0; |
211 | unsigned int w = 0, h = 0; |
208 | unsigned int n; |
212 | unsigned int n; |
209 | unsigned long new_flags = (bg_flags & (~geometryFlags)); |
213 | unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS)); |
210 | const char *ops; |
214 | const char *ops; |
211 | |
215 | |
212 | if (geom == NULL) |
216 | if (geom == NULL) |
213 | return false; |
217 | return false; |
214 | |
218 | |
… | |
… | |
261 | w = h = noScale; |
265 | w = h = noScale; |
262 | geom_flags |= WidthValue|HeightValue; |
266 | geom_flags |= WidthValue|HeightValue; |
263 | } |
267 | } |
264 | else if (!strcasecmp (arr[i], "propscale")) |
268 | else if (!strcasecmp (arr[i], "propscale")) |
265 | { |
269 | { |
266 | new_flags |= propScale; |
270 | new_flags |= BG_PROP_SCALE; |
267 | } |
271 | } |
268 | else if (!strcasecmp (arr[i], "hscale")) |
272 | else if (!strcasecmp (arr[i], "hscale")) |
269 | { |
273 | { |
270 | if (w == 0) w = windowScale; |
274 | if (w == 0) w = windowScale; |
271 | |
275 | |
… | |
… | |
292 | x = y = centerAlign; |
296 | x = y = centerAlign; |
293 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
297 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
294 | } |
298 | } |
295 | else if (!strcasecmp (arr[i], "root")) |
299 | else if (!strcasecmp (arr[i], "root")) |
296 | { |
300 | { |
297 | new_flags |= rootAlign; |
301 | new_flags |= BG_ROOT_ALIGN; |
298 | w = h = noScale; |
302 | w = h = noScale; |
299 | geom_flags |= WidthValue|HeightValue; |
303 | geom_flags |= WidthValue|HeightValue; |
300 | } |
304 | } |
301 | } /* done parsing ops */ |
305 | } /* done parsing ops */ |
302 | |
306 | |
… | |
… | |
321 | rxvt_term::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
325 | rxvt_term::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
322 | { |
326 | { |
323 | int target_width = szHint.width; |
327 | int target_width = szHint.width; |
324 | int target_height = szHint.height; |
328 | int target_height = szHint.height; |
325 | |
329 | |
326 | if (bg_flags & propScale) |
330 | if (bg_flags & BG_PROP_SCALE) |
327 | { |
331 | { |
328 | float scale = (float)target_width / image_width; |
332 | float scale = (float)target_width / image_width; |
329 | min_it (scale, (float)target_height / image_height); |
333 | min_it (scale, (float)target_height / image_height); |
330 | w = image_width * scale + 0.5; |
334 | w = image_width * scale + 0.5; |
331 | h = image_height * scale + 0.5; |
335 | h = image_height * scale + 0.5; |
… | |
… | |
337 | } |
341 | } |
338 | |
342 | |
339 | if (!w) w = image_width; |
343 | if (!w) w = image_width; |
340 | if (!h) h = image_height; |
344 | if (!h) h = image_height; |
341 | |
345 | |
342 | if (bg_flags & rootAlign) |
346 | if (bg_flags & BG_ROOT_ALIGN) |
343 | { |
347 | { |
344 | x = -target_x; |
348 | x = -target_x; |
345 | y = -target_y; |
349 | y = -target_y; |
346 | } |
350 | } |
347 | else |
351 | else |
348 | { |
352 | { |
349 | x = make_align_position (h_align, target_width, w); |
353 | x = make_align_position (h_align, target_width, w); |
350 | y = make_align_position (v_align, target_height, h); |
354 | y = make_align_position (v_align, target_height, h); |
351 | } |
355 | } |
352 | |
356 | |
353 | bg_flags &= ~sizeSensitive; |
357 | bg_flags &= ~BG_IS_SIZE_SENSITIVE; |
354 | if ((bg_flags & propScale) || h_scale || v_scale |
358 | if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale |
355 | || (!(bg_flags & rootAlign) && (h_align || v_align)) |
359 | || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) |
356 | || w > target_width || h > target_height) |
360 | || w > target_width || h > target_height) |
357 | bg_flags |= sizeSensitive; |
361 | bg_flags |= BG_IS_SIZE_SENSITIVE; |
358 | } |
362 | } |
359 | |
363 | |
360 | # ifdef HAVE_AFTERIMAGE |
364 | # ifdef HAVE_AFTERIMAGE |
361 | bool |
365 | bool |
362 | rxvt_term::render_image (unsigned long tr_flags) |
366 | rxvt_term::render_image (unsigned long tr_flags) |
… | |
… | |
368 | |
372 | |
369 | # ifdef ENABLE_TRANSPARENCY |
373 | # ifdef ENABLE_TRANSPARENCY |
370 | if (tr_flags) |
374 | if (tr_flags) |
371 | background = pixmap2ximage (asv, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, 100); |
375 | background = pixmap2ximage (asv, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, 100); |
372 | |
376 | |
373 | if (tr_flags & tintNeeded) |
377 | if (tr_flags & BG_NEEDS_TINT) |
374 | { |
378 | { |
375 | ShadingInfo as_shade; |
379 | ShadingInfo as_shade; |
376 | as_shade.shading = shade; |
380 | as_shade.shading = shade; |
377 | |
381 | |
378 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
382 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
379 | if (bg_flags & tintSet) |
383 | if (bg_flags & BG_TINT_SET) |
380 | tint.get (c); |
384 | tint.get (c); |
381 | as_shade.tintColor.red = c.r; |
385 | as_shade.tintColor.red = c.r; |
382 | as_shade.tintColor.green = c.g; |
386 | as_shade.tintColor.green = c.g; |
383 | as_shade.tintColor.blue = c.b; |
387 | as_shade.tintColor.blue = c.b; |
384 | |
388 | |
385 | background_tint = shading2tint32 (&as_shade); |
389 | background_tint = shading2tint32 (&as_shade); |
386 | } |
390 | } |
387 | |
391 | |
388 | if ((tr_flags & blurNeeded) && background != NULL) |
392 | if ((tr_flags & BG_NEEDS_BLUR) && background != NULL) |
389 | { |
393 | { |
390 | ASImage *tmp = blur_asimage_gauss (asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
394 | ASImage *tmp = blur_asimage_gauss (asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
391 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
395 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
392 | 100, ASIMAGE_QUALITY_DEFAULT); |
396 | 100, ASIMAGE_QUALITY_DEFAULT); |
393 | if (tmp) |
397 | if (tmp) |
… | |
… | |
412 | |
416 | |
413 | if (original_asim) |
417 | if (original_asim) |
414 | get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); |
418 | get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); |
415 | |
419 | |
416 | if (!original_asim |
420 | if (!original_asim |
417 | || (!(bg_flags & rootAlign) |
421 | || (!(bg_flags & BG_ROOT_ALIGN) |
418 | && (x >= target_width |
422 | && (x >= target_width |
419 | || y >= target_height |
423 | || y >= target_height |
420 | || (x + w <= 0) |
424 | || (x + w <= 0) |
421 | || (y + h <= 0)))) |
425 | || (y + h <= 0)))) |
422 | { |
426 | { |
… | |
… | |
682 | { |
686 | { |
683 | if (!pixbuf) |
687 | if (!pixbuf) |
684 | return false; |
688 | return false; |
685 | |
689 | |
686 | if (tr_flags |
690 | if (tr_flags |
687 | && !(bg_flags & HAS_RENDER)) |
691 | && !(bg_flags & BG_HAS_RENDER)) |
688 | return false; |
692 | return false; |
689 | |
693 | |
690 | GdkPixbuf *result; |
694 | GdkPixbuf *result; |
691 | |
695 | |
692 | int image_width = gdk_pixbuf_get_width (pixbuf); |
696 | int image_width = gdk_pixbuf_get_width (pixbuf); |
… | |
… | |
702 | int w = 0; |
706 | int w = 0; |
703 | int h = 0; |
707 | int h = 0; |
704 | |
708 | |
705 | get_image_geometry (image_width, image_height, w, h, x, y); |
709 | get_image_geometry (image_width, image_height, w, h, x, y); |
706 | |
710 | |
707 | if (!(bg_flags & rootAlign) |
711 | if (!(bg_flags & BG_ROOT_ALIGN) |
708 | && (x >= target_width |
712 | && (x >= target_width |
709 | || y >= target_height |
713 | || y >= target_height |
710 | || (x + w <= 0) |
714 | || (x + w <= 0) |
711 | || (y + h <= 0))) |
715 | || (y + h <= 0))) |
712 | return false; |
716 | return false; |
… | |
… | |
719 | result = gdk_pixbuf_scale_simple (pixbuf, |
723 | result = gdk_pixbuf_scale_simple (pixbuf, |
720 | w, h, |
724 | w, h, |
721 | GDK_INTERP_BILINEAR); |
725 | GDK_INTERP_BILINEAR); |
722 | } |
726 | } |
723 | |
727 | |
|
|
728 | if (!result) |
|
|
729 | return false; |
|
|
730 | |
724 | bool ret = false; |
731 | bool ret = false; |
725 | |
732 | |
726 | if (result) |
|
|
727 | { |
|
|
728 | XGCValues gcv; |
733 | XGCValues gcv; |
729 | GC gc; |
734 | GC gc; |
730 | Pixmap root_pmap; |
735 | Pixmap root_pmap; |
731 | |
736 | |
732 | image_width = gdk_pixbuf_get_width (result); |
737 | image_width = gdk_pixbuf_get_width (result); |
733 | image_height = gdk_pixbuf_get_height (result); |
738 | image_height = gdk_pixbuf_get_height (result); |
734 | |
739 | |
735 | if (tr_flags) |
740 | if (tr_flags) |
736 | { |
741 | { |
737 | root_pmap = bg_pixmap; |
742 | root_pmap = bg_pixmap; |
738 | bg_pixmap = None; |
743 | bg_pixmap = None; |
739 | } |
744 | } |
740 | else |
745 | else |
741 | { |
746 | { |
742 | if (h_scale == 0 || v_scale == 0) |
747 | if (h_scale == 0 || v_scale == 0) |
743 | { |
748 | { |
744 | new_pmap_width = min (image_width, target_width); |
749 | new_pmap_width = min (image_width, target_width); |
745 | new_pmap_height = min (image_height, target_height); |
750 | new_pmap_height = min (image_height, target_height); |
746 | } |
751 | } |
747 | } |
752 | } |
748 | |
753 | |
749 | if (bg_pixmap == None |
754 | if (bg_pixmap == None |
750 | || bg_pmap_width != new_pmap_width |
755 | || bg_pmap_width != new_pmap_width |
751 | || bg_pmap_height != new_pmap_height) |
756 | || bg_pmap_height != new_pmap_height) |
752 | { |
757 | { |
753 | if (bg_pixmap) |
758 | if (bg_pixmap) |
754 | XFreePixmap (dpy, bg_pixmap); |
759 | XFreePixmap (dpy, bg_pixmap); |
755 | bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); |
760 | bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); |
756 | bg_pmap_width = new_pmap_width; |
761 | bg_pmap_width = new_pmap_width; |
757 | bg_pmap_height = new_pmap_height; |
762 | bg_pmap_height = new_pmap_height; |
758 | } |
763 | } |
759 | |
764 | |
760 | gcv.foreground = pix_colors[Color_bg]; |
765 | gcv.foreground = pix_colors[Color_bg]; |
761 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
766 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
762 | |
767 | |
|
|
768 | if (gc) |
|
|
769 | { |
763 | if (h_scale == 0 || v_scale == 0) |
770 | if (h_scale == 0 || v_scale == 0) |
764 | { |
771 | { |
765 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
772 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
766 | pixbuf_to_pixmap (result, tile, gc, |
773 | pixbuf_to_pixmap (result, tile, gc, |
767 | 0, 0, |
774 | 0, 0, |
… | |
… | |
812 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
819 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
813 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
820 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
814 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
821 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
815 | XFreePixmap (dpy, mask_pmap); |
822 | XFreePixmap (dpy, mask_pmap); |
816 | |
823 | |
817 | if (src && dst && mask) |
|
|
818 | { |
|
|
819 | XRenderColor mask_c; |
824 | XRenderColor mask_c; |
820 | |
825 | |
821 | mask_c.alpha = 0x8000; |
826 | mask_c.alpha = 0x8000; |
822 | mask_c.red = 0; |
827 | mask_c.red = 0; |
823 | mask_c.green = 0; |
828 | mask_c.green = 0; |
824 | mask_c.blue = 0; |
829 | mask_c.blue = 0; |
825 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
830 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
826 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
831 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
827 | } |
|
|
828 | |
832 | |
829 | XRenderFreePicture (dpy, src); |
833 | XRenderFreePicture (dpy, src); |
830 | XRenderFreePicture (dpy, dst); |
834 | XRenderFreePicture (dpy, dst); |
831 | XRenderFreePicture (dpy, mask); |
835 | XRenderFreePicture (dpy, mask); |
832 | |
|
|
833 | XFreePixmap (dpy, root_pmap); |
|
|
834 | } |
836 | } |
835 | #endif |
837 | #endif |
836 | |
838 | |
837 | if (result != pixbuf) |
|
|
838 | g_object_unref (result); |
|
|
839 | |
|
|
840 | XFreeGC (dpy, gc); |
839 | XFreeGC (dpy, gc); |
841 | |
840 | |
842 | ret = true; |
841 | ret = true; |
843 | } |
842 | } |
|
|
843 | |
|
|
844 | if (result != pixbuf) |
|
|
845 | g_object_unref (result); |
|
|
846 | |
|
|
847 | if (tr_flags) |
|
|
848 | XFreePixmap (dpy, root_pmap); |
844 | |
849 | |
845 | return ret; |
850 | return ret; |
846 | } |
851 | } |
847 | # endif /* HAVE_PIXBUF */ |
852 | # endif /* HAVE_PIXBUF */ |
848 | |
853 | |
… | |
… | |
868 | if (image) |
873 | if (image) |
869 | { |
874 | { |
870 | if (original_asim) |
875 | if (original_asim) |
871 | safe_asimage_destroy (original_asim); |
876 | safe_asimage_destroy (original_asim); |
872 | original_asim = image; |
877 | original_asim = image; |
873 | bg_flags |= CLIENT_RENDER; |
878 | bg_flags |= BG_IS_FROM_FILE | BG_CLIENT_RENDER; |
874 | have_image = true; |
|
|
875 | return true; |
879 | return true; |
876 | } |
880 | } |
877 | # endif |
881 | # endif |
878 | |
882 | |
879 | # ifdef HAVE_PIXBUF |
883 | # ifdef HAVE_PIXBUF |
… | |
… | |
881 | if (image) |
885 | if (image) |
882 | { |
886 | { |
883 | if (pixbuf) |
887 | if (pixbuf) |
884 | g_object_unref (pixbuf); |
888 | g_object_unref (pixbuf); |
885 | pixbuf = image; |
889 | pixbuf = image; |
886 | have_image = true; |
890 | bg_flags |= BG_IS_FROM_FILE; |
887 | return true; |
891 | return true; |
888 | } |
892 | } |
889 | # endif |
893 | # endif |
890 | |
894 | |
891 | return false; |
895 | return false; |
… | |
… | |
895 | |
899 | |
896 | # ifdef ENABLE_TRANSPARENCY |
900 | # ifdef ENABLE_TRANSPARENCY |
897 | bool |
901 | bool |
898 | rxvt_term::bg_set_transparent () |
902 | rxvt_term::bg_set_transparent () |
899 | { |
903 | { |
900 | if (!(bg_flags & isTransparent)) |
904 | if (!(bg_flags & BG_IS_TRANSPARENT)) |
901 | { |
905 | { |
902 | bg_flags |= isTransparent; |
906 | bg_flags |= BG_IS_TRANSPARENT; |
903 | return true; |
907 | return true; |
904 | } |
908 | } |
905 | |
909 | |
906 | return false; |
910 | return false; |
907 | } |
911 | } |
… | |
… | |
933 | changed = true; |
937 | changed = true; |
934 | v_blurRadius = vr; |
938 | v_blurRadius = vr; |
935 | } |
939 | } |
936 | |
940 | |
937 | if (v_blurRadius == 0 && h_blurRadius == 0) |
941 | if (v_blurRadius == 0 && h_blurRadius == 0) |
938 | bg_flags &= ~blurNeeded; |
942 | bg_flags &= ~BG_NEEDS_BLUR; |
939 | else |
943 | else |
940 | bg_flags |= blurNeeded; |
944 | bg_flags |= BG_NEEDS_BLUR; |
941 | |
945 | |
942 | return changed; |
946 | return changed; |
943 | } |
947 | } |
944 | |
948 | |
945 | static inline unsigned long |
949 | void |
946 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
950 | rxvt_term::set_tint_shade_flags () |
947 | { |
951 | { |
948 | unsigned long flags = 0; |
|
|
949 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
952 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
950 | bool has_shade = shade != 100; |
953 | bool has_shade = shade != 100; |
951 | |
954 | |
952 | if (tint) |
955 | bg_flags &= ~BG_TINT_FLAGS; |
|
|
956 | |
|
|
957 | if (bg_flags & BG_TINT_SET) |
953 | { |
958 | { |
954 | tint->get (c); |
959 | tint.get (c); |
955 | if (!has_shade |
960 | if (!has_shade |
956 | && (c.r <= 0x00ff || c.r >= 0xff00) |
961 | && (c.r <= 0x00ff || c.r >= 0xff00) |
957 | && (c.g <= 0x00ff || c.g >= 0xff00) |
962 | && (c.g <= 0x00ff || c.g >= 0xff00) |
958 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
963 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
959 | flags |= rxvt_term::tintWholesome; |
964 | bg_flags |= BG_TINT_BITAND; |
960 | } |
965 | } |
961 | |
966 | |
962 | if (has_shade || tint) |
967 | if (has_shade || (bg_flags & BG_TINT_SET)) |
963 | flags |= rxvt_term::tintNeeded; |
968 | bg_flags |= BG_NEEDS_TINT; |
964 | |
|
|
965 | return flags; |
|
|
966 | } |
969 | } |
967 | |
970 | |
968 | bool |
971 | bool |
969 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
972 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
970 | { |
973 | { |
971 | if (!(bg_flags & tintSet) || tint != new_tint) |
974 | if (!(bg_flags & BG_TINT_SET) || tint != new_tint) |
972 | { |
975 | { |
973 | unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); |
|
|
974 | tint = new_tint; |
976 | tint = new_tint; |
975 | bg_flags = (bg_flags & ~tintFlags) | new_flags | tintSet; |
977 | bg_flags |= BG_TINT_SET; |
|
|
978 | set_tint_shade_flags (); |
976 | return true; |
979 | return true; |
977 | } |
980 | } |
978 | |
981 | |
979 | return false; |
982 | return false; |
980 | } |
983 | } |
… | |
… | |
988 | if (new_shade < 0) |
991 | if (new_shade < 0) |
989 | new_shade = 200 - (100 + new_shade); |
992 | new_shade = 200 - (100 + new_shade); |
990 | |
993 | |
991 | if (new_shade != shade) |
994 | if (new_shade != shade) |
992 | { |
995 | { |
993 | unsigned long new_flags = compute_tint_shade_flags ((bg_flags & tintSet) ? &tint : NULL, new_shade); |
|
|
994 | shade = new_shade; |
996 | shade = new_shade; |
995 | bg_flags = (bg_flags & ~tintFlags) | new_flags; |
997 | set_tint_shade_flags (); |
996 | return true; |
998 | return true; |
997 | } |
999 | } |
998 | |
1000 | |
999 | return false; |
1001 | return false; |
1000 | } |
1002 | } |
… | |
… | |
1035 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1037 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1036 | |
1038 | |
1037 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1039 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1038 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1040 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1039 | |
1041 | |
1040 | if (kernel && params && src && dst) |
1042 | if (kernel && params) |
1041 | { |
1043 | { |
1042 | if (h_blurRadius) |
1044 | if (h_blurRadius) |
1043 | { |
1045 | { |
1044 | size = h_blurRadius * 2 + 1; |
1046 | size = h_blurRadius * 2 + 1; |
1045 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
1047 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
… | |
… | |
1088 | bool |
1090 | bool |
1089 | rxvt_term::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1091 | rxvt_term::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1090 | { |
1092 | { |
1091 | bool ret = false; |
1093 | bool ret = false; |
1092 | |
1094 | |
1093 | if (bg_flags & tintWholesome) |
1095 | if (bg_flags & BG_TINT_BITAND) |
1094 | { |
1096 | { |
1095 | XGCValues gcv; |
1097 | XGCValues gcv; |
1096 | GC gc; |
1098 | GC gc; |
1097 | |
1099 | |
1098 | /* In this case we can tint image server-side getting significant |
1100 | /* In this case we can tint image server-side getting significant |
… | |
… | |
1110 | } |
1112 | } |
1111 | } |
1113 | } |
1112 | else |
1114 | else |
1113 | { |
1115 | { |
1114 | # if XRENDER |
1116 | # if XRENDER |
1115 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1117 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1116 | |
1118 | |
1117 | if (bg_flags & tintSet) |
1119 | if (bg_flags & BG_TINT_SET) |
1118 | tint.get (c); |
1120 | tint.get (c); |
1119 | |
1121 | |
1120 | if (shade <= 100) |
1122 | if (shade <= 100) |
1121 | { |
1123 | { |
1122 | c.r = (c.r * shade) / 100; |
1124 | c.r = c.r * shade / 100; |
1123 | c.g = (c.g * shade) / 100; |
1125 | c.g = c.g * shade / 100; |
1124 | c.b = (c.b * shade) / 100; |
1126 | c.b = c.b * shade / 100; |
1125 | } |
1127 | } |
1126 | else |
1128 | else |
1127 | { |
1129 | { |
1128 | c.r = (c.r * (200 - shade)) / 100; |
1130 | c.r = c.r * (200 - shade) / 100; |
1129 | c.g = (c.g * (200 - shade)) / 100; |
1131 | c.g = c.g * (200 - shade) / 100; |
1130 | c.b = (c.b * (200 - shade)) / 100; |
1132 | c.b = c.b * (200 - shade) / 100; |
1131 | } |
1133 | } |
1132 | |
1134 | |
1133 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
1135 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
1134 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1136 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1135 | XRenderPictureAttributes pa; |
1137 | XRenderPictureAttributes pa; |
… | |
… | |
1142 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
1144 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
1143 | XFreePixmap (dpy, overlay_pmap); |
1145 | XFreePixmap (dpy, overlay_pmap); |
1144 | |
1146 | |
1145 | pa.component_alpha = True; |
1147 | pa.component_alpha = True; |
1146 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1148 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1147 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
1149 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa); |
1148 | XFreePixmap (dpy, mask_pmap); |
1150 | XFreePixmap (dpy, mask_pmap); |
1149 | |
1151 | |
1150 | if (mask_pic && overlay_pic && back_pic) |
|
|
1151 | { |
|
|
1152 | XRenderColor mask_c; |
1152 | XRenderColor mask_c; |
1153 | |
1153 | |
1154 | mask_c.red = mask_c.green = mask_c.blue = 0; |
|
|
1155 | mask_c.alpha = 0xffff; |
1154 | mask_c.alpha = 0xffff; |
|
|
1155 | mask_c.red = |
|
|
1156 | mask_c.green = |
|
|
1157 | mask_c.blue = 0; |
|
|
1158 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1159 | |
|
|
1160 | mask_c.alpha = 0; |
|
|
1161 | mask_c.red = 0xffff - c.r; |
|
|
1162 | mask_c.green = 0xffff - c.g; |
|
|
1163 | mask_c.blue = 0xffff - c.b; |
|
|
1164 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1165 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
|
|
1166 | |
|
|
1167 | if (shade > 100) |
|
|
1168 | { |
|
|
1169 | mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; |
|
|
1170 | mask_c.alpha = 0; |
1156 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1171 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1157 | |
1172 | |
1158 | mask_c.alpha = 0; |
|
|
1159 | mask_c.red = 0xffff - c.r; |
|
|
1160 | mask_c.green = 0xffff - c.g; |
|
|
1161 | mask_c.blue = 0xffff - c.b; |
|
|
1162 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1163 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
|
|
1164 | |
|
|
1165 | if (shade > 100) |
|
|
1166 | { |
|
|
1167 | mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; |
|
|
1168 | mask_c.alpha = 0; |
|
|
1169 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1170 | |
|
|
1171 | XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1173 | XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1172 | } |
1174 | } |
1173 | |
1175 | |
1174 | ret = true; |
1176 | ret = true; |
1175 | } |
|
|
1176 | |
1177 | |
1177 | XRenderFreePicture (dpy, mask_pic); |
1178 | XRenderFreePicture (dpy, mask_pic); |
1178 | XRenderFreePicture (dpy, overlay_pic); |
1179 | XRenderFreePicture (dpy, overlay_pic); |
1179 | XRenderFreePicture (dpy, back_pic); |
1180 | XRenderFreePicture (dpy, back_pic); |
1180 | # endif |
1181 | # endif |
1181 | } |
1182 | } |
1182 | |
1183 | |
1183 | return ret; |
1184 | return ret; |
1184 | } |
1185 | } |
1185 | |
1186 | |
1186 | /* make_transparency_pixmap() |
1187 | /* |
1187 | * Builds a pixmap of the same size as the terminal window that contains |
1188 | * Builds a pixmap of the same size as the terminal window that contains |
1188 | * the tiled portion of the root pixmap that is supposed to be covered by |
1189 | * the tiled portion of the root pixmap that is supposed to be covered by |
1189 | * our window. |
1190 | * our window. |
1190 | */ |
1191 | */ |
1191 | unsigned long |
1192 | unsigned long |
… | |
… | |
1233 | Pixmap recoded_root_pmap = root_pixmap; |
1234 | Pixmap recoded_root_pmap = root_pixmap; |
1234 | |
1235 | |
1235 | if (root_pixmap != None && root_depth != depth) |
1236 | if (root_pixmap != None && root_depth != depth) |
1236 | { |
1237 | { |
1237 | #if XRENDER |
1238 | #if XRENDER |
1238 | if (bg_flags & HAS_RENDER) |
1239 | if (bg_flags & BG_HAS_RENDER) |
1239 | { |
1240 | { |
|
|
1241 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
|
|
1242 | |
1240 | XRenderPictureAttributes pa; |
1243 | XRenderPictureAttributes pa; |
1241 | |
1244 | |
1242 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1245 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1243 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1246 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1244 | |
1247 | |
1245 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
|
|
1246 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1248 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1247 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1249 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1248 | |
1250 | |
1249 | if (src && dst) |
|
|
1250 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1251 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1251 | else |
|
|
1252 | { |
|
|
1253 | XFreePixmap (dpy, recoded_root_pmap); |
|
|
1254 | root_pixmap = None; |
|
|
1255 | } |
|
|
1256 | |
1252 | |
1257 | XRenderFreePicture (dpy, src); |
1253 | XRenderFreePicture (dpy, src); |
1258 | XRenderFreePicture (dpy, dst); |
1254 | XRenderFreePicture (dpy, dst); |
1259 | } |
1255 | } |
1260 | else |
1256 | else |
1261 | #endif |
1257 | #endif |
1262 | root_pixmap = None; |
1258 | recoded_root_pmap = None; |
1263 | } |
1259 | } |
1264 | |
1260 | |
1265 | if (root_pixmap == None) |
1261 | if (recoded_root_pmap == None) |
1266 | return 0; |
1262 | return 0; |
1267 | |
1263 | |
1268 | if (bg_pixmap == None |
1264 | if (bg_pixmap == None |
1269 | || bg_pmap_width != window_width |
1265 | || bg_pmap_width != window_width |
1270 | || bg_pmap_height != window_height) |
1266 | || bg_pmap_height != window_height) |
… | |
… | |
1274 | bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); |
1270 | bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); |
1275 | bg_pmap_width = window_width; |
1271 | bg_pmap_width = window_width; |
1276 | bg_pmap_height = window_height; |
1272 | bg_pmap_height = window_height; |
1277 | } |
1273 | } |
1278 | |
1274 | |
1279 | if (bg_pixmap == None) |
|
|
1280 | return 0; |
|
|
1281 | |
|
|
1282 | /* straightforward pixmap copy */ |
1275 | /* straightforward pixmap copy */ |
1283 | while (sx < 0) sx += (int)root_width; |
1276 | while (sx < 0) sx += root_width; |
1284 | while (sy < 0) sy += (int)root_height; |
1277 | while (sy < 0) sy += root_height; |
1285 | |
1278 | |
1286 | gcv.tile = recoded_root_pmap; |
1279 | gcv.tile = recoded_root_pmap; |
1287 | gcv.fill_style = FillTiled; |
1280 | gcv.fill_style = FillTiled; |
1288 | gcv.ts_x_origin = -sx; |
1281 | gcv.ts_x_origin = -sx; |
1289 | gcv.ts_y_origin = -sy; |
1282 | gcv.ts_y_origin = -sy; |
1290 | gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1283 | gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1291 | |
1284 | |
1292 | if (gc) |
1285 | if (gc) |
1293 | { |
1286 | { |
1294 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1287 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1295 | result |= isValid | (bg_flags & effectsFlags); |
1288 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1296 | XFreeGC (dpy, gc); |
1289 | XFreeGC (dpy, gc); |
1297 | |
1290 | |
1298 | if (!(bg_flags & CLIENT_RENDER)) |
1291 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1299 | { |
1292 | { |
1300 | if ((bg_flags & blurNeeded) |
1293 | if ((bg_flags & BG_NEEDS_BLUR) |
1301 | && (bg_flags & HAS_RENDER_CONV)) |
1294 | && (bg_flags & BG_HAS_RENDER_CONV)) |
1302 | { |
1295 | { |
1303 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1296 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1304 | result &= ~blurNeeded; |
1297 | result &= ~BG_NEEDS_BLUR; |
1305 | } |
1298 | } |
1306 | if ((bg_flags & tintNeeded) |
1299 | if ((bg_flags & BG_NEEDS_TINT) |
1307 | && (bg_flags & (tintWholesome | HAS_RENDER))) |
1300 | && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) |
1308 | { |
1301 | { |
1309 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1302 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1310 | result &= ~tintNeeded; |
1303 | result &= ~BG_NEEDS_TINT; |
1311 | } |
1304 | } |
1312 | } /* server side rendering completed */ |
1305 | } /* server side rendering completed */ |
1313 | } |
1306 | } |
1314 | |
1307 | |
1315 | if (recoded_root_pmap != root_pixmap) |
1308 | if (recoded_root_pmap != root_pixmap) |
… | |
… | |
1338 | { |
1331 | { |
1339 | unsigned long tr_flags = 0; |
1332 | unsigned long tr_flags = 0; |
1340 | |
1333 | |
1341 | bg_invalidate (); |
1334 | bg_invalidate (); |
1342 | # ifdef ENABLE_TRANSPARENCY |
1335 | # ifdef ENABLE_TRANSPARENCY |
1343 | if (bg_flags & isTransparent) |
1336 | if (bg_flags & BG_IS_TRANSPARENT) |
1344 | { |
1337 | { |
1345 | /* we need to re-generate transparency pixmap in that case ! */ |
1338 | /* we need to re-generate transparency pixmap in that case ! */ |
1346 | tr_flags = make_transparency_pixmap (); |
1339 | tr_flags = make_transparency_pixmap (); |
1347 | if (tr_flags == 0) |
1340 | if (tr_flags == 0) |
1348 | return false; |
1341 | return false; |
1349 | else if (!(tr_flags & effectsFlags)) |
1342 | else if (!(tr_flags & BG_EFFECTS_FLAGS)) |
1350 | bg_flags |= isValid; |
1343 | bg_flags |= BG_IS_VALID; |
1351 | } |
1344 | } |
1352 | # endif |
1345 | # endif |
1353 | |
1346 | |
1354 | # ifdef BG_IMAGE_FROM_FILE |
1347 | # ifdef BG_IMAGE_FROM_FILE |
1355 | if (have_image |
1348 | if ((bg_flags & BG_IS_FROM_FILE) |
1356 | || (tr_flags & effectsFlags)) |
1349 | || (tr_flags & BG_EFFECTS_FLAGS)) |
1357 | { |
1350 | { |
1358 | if (render_image (tr_flags)) |
1351 | if (render_image (tr_flags)) |
1359 | bg_flags |= isValid; |
1352 | bg_flags |= BG_IS_VALID; |
1360 | } |
1353 | } |
1361 | # endif |
1354 | # endif |
1362 | |
1355 | |
1363 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1356 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1364 | XImage *result = NULL; |
1357 | XImage *result = NULL; |
1365 | |
1358 | |
1366 | if (tr_flags && !(bg_flags & isValid)) |
1359 | if (tr_flags && !(bg_flags & BG_IS_VALID)) |
1367 | { |
1360 | { |
1368 | result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
1361 | result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
1369 | } |
1362 | } |
1370 | |
1363 | |
1371 | if (result) |
1364 | if (result) |
1372 | { |
1365 | { |
1373 | /* our own client-side tinting */ |
1366 | /* our own client-side tinting */ |
1374 | if (tr_flags & tintNeeded) |
1367 | if (tr_flags & BG_NEEDS_TINT) |
1375 | { |
1368 | { |
1376 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1369 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1377 | if (bg_flags & tintSet) |
1370 | if (bg_flags & BG_TINT_SET) |
1378 | tint.get (c); |
1371 | tint.get (c); |
1379 | shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); |
1372 | shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); |
1380 | } |
1373 | } |
1381 | |
1374 | |
1382 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
1375 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
… | |
… | |
1384 | if (gc) |
1377 | if (gc) |
1385 | { |
1378 | { |
1386 | XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1379 | XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1387 | |
1380 | |
1388 | XFreeGC (dpy, gc); |
1381 | XFreeGC (dpy, gc); |
1389 | bg_flags |= isValid; |
1382 | bg_flags |= BG_IS_VALID; |
1390 | } |
1383 | } |
1391 | |
1384 | |
1392 | XDestroyImage (result); |
1385 | XDestroyImage (result); |
1393 | } |
1386 | } |
1394 | # endif |
1387 | # endif |
1395 | |
1388 | |
1396 | if (!(bg_flags & isValid)) |
1389 | if (!(bg_flags & BG_IS_VALID)) |
1397 | { |
1390 | { |
1398 | if (bg_pixmap != None) |
1391 | if (bg_pixmap != None) |
1399 | { |
1392 | { |
1400 | XFreePixmap (dpy, bg_pixmap); |
1393 | XFreePixmap (dpy, bg_pixmap); |
1401 | bg_pixmap = None; |
1394 | bg_pixmap = None; |
1402 | } |
1395 | } |
1403 | } |
1396 | } |
1404 | |
1397 | |
1405 | scr_recolour (false); |
1398 | scr_recolour (false); |
1406 | bg_flags |= hasChanged; |
1399 | bg_flags |= BG_NEEDS_REFRESH; |
1407 | |
1400 | |
1408 | bg_valid_since = ev::now (); |
1401 | bg_valid_since = ev::now (); |
1409 | |
1402 | |
1410 | return true; |
1403 | return true; |
1411 | } |
1404 | } |
… | |
… | |
1415 | { |
1408 | { |
1416 | #ifdef ENABLE_TRANSPARENCY |
1409 | #ifdef ENABLE_TRANSPARENCY |
1417 | shade = 100; |
1410 | shade = 100; |
1418 | #endif |
1411 | #endif |
1419 | |
1412 | |
1420 | bg_flags &= ~(HAS_RENDER | HAS_RENDER_CONV); |
1413 | bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); |
1421 | #if XRENDER |
1414 | #if XRENDER |
1422 | int major, minor; |
1415 | int major, minor; |
1423 | if (XRenderQueryVersion (dpy, &major, &minor)) |
1416 | if (XRenderQueryVersion (dpy, &major, &minor)) |
1424 | bg_flags |= HAS_RENDER; |
1417 | bg_flags |= BG_HAS_RENDER; |
1425 | XFilters *filters = XRenderQueryFilters (dpy, vt); |
1418 | XFilters *filters = XRenderQueryFilters (dpy, vt); |
1426 | if (filters) |
1419 | if (filters) |
1427 | { |
1420 | { |
1428 | for (int i = 0; i < filters->nfilter; i++) |
1421 | for (int i = 0; i < filters->nfilter; i++) |
1429 | if (!strcmp (filters->filter[i], FilterConvolution)) |
1422 | if (!strcmp (filters->filter[i], FilterConvolution)) |
1430 | bg_flags |= HAS_RENDER_CONV; |
1423 | bg_flags |= BG_HAS_RENDER_CONV; |
1431 | |
1424 | |
1432 | XFree (filters); |
1425 | XFree (filters); |
1433 | } |
1426 | } |
1434 | #endif |
1427 | #endif |
1435 | } |
1428 | } |