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) 1997 Carsten Haitzler <raster@zip.com.au> |
|
|
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
|
|
8 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
|
|
9 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
10 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
7 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
11 | * |
8 | * |
12 | * This program is free software; you can redistribute it and/or modify |
9 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by |
10 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
28 | #include "rxvt.h" /* NECESSARY */ |
25 | #include "rxvt.h" /* NECESSARY */ |
29 | |
26 | |
30 | #define DO_TIMING_TEST 0 |
27 | #define DO_TIMING_TEST 0 |
31 | |
28 | |
32 | #if DO_TIMING_TEST |
29 | #if DO_TIMING_TEST |
|
|
30 | # include <sys/time.h> |
33 | #define TIMING_TEST_START(id) \ |
31 | #define TIMING_TEST_START(id) \ |
34 | struct timeval timing_test_##id##_stv;\ |
32 | struct timeval timing_test_##id##_stv;\ |
35 | gettimeofday (&timing_test_##id##_stv, NULL); |
33 | gettimeofday (&timing_test_##id##_stv, NULL); |
36 | |
34 | |
37 | #define TIMING_TEST_PRINT_RESULT(id) \ |
35 | #define TIMING_TEST_PRINT_RESULT(id) \ |
… | |
… | |
87 | * scale Scale both up and down |
85 | * scale Scale both up and down |
88 | * auto Same as 100x100+50+50 |
86 | * auto Same as 100x100+50+50 |
89 | */ |
87 | */ |
90 | |
88 | |
91 | #ifdef HAVE_BG_PIXMAP |
89 | #ifdef HAVE_BG_PIXMAP |
92 | bgPixmap_t::bgPixmap_t() |
90 | bgPixmap_t::bgPixmap_t () |
93 | { |
91 | { |
94 | #ifdef HAVE_AFTERIMAGE |
92 | #ifdef HAVE_AFTERIMAGE |
95 | original_asim = NULL; |
93 | original_asim = NULL; |
96 | #endif |
94 | #endif |
97 | #ifdef BG_IMAGE_FROM_FILE |
95 | #ifdef BG_IMAGE_FROM_FILE |
… | |
… | |
100 | #endif |
98 | #endif |
101 | flags = 0; |
99 | flags = 0; |
102 | pixmap = None; |
100 | pixmap = None; |
103 | } |
101 | } |
104 | |
102 | |
105 | bgPixmap_t::~bgPixmap_t() |
103 | void |
|
|
104 | bgPixmap_t::destroy () |
106 | { |
105 | { |
107 | #ifdef HAVE_AFTERIMAGE |
106 | #ifdef HAVE_AFTERIMAGE |
108 | if (original_asim) |
107 | if (original_asim) |
109 | safe_asimage_destroy (original_asim); |
108 | safe_asimage_destroy (original_asim); |
110 | #endif |
109 | #endif |
|
|
110 | |
111 | if (pixmap && target) |
111 | if (pixmap && target) |
112 | XFreePixmap (target->dpy, pixmap); |
112 | XFreePixmap (target->dpy, pixmap); |
113 | } |
113 | } |
114 | |
114 | |
115 | bool |
115 | bool |
… | |
… | |
303 | y = x; |
303 | y = x; |
304 | geom_flags |= YValue; |
304 | geom_flags |= YValue; |
305 | } |
305 | } |
306 | |
306 | |
307 | if (flags & geometrySet) |
307 | if (flags & geometrySet) |
|
|
308 | { |
308 | {/* new geometry is an adjustment to the old one ! */ |
309 | /* new geometry is an adjustment to the old one ! */ |
309 | if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) |
310 | if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) |
310 | { |
311 | { |
311 | if (w == 0 && h != 0) |
312 | if (w == 0 && h != 0) |
312 | { |
313 | { |
313 | w = h_scale; |
314 | w = h_scale; |
… | |
… | |
329 | } |
330 | } |
330 | } |
331 | } |
331 | else /* setting up geometry from scratch */ |
332 | else /* setting up geometry from scratch */ |
332 | { |
333 | { |
333 | if (!(geom_flags & XValue)) |
334 | if (!(geom_flags & XValue)) |
|
|
335 | { |
334 | {/* use default geometry - centered */ |
336 | /* use default geometry - centered */ |
335 | x = y = defaultAlign; |
337 | x = y = defaultAlign; |
336 | } |
338 | } |
337 | else if (!(geom_flags & YValue)) |
339 | else if (!(geom_flags & YValue)) |
338 | y = x; |
340 | y = x; |
339 | |
341 | |
340 | if ((geom_flags & (WidthValue|HeightValue)) == 0) |
342 | if ((geom_flags & (WidthValue|HeightValue)) == 0) |
|
|
343 | { |
341 | {/* use default geometry - scaled */ |
344 | /* use default geometry - scaled */ |
342 | w = h = defaultScale; |
345 | w = h = defaultScale; |
343 | } |
346 | } |
344 | else if (geom_flags & WidthValue) |
347 | else if (geom_flags & WidthValue) |
345 | { |
348 | { |
346 | if (!(geom_flags & HeightValue)) |
349 | if (!(geom_flags & HeightValue)) |
… | |
… | |
349 | else |
352 | else |
350 | w = h; |
353 | w = h; |
351 | } |
354 | } |
352 | } /* done parsing geometry string */ |
355 | } /* done parsing geometry string */ |
353 | else if (!(flags & geometrySet)) |
356 | else if (!(flags & geometrySet)) |
|
|
357 | { |
354 | { /* default geometry - scaled and centered */ |
358 | /* default geometry - scaled and centered */ |
355 | x = y = defaultAlign; |
359 | x = y = defaultAlign; |
356 | w = h = defaultScale; |
360 | w = h = defaultScale; |
357 | } |
361 | } |
358 | |
362 | |
359 | if (!(flags & geometrySet)) |
363 | if (!(flags & geometrySet)) |
… | |
… | |
431 | if (new_flags != flags) |
435 | if (new_flags != flags) |
432 | { |
436 | { |
433 | flags = new_flags; |
437 | flags = new_flags; |
434 | changed++; |
438 | changed++; |
435 | } |
439 | } |
436 | //fprintf( stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
440 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
437 | // flags, h_scale, v_scale, h_align, v_align); |
441 | // flags, h_scale, v_scale, h_align, v_align); |
438 | return (changed > 0); |
442 | return (changed > 0); |
439 | } |
443 | } |
440 | |
444 | |
441 | # ifdef HAVE_AFTERIMAGE |
445 | # ifdef HAVE_AFTERIMAGE |
… | |
… | |
505 | h > 0 ? h : original_asim->height, |
509 | h > 0 ? h : original_asim->height, |
506 | background ? ASA_ASImage : ASA_XImage, |
510 | background ? ASA_ASImage : ASA_XImage, |
507 | 100, ASIMAGE_QUALITY_DEFAULT); |
511 | 100, ASIMAGE_QUALITY_DEFAULT); |
508 | } |
512 | } |
509 | if (background == NULL) |
513 | if (background == NULL) |
|
|
514 | { |
510 | {/* if tiling - pixmap has to be sized exactly as the image, |
515 | /* if tiling - pixmap has to be sized exactly as the image, |
511 | but there is no need to make it bigger then the window! */ |
516 | but there is no need to make it bigger then the window! */ |
512 | if (h_scale == 0) |
517 | if (h_scale == 0) |
513 | new_pmap_width = min (result->width, target_width); |
518 | new_pmap_width = min (result->width, target_width); |
514 | if (v_scale == 0) |
519 | if (v_scale == 0) |
515 | new_pmap_height = min (result->height, target_height); |
520 | new_pmap_height = min (result->height, target_height); |
516 | /* we also need to tile our image in one or both directions */ |
521 | /* we also need to tile our image in one or both directions */ |
… | |
… | |
530 | result = tmp; |
535 | result = tmp; |
531 | } |
536 | } |
532 | } |
537 | } |
533 | } |
538 | } |
534 | else |
539 | else |
|
|
540 | { |
535 | {/* if blending background and image - pixmap has to be sized same as target window */ |
541 | /* if blending background and image - pixmap has to be sized same as target window */ |
536 | ASImageLayer *layers = create_image_layers (2); |
542 | ASImageLayer *layers = create_image_layers (2); |
537 | ASImage *merged_im = NULL; |
543 | ASImage *merged_im = NULL; |
538 | |
544 | |
539 | layers[0].im = background; |
545 | layers[0].im = background; |
540 | layers[0].clip_width = target_width; |
546 | layers[0].clip_width = target_width; |
541 | layers[0].clip_height = target_height; |
547 | layers[0].clip_height = target_height; |
542 | layers[0].tint = background_tint; |
548 | layers[0].tint = background_tint; |
543 | layers[1].im = result; |
549 | layers[1].im = result; |
544 | if (w <= 0) |
550 | if (w <= 0) |
|
|
551 | { |
545 | {/* tile horizontally */ |
552 | /* tile horizontally */ |
546 | while (x > 0) x -= (int)result->width; |
553 | while (x > 0) x -= (int)result->width; |
547 | layers[1].dst_x = x; |
554 | layers[1].dst_x = x; |
548 | layers[1].clip_width = result->width+target_width; |
555 | layers[1].clip_width = result->width+target_width; |
549 | } |
556 | } |
550 | else |
557 | else |
|
|
558 | { |
551 | {/* clip horizontally */ |
559 | /* clip horizontally */ |
552 | layers[1].dst_x = x; |
560 | layers[1].dst_x = x; |
553 | layers[1].clip_width = result->width; |
561 | layers[1].clip_width = result->width; |
554 | } |
562 | } |
555 | if (h <= 0) |
563 | if (h <= 0) |
556 | { |
564 | { |
… | |
… | |
771 | unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); |
779 | unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); |
772 | tint = new_tint; |
780 | tint = new_tint; |
773 | flags = (flags & ~tintFlags) | new_flags | tintSet; |
781 | flags = (flags & ~tintFlags) | new_flags | tintSet; |
774 | return true; |
782 | return true; |
775 | } |
783 | } |
|
|
784 | |
776 | return false; |
785 | return false; |
777 | } |
786 | } |
778 | |
787 | |
779 | bool |
788 | bool |
780 | bgPixmap_t::unset_tint () |
789 | bgPixmap_t::unset_tint () |
… | |
… | |
784 | if (new_flags != (flags & tintFlags)) |
793 | if (new_flags != (flags & tintFlags)) |
785 | { |
794 | { |
786 | flags = (flags&~tintFlags)|new_flags; |
795 | flags = (flags&~tintFlags)|new_flags; |
787 | return true; |
796 | return true; |
788 | } |
797 | } |
|
|
798 | |
789 | return false; |
799 | return false; |
790 | } |
800 | } |
791 | |
801 | |
792 | bool |
802 | bool |
793 | bgPixmap_t::set_shade (const char *shade_str) |
803 | bgPixmap_t::set_shade (const char *shade_str) |
794 | { |
804 | { |
795 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
805 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
796 | |
806 | |
797 | if (new_shade < 0 && new_shade > -100) |
807 | if (new_shade < 0 && new_shade > -100) |
798 | new_shade = 200 - (100 + new_shade); |
808 | new_shade = 200 - (100 + new_shade); |
799 | else if (new_shade == 100) |
809 | else if (new_shade == 100) |
800 | new_shade = 0; |
810 | new_shade = 0; |
801 | |
811 | |
802 | if (new_shade != shade) |
812 | if (new_shade != shade) |
803 | { |
813 | { |
804 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
814 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
805 | shade = new_shade; |
815 | shade = new_shade; |
806 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
816 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
807 | return true; |
817 | return true; |
808 | } |
818 | } |
|
|
819 | |
809 | return false; |
820 | return false; |
810 | } |
821 | } |
811 | |
822 | |
812 | /* make_transparency_pixmap() |
823 | /* make_transparency_pixmap() |
813 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
824 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
… | |
… | |
843 | if (sx + window_width <= 0 || sy + window_height <= 0 |
854 | if (sx + window_width <= 0 || sy + window_height <= 0 |
844 | || sx >= root_width || sy >= root_height) |
855 | || sx >= root_width || sy >= root_height) |
845 | return 0; |
856 | return 0; |
846 | |
857 | |
847 | if (root_pixmap != None) |
858 | if (root_pixmap != None) |
|
|
859 | { |
848 | {/* we want to validate the pixmap and get it's size at the same time : */ |
860 | /* we want to validate the pixmap and get it's size at the same time : */ |
849 | int junk; |
861 | int junk; |
850 | unsigned int ujunk; |
862 | unsigned int ujunk; |
851 | /* root pixmap may be bad - allow a error */ |
863 | /* root pixmap may be bad - allow a error */ |
852 | target->allowedxerror = -1; |
864 | target->allowedxerror = -1; |
853 | |
865 | |
… | |
… | |
862 | |
874 | |
863 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
875 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
864 | return 0; |
876 | return 0; |
865 | |
877 | |
866 | if (root_pixmap == None) |
878 | if (root_pixmap == None) |
|
|
879 | { |
867 | { /* use tricks to obtain the root background image :*/ |
880 | /* use tricks to obtain the root background image :*/ |
868 | /* we want to create Overrideredirect window overlapping out window |
881 | /* we want to create Overrideredirect window overlapping out window |
869 | with background type of Parent Relative and then grab it */ |
882 | with background type of Parent Relative and then grab it */ |
870 | XSetWindowAttributes attr; |
883 | XSetWindowAttributes attr; |
871 | Window src; |
884 | Window src; |
872 | bool success = false; |
885 | bool success = false; |
… | |
… | |
887 | XGrabServer (dpy); |
900 | XGrabServer (dpy); |
888 | XMapRaised (dpy, src); |
901 | XMapRaised (dpy, src); |
889 | XSync (dpy, False); |
902 | XSync (dpy, False); |
890 | |
903 | |
891 | /* XSync should get window where it's properly exposed, |
904 | /* XSync should get window where it's properly exposed, |
892 | * but to be on the safe side - let's check for the actuall event to arrive : */ |
905 | * but to be on the safe side - let's check for the actual event to arrive : */ |
893 | while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) |
906 | while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) |
894 | ++ev_count; |
907 | ++ev_count; |
895 | |
908 | |
896 | if (ev_count > 0); |
909 | if (ev_count > 0); |
|
|
910 | { |
897 | { /* hooray! - we can grab the image! */ |
911 | /* hooray! - we can grab the image! */ |
898 | gc = XCreateGC (dpy, root, 0, NULL); |
912 | gc = XCreateGC (dpy, root, 0, NULL); |
899 | if (gc) |
913 | if (gc) |
900 | { |
914 | { |
901 | XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0); |
915 | XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0); |
902 | success = true; |
916 | success = true; |
903 | } |
917 | } |
904 | } |
918 | } |
|
|
919 | |
905 | XDestroyWindow (dpy, src); |
920 | XDestroyWindow (dpy, src); |
906 | XUngrabServer (dpy); |
921 | XUngrabServer (dpy); |
907 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
922 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
908 | } |
923 | } |
909 | |
924 | |
… | |
… | |
914 | } |
929 | } |
915 | else |
930 | else |
916 | result |= transpPmapTiled; |
931 | result |= transpPmapTiled; |
917 | } |
932 | } |
918 | else |
933 | else |
|
|
934 | { |
919 | {/* strightforward pixmap copy */ |
935 | /* strightforward pixmap copy */ |
920 | gcv.tile = root_pixmap; |
936 | gcv.tile = root_pixmap; |
921 | gcv.fill_style = FillTiled; |
937 | gcv.fill_style = FillTiled; |
922 | |
938 | |
923 | while (sx < 0) sx += (int)root_width; |
939 | while (sx < 0) sx += (int)root_width; |
924 | while (sy < 0) sy += (int)root_height; |
940 | while (sy < 0) sy += (int)root_height; |
… | |
… | |
972 | { |
988 | { |
973 | c.r = (c.r * shade) / 100; |
989 | c.r = (c.r * shade) / 100; |
974 | c.g = (c.g * shade) / 100; |
990 | c.g = (c.g * shade) / 100; |
975 | c.b = (c.b * shade) / 100; |
991 | c.b = (c.b * shade) / 100; |
976 | } |
992 | } |
977 | else if( shade > 100 && shade < 200) |
993 | else if (shade > 100 && shade < 200) |
978 | { |
994 | { |
979 | c.r = (c.r * (200 - shade)) / 100; |
995 | c.r = (c.r * (200 - shade)) / 100; |
980 | c.g = (c.g * (200 - shade)) / 100; |
996 | c.g = (c.g * (200 - shade)) / 100; |
981 | c.b = (c.b * (200 - shade)) / 100; |
997 | c.b = (c.b * (200 - shade)) / 100; |
982 | } |
998 | } |
… | |
… | |
1028 | mask_c.blue = 0xffff - c.b; |
1044 | mask_c.blue = 0xffff - c.b; |
1029 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
1045 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
1030 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
1046 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
1031 | result |= transpPmapTinted; |
1047 | result |= transpPmapTinted; |
1032 | } |
1048 | } |
|
|
1049 | |
1033 | XRenderFreePicture (dpy, mask_pic); |
1050 | XRenderFreePicture (dpy, mask_pic); |
1034 | XRenderFreePicture (dpy, overlay_pic); |
1051 | XRenderFreePicture (dpy, overlay_pic); |
1035 | XRenderFreePicture (dpy, back_pic); |
1052 | XRenderFreePicture (dpy, back_pic); |
1036 | # if DO_TIMING_TEST |
1053 | # if DO_TIMING_TEST |
1037 | XSync (dpy, False); |
1054 | XSync (dpy, False); |
… | |
… | |
1059 | } |
1076 | } |
1060 | |
1077 | |
1061 | bool |
1078 | bool |
1062 | bgPixmap_t::set_root_pixmap () |
1079 | bgPixmap_t::set_root_pixmap () |
1063 | { |
1080 | { |
1064 | Pixmap new_root_pixmap = None; |
|
|
1065 | |
|
|
1066 | new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1081 | Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1067 | if (new_root_pixmap == None) |
1082 | if (new_root_pixmap == None) |
1068 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1083 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1069 | |
1084 | |
1070 | if (new_root_pixmap != root_pixmap) |
1085 | if (new_root_pixmap != root_pixmap) |
1071 | { |
1086 | { |
1072 | root_pixmap = new_root_pixmap; |
1087 | root_pixmap = new_root_pixmap; |
1073 | return true; |
1088 | return true; |
1074 | } |
1089 | } |
|
|
1090 | |
1075 | return false; |
1091 | return false; |
1076 | } |
1092 | } |
1077 | # endif /* ENABLE_TRANSPARENCY */ |
1093 | # endif /* ENABLE_TRANSPARENCY */ |
1078 | |
1094 | |
1079 | # ifndef HAVE_AFTERIMAGE |
1095 | # ifndef HAVE_AFTERIMAGE |
1080 | static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); |
1096 | static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); |
1081 | # endif |
1097 | # endif |
1082 | |
|
|
1083 | |
1098 | |
1084 | bool |
1099 | bool |
1085 | bgPixmap_t::render () |
1100 | bgPixmap_t::render () |
1086 | { |
1101 | { |
1087 | unsigned long background_flags = 0; |
1102 | unsigned long background_flags = 0; |
… | |
… | |
1169 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1184 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1170 | } |
1185 | } |
1171 | } |
1186 | } |
1172 | # endif /* HAVE_AFTERIMAGE */ |
1187 | # endif /* HAVE_AFTERIMAGE */ |
1173 | |
1188 | |
1174 | if (result != NULL) |
1189 | if (result) |
1175 | { |
1190 | { |
1176 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1191 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
|
|
1192 | |
1177 | if (gc) |
1193 | if (gc) |
1178 | { |
1194 | { |
1179 | if (/*pmap_depth != target->depth &&*/ pixmap != None) |
1195 | if (/*pmap_depth != target->depth &&*/ pixmap != None) |
1180 | { |
1196 | { |
1181 | XFreePixmap (target->dpy, pixmap); |
1197 | XFreePixmap (target->dpy, pixmap); |
1182 | pixmap = None; |
1198 | pixmap = None; |
1183 | } |
1199 | } |
|
|
1200 | |
1184 | if (pixmap == None) |
1201 | if (pixmap == None) |
1185 | { |
1202 | { |
1186 | pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); |
1203 | pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); |
1187 | pmap_width = result->width; |
1204 | pmap_width = result->width; |
1188 | pmap_height = result->height; |
1205 | pmap_height = result->height; |
1189 | pmap_depth = target->depth; |
1206 | pmap_depth = target->depth; |
1190 | } |
1207 | } |
|
|
1208 | |
1191 | if (pmap_depth != result->depth) |
1209 | if (pmap_depth != result->depth) |
|
|
1210 | { |
1192 | { /* Bad Match error will ensue ! stupid X !!!! */ |
1211 | /* Bad Match error will ensue ! stupid X !!!! */ |
1193 | if( result->depth == 24 && pmap_depth == 32) |
1212 | if (result->depth == 24 && pmap_depth == 32) |
1194 | result->depth = 32; |
1213 | result->depth = 32; |
1195 | else if( result->depth == 32 && pmap_depth == 24) |
1214 | else if (result->depth == 32 && pmap_depth == 24) |
1196 | result->depth = 24; |
1215 | result->depth = 24; |
1197 | else |
1216 | else |
1198 | { |
1217 | { |
1199 | /* TODO: implement image recoding */ |
1218 | /* TODO: implement image recoding */ |
1200 | } |
1219 | } |
1201 | } |
1220 | } |
|
|
1221 | |
1202 | if (pmap_depth == result->depth) |
1222 | if (pmap_depth == result->depth) |
1203 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1223 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
|
|
1224 | |
1204 | XFreeGC (target->dpy, gc); |
1225 | XFreeGC (target->dpy, gc); |
1205 | flags = flags & ~isInvalid; |
1226 | flags = flags & ~isInvalid; |
1206 | } |
1227 | } |
|
|
1228 | |
1207 | XDestroyImage (result); |
1229 | XDestroyImage (result); |
1208 | } |
1230 | } |
1209 | |
1231 | |
1210 | if (flags & isInvalid) |
1232 | if (flags & isInvalid) |
1211 | { |
1233 | { |
… | |
… | |
1237 | } |
1259 | } |
1238 | return false; |
1260 | return false; |
1239 | } |
1261 | } |
1240 | |
1262 | |
1241 | void |
1263 | void |
1242 | bgPixmap_t::apply() |
1264 | bgPixmap_t::apply () |
1243 | { |
1265 | { |
1244 | if (target) |
1266 | if (target) |
1245 | { |
1267 | { |
1246 | flags &= ~isVtOrigin; |
1268 | flags &= ~isVtOrigin; |
1247 | if (pixmap != None) |
1269 | if (pixmap != None) |
|
|
1270 | { |
1248 | { /* set target's background to pixmap */ |
1271 | /* set target's background to pixmap */ |
1249 | # ifdef ENABLE_TRANSPARENCY |
1272 | # ifdef ENABLE_TRANSPARENCY |
1250 | if (flags & isTransparent) |
1273 | if (flags & isTransparent) |
1251 | { |
1274 | { |
1252 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
1275 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
1253 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
1276 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
… | |
… | |
1269 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1292 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1270 | # endif |
1293 | # endif |
1271 | } |
1294 | } |
1272 | } |
1295 | } |
1273 | else |
1296 | else |
|
|
1297 | { |
1274 | { /* set target background to a pixel */ |
1298 | /* set target background to a pixel */ |
1275 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1299 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1276 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
1300 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
1277 | /* do we also need to set scrollbar's background here ? */ |
1301 | /* do we also need to set scrollbar's background here ? */ |
1278 | # if HAVE_SCROLLBARS |
1302 | # if HAVE_SCROLLBARS |
1279 | if (target->scrollBar.win) |
1303 | if (target->scrollBar.win) |