ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/background.C
(Generate patch)

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.10 by ayin, Wed Oct 31 09:55:23 2007 UTC vs.
Revision 1.20 by root, Mon Dec 24 06:51:37 2007 UTC

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
92bgPixmap_t::bgPixmap_t() 90bgPixmap_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
103void
104bgPixmap_t::destroy ()
105{
106#ifdef HAVE_AFTERIMAGE
107 if (original_asim)
108 safe_asimage_destroy (original_asim);
109#endif
110
111 if (pixmap && target)
112 XFreePixmap (target->dpy, pixmap);
113}
105 114
106bool 115bool
107bgPixmap_t::window_size_sensitive () 116bgPixmap_t::window_size_sensitive ()
108{ 117{
118# ifdef ENABLE_TRANSPARENCY
119 if (flags & isTransparent)
120 return true;
121# endif
122
109# ifdef BG_IMAGE_FROM_FILE 123# ifdef BG_IMAGE_FROM_FILE
110# ifdef HAVE_AFTERIMAGE 124# ifdef HAVE_AFTERIMAGE
111 if (original_asim != NULL) 125 if (original_asim != NULL)
112# endif 126# endif
113 { 127 {
114 if (h_scale != 0 || v_scale != 0 128 if (h_scale != 0 || v_scale != 0
115 || h_align != 0 || v_align != 0) 129 || h_align != 0 || v_align != 0)
116 return true; 130 return true;
117 } 131 }
118# endif 132# endif
133
134 return false;
135}
136
137bool
138bgPixmap_t::window_position_sensitive ()
139{
119# ifdef ENABLE_TRANSPARENCY 140# ifdef ENABLE_TRANSPARENCY
120 if (flags & isTransparent) 141 if (flags & isTransparent)
121 return true; 142 return true;
122# endif 143# endif
144
145# ifdef BG_IMAGE_FROM_FILE
146# ifdef HAVE_AFTERIMAGE
147 if (original_asim != NULL)
148# endif
149 {
150 if (h_align == rootAlign || v_align == rootAlign)
151 return true;
152 }
153# endif
154
123 return false; 155 return false;
124} 156};
125 157
126bool bgPixmap_t::need_client_side_rendering () 158bool bgPixmap_t::need_client_side_rendering ()
127{ 159{
128# ifdef HAVE_AFTERIMAGE 160# ifdef HAVE_AFTERIMAGE
129 if (original_asim != NULL) 161 if (original_asim != NULL)
163static inline bool 195static inline bool
164check_set_align_value (int geom_flags, int flag, int &align, int new_value) 196check_set_align_value (int geom_flags, int flag, int &align, int new_value)
165{ 197{
166 if (geom_flags & flag) 198 if (geom_flags & flag)
167 { 199 {
200 if (new_value != bgPixmap_t::rootAlign)
201 {
168 if (new_value < -100) 202 if (new_value < -100)
169 new_value = -100; 203 new_value = -100;
170 else if (new_value > 200) 204 else if (new_value > 200)
171 new_value = 200; 205 new_value = 200;
206 }
172 if (new_value != align) 207 if (new_value != align)
173 { 208 {
174 align = new_value; 209 align = new_value;
175 return true; 210 return true;
176 } 211 }
268 y = x; 303 y = x;
269 geom_flags |= YValue; 304 geom_flags |= YValue;
270 } 305 }
271 306
272 if (flags & geometrySet) 307 if (flags & geometrySet)
308 {
273 {/* new geometry is an adjustment to the old one ! */ 309 /* new geometry is an adjustment to the old one ! */
274 if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) 310 if ((geom_flags & WidthValue) && (geom_flags & HeightValue))
275 { 311 {
276 if (w == 0 && h != 0) 312 if (w == 0 && h != 0)
277 { 313 {
278 w = h_scale; 314 w = h_scale;
294 } 330 }
295 } 331 }
296 else /* setting up geometry from scratch */ 332 else /* setting up geometry from scratch */
297 { 333 {
298 if (!(geom_flags & XValue)) 334 if (!(geom_flags & XValue))
335 {
299 {/* use default geometry - centered */ 336 /* use default geometry - centered */
300 x = y = defaultAlign; 337 x = y = defaultAlign;
301 } 338 }
302 else if (!(geom_flags & YValue)) 339 else if (!(geom_flags & YValue))
303 y = x; 340 y = x;
304 341
305 if ((geom_flags & (WidthValue|HeightValue)) == 0) 342 if ((geom_flags & (WidthValue|HeightValue)) == 0)
343 {
306 {/* use default geometry - scaled */ 344 /* use default geometry - scaled */
307 w = h = defaultScale; 345 w = h = defaultScale;
308 } 346 }
309 else if (geom_flags & WidthValue) 347 else if (geom_flags & WidthValue)
310 { 348 {
311 if (!(geom_flags & HeightValue)) 349 if (!(geom_flags & HeightValue))
314 else 352 else
315 w = h; 353 w = h;
316 } 354 }
317 } /* done parsing geometry string */ 355 } /* done parsing geometry string */
318 else if (!(flags & geometrySet)) 356 else if (!(flags & geometrySet))
357 {
319 { /* default geometry - scaled and centered */ 358 /* default geometry - scaled and centered */
320 x = y = defaultAlign; 359 x = y = defaultAlign;
321 w = h = defaultScale; 360 w = h = defaultScale;
322 } 361 }
323 362
324 if (!(flags & geometrySet)) 363 if (!(flags & geometrySet))
330 { 369 {
331 while (*ops == ':' || isspace(*ops)) ++ops; 370 while (*ops == ':' || isspace(*ops)) ++ops;
332# define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) 371# define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0)
333 if (CHECK_GEOM_OPS("tile")) 372 if (CHECK_GEOM_OPS("tile"))
334 { 373 {
335 w = h = 0; 374 w = h = noScale;
336 geom_flags |= WidthValue|HeightValue; 375 geom_flags |= WidthValue|HeightValue;
337 } 376 }
338 else if (CHECK_GEOM_OPS("propscale")) 377 else if (CHECK_GEOM_OPS("propscale"))
339 { 378 {
340 if (w == 0 && h == 0) 379 if (w == 0 && h == 0)
341 { 380 {
342 w = 100; 381 w = windowScale;
343 geom_flags |= WidthValue; 382 geom_flags |= WidthValue;
344 } 383 }
345 new_flags |= propScale; 384 new_flags |= propScale;
346 } 385 }
347 else if (CHECK_GEOM_OPS("hscale")) 386 else if (CHECK_GEOM_OPS("hscale"))
348 { 387 {
349 if (w == 0) 388 if (w == 0)
350 w = 100; 389 w = windowScale;
351 h = 0; 390 h = noScale;
352 geom_flags |= WidthValue|HeightValue; 391 geom_flags |= WidthValue|HeightValue;
353 } 392 }
354 else if (CHECK_GEOM_OPS("vscale")) 393 else if (CHECK_GEOM_OPS("vscale"))
355 { 394 {
356 if (h == 0) 395 if (h == 0)
357 h = 100; 396 h = windowScale;
358 w = 0; 397 w = noScale;
359 geom_flags |= WidthValue|HeightValue; 398 geom_flags |= WidthValue|HeightValue;
360 } 399 }
361 else if (CHECK_GEOM_OPS("scale")) 400 else if (CHECK_GEOM_OPS("scale"))
362 { 401 {
363 if (h == 0) 402 if (h == 0)
364 h = 100; 403 h = windowScale;
365 if (w == 0) 404 if (w == 0)
366 w = 100; 405 w = windowScale;
367 geom_flags |= WidthValue|HeightValue; 406 geom_flags |= WidthValue|HeightValue;
368 } 407 }
369 else if (CHECK_GEOM_OPS("auto")) 408 else if (CHECK_GEOM_OPS("auto"))
370 { 409 {
410 w = h = windowScale;
411 x = y = centerAlign;
412 geom_flags |= WidthValue|HeightValue|XValue|YValue;
413 }
414 else if (CHECK_GEOM_OPS("root"))
415 {
371 w = h = 100; 416 w = h = noScale;
372 x = y = 50; 417 x = y = rootAlign;
373 geom_flags |= WidthValue|HeightValue|XValue|YValue; 418 geom_flags |= WidthValue|HeightValue|XValue|YValue;
374 } 419 }
375# undef CHECK_GEOM_OPS 420# undef CHECK_GEOM_OPS
376 while (*ops != ':' && *ops != '\0') ++ops; 421 while (*ops != ':' && *ops != '\0') ++ops;
377 } /* done parsing ops */ 422 } /* done parsing ops */
390 if (new_flags != flags) 435 if (new_flags != flags)
391 { 436 {
392 flags = new_flags; 437 flags = new_flags;
393 changed++; 438 changed++;
394 } 439 }
395//fprintf( stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", 440//fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n",
396// flags, h_scale, v_scale, h_align, v_align); 441// flags, h_scale, v_scale, h_align, v_align);
397 return (changed > 0); 442 return (changed > 0);
398} 443}
399 444
400# ifdef HAVE_AFTERIMAGE 445# ifdef HAVE_AFTERIMAGE
416 461
417 TIMING_TEST_START (asim); 462 TIMING_TEST_START (asim);
418 463
419 if (original_asim) 464 if (original_asim)
420 { 465 {
466 if (h_align == rootAlign || v_align == rootAlign)
467 {
468 target->get_window_origin(x, y);
469 x = -x;
470 y = -y;
471 }
472 if (h_align != rootAlign)
421 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); 473 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width);
474 if (v_align != rootAlign)
422 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); 475 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height);
423 } 476 }
424 477
425 if (original_asim == NULL 478 if (original_asim == NULL
426 || x >= target_width 479 || x >= target_width
427 || y >= target_height 480 || y >= target_height
456 h > 0 ? h : original_asim->height, 509 h > 0 ? h : original_asim->height,
457 background ? ASA_ASImage : ASA_XImage, 510 background ? ASA_ASImage : ASA_XImage,
458 100, ASIMAGE_QUALITY_DEFAULT); 511 100, ASIMAGE_QUALITY_DEFAULT);
459 } 512 }
460 if (background == NULL) 513 if (background == NULL)
514 {
461 {/* if tiling - pixmap has to be sized exactly as the image */ 515 /* if tiling - pixmap has to be sized exactly as the image,
516 but there is no need to make it bigger then the window! */
462 if (h_scale == 0) 517 if (h_scale == 0)
463 new_pmap_width = result->width; 518 new_pmap_width = min (result->width, target_width);
464 if (v_scale == 0) 519 if (v_scale == 0)
465 new_pmap_height = result->height; 520 new_pmap_height = min (result->height, target_height);
466 /* 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 */
467 if (h_scale == 0 || v_scale == 0) 522 if (h_scale == 0 || v_scale == 0)
468 { 523 {
469 ASImage *tmp = tile_asimage (target->asv, result, 524 ASImage *tmp = tile_asimage (target->asv, result,
470 (h_scale > 0) ? 0 : (int)result->width - x, 525 (h_scale > 0) ? 0 : (int)result->width - x,
471 (v_scale > 0) ? 0 : (int)result->height - y, 526 (v_scale > 0) ? 0 : (int)result->height - y,
527 new_pmap_width,
472 result->width, result->height, 528 new_pmap_height,
473 TINT_LEAVE_SAME, ASA_XImage, 529 TINT_LEAVE_SAME, ASA_XImage,
474 100, ASIMAGE_QUALITY_DEFAULT); 530 100, ASIMAGE_QUALITY_DEFAULT);
475 if (tmp) 531 if (tmp)
476 { 532 {
477 if (result != original_asim) 533 if (result != original_asim)
479 result = tmp; 535 result = tmp;
480 } 536 }
481 } 537 }
482 } 538 }
483 else 539 else
540 {
484 {/* 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 */
485 ASImageLayer *layers = create_image_layers (2); 542 ASImageLayer *layers = create_image_layers (2);
486 ASImage *merged_im = NULL; 543 ASImage *merged_im = NULL;
487 544
488 layers[0].im = background; 545 layers[0].im = background;
489 layers[0].clip_width = target_width; 546 layers[0].clip_width = target_width;
490 layers[0].clip_height = target_height; 547 layers[0].clip_height = target_height;
491 layers[0].tint = background_tint; 548 layers[0].tint = background_tint;
492 layers[1].im = result; 549 layers[1].im = result;
493 if (w <= 0) 550 if (w <= 0)
551 {
494 {/* tile horizontally */ 552 /* tile horizontally */
495 while (x > 0) x -= (int)result->width; 553 while (x > 0) x -= (int)result->width;
496 layers[1].dst_x = x; 554 layers[1].dst_x = x;
497 layers[1].clip_width = result->width+target_width; 555 layers[1].clip_width = result->width+target_width;
498 } 556 }
499 else 557 else
558 {
500 {/* clip horizontally */ 559 /* clip horizontally */
501 layers[1].dst_x = x; 560 layers[1].dst_x = x;
502 layers[1].clip_width = result->width; 561 layers[1].clip_width = result->width;
503 } 562 }
504 if (h <= 0) 563 if (h <= 0)
505 { 564 {
619# endif 678# endif
620 } 679 }
621 return false; 680 return false;
622} 681}
623 682
624# endif /* BG_IMAGE_FROM_FILE */ 683# endif /* BG_IMAGE_FROM_FILE */
625 684
626# ifdef ENABLE_TRANSPARENCY 685# ifdef ENABLE_TRANSPARENCY
627bool 686bool
628bgPixmap_t::set_transparent () 687bgPixmap_t::set_transparent ()
629{ 688{
720 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); 779 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade);
721 tint = new_tint; 780 tint = new_tint;
722 flags = (flags & ~tintFlags) | new_flags | tintSet; 781 flags = (flags & ~tintFlags) | new_flags | tintSet;
723 return true; 782 return true;
724 } 783 }
784
725 return false; 785 return false;
726} 786}
727 787
728bool 788bool
729bgPixmap_t::unset_tint () 789bgPixmap_t::unset_tint ()
733 if (new_flags != (flags & tintFlags)) 793 if (new_flags != (flags & tintFlags))
734 { 794 {
735 flags = (flags&~tintFlags)|new_flags; 795 flags = (flags&~tintFlags)|new_flags;
736 return true; 796 return true;
737 } 797 }
798
738 return false; 799 return false;
739} 800}
740 801
741bool 802bool
742bgPixmap_t::set_shade (const char *shade_str) 803bgPixmap_t::set_shade (const char *shade_str)
743{ 804{
744 int new_shade = (shade_str) ? atoi (shade_str) : 0; 805 int new_shade = (shade_str) ? atoi (shade_str) : 0;
745 806
746 if (new_shade < 0 && new_shade > -100) 807 if (new_shade < 0 && new_shade > -100)
747 new_shade = 200 - (100 + new_shade); 808 new_shade = 200 - (100 + new_shade);
748 else if (new_shade == 100) 809 else if (new_shade == 100)
749 new_shade = 0; 810 new_shade = 0;
750 811
751 if (new_shade != shade) 812 if (new_shade != shade)
752 { 813 {
753 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);
754 shade = new_shade; 815 shade = new_shade;
755 flags = (flags & (~tintFlags | tintSet)) | new_flags; 816 flags = (flags & (~tintFlags | tintSet)) | new_flags;
756 return true; 817 return true;
757 } 818 }
819
758 return false; 820 return false;
759} 821}
760 822
761/* make_transparency_pixmap() 823/* make_transparency_pixmap()
762 * 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
792 if (sx + window_width <= 0 || sy + window_height <= 0 854 if (sx + window_width <= 0 || sy + window_height <= 0
793 || sx >= root_width || sy >= root_height) 855 || sx >= root_width || sy >= root_height)
794 return 0; 856 return 0;
795 857
796 if (root_pixmap != None) 858 if (root_pixmap != None)
859 {
797 {/* 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 : */
798 int junk; 861 int junk;
799 unsigned int ujunk; 862 unsigned int ujunk;
800 /* root pixmap may be bad - allow a error */ 863 /* root pixmap may be bad - allow a error */
801 target->allowedxerror = -1; 864 target->allowedxerror = -1;
802 865
811 874
812 if (tiled_root_pmap == None) /* something really bad happened - abort */ 875 if (tiled_root_pmap == None) /* something really bad happened - abort */
813 return 0; 876 return 0;
814 877
815 if (root_pixmap == None) 878 if (root_pixmap == None)
879 {
816 { /* use tricks to obtain the root background image :*/ 880 /* use tricks to obtain the root background image :*/
817 /* we want to create Overrideredirect window overlapping out window 881 /* we want to create Overrideredirect window overlapping out window
818 with background type of Parent Relative and then grab it */ 882 with background type of Parent Relative and then grab it */
819 XSetWindowAttributes attr; 883 XSetWindowAttributes attr;
820 Window src; 884 Window src;
821 bool success = false; 885 bool success = false;
841 * 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 actuall event to arrive : */
842 while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) 906 while (XCheckWindowEvent (dpy, src, ExposureMask, &event))
843 ++ev_count; 907 ++ev_count;
844 908
845 if (ev_count > 0); 909 if (ev_count > 0);
910 {
846 { /* hooray! - we can grab the image! */ 911 /* hooray! - we can grab the image! */
847 gc = XCreateGC (dpy, root, 0, NULL); 912 gc = XCreateGC (dpy, root, 0, NULL);
848 if (gc) 913 if (gc)
849 { 914 {
850 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);
851 success = true; 916 success = true;
852 } 917 }
853 } 918 }
919
854 XDestroyWindow (dpy, src); 920 XDestroyWindow (dpy, src);
855 XUngrabServer (dpy); 921 XUngrabServer (dpy);
856 //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);
857 } 923 }
858 924
863 } 929 }
864 else 930 else
865 result |= transpPmapTiled; 931 result |= transpPmapTiled;
866 } 932 }
867 else 933 else
934 {
868 {/* strightforward pixmap copy */ 935 /* strightforward pixmap copy */
869 gcv.tile = root_pixmap; 936 gcv.tile = root_pixmap;
870 gcv.fill_style = FillTiled; 937 gcv.fill_style = FillTiled;
871 938
872 while (sx < 0) sx += (int)root_width; 939 while (sx < 0) sx += (int)root_width;
873 while (sy < 0) sy += (int)root_height; 940 while (sy < 0) sy += (int)root_height;
921 { 988 {
922 c.r = (c.r * shade) / 100; 989 c.r = (c.r * shade) / 100;
923 c.g = (c.g * shade) / 100; 990 c.g = (c.g * shade) / 100;
924 c.b = (c.b * shade) / 100; 991 c.b = (c.b * shade) / 100;
925 } 992 }
926 else if( shade > 100 && shade < 200) 993 else if (shade > 100 && shade < 200)
927 { 994 {
928 c.r = (c.r * (200 - shade)) / 100; 995 c.r = (c.r * (200 - shade)) / 100;
929 c.g = (c.g * (200 - shade)) / 100; 996 c.g = (c.g * (200 - shade)) / 100;
930 c.b = (c.b * (200 - shade)) / 100; 997 c.b = (c.b * (200 - shade)) / 100;
931 } 998 }
977 mask_c.blue = 0xffff - c.b; 1044 mask_c.blue = 0xffff - c.b;
978 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); 1045 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
979 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);
980 result |= transpPmapTinted; 1047 result |= transpPmapTinted;
981 } 1048 }
1049
982 XRenderFreePicture (dpy, mask_pic); 1050 XRenderFreePicture (dpy, mask_pic);
983 XRenderFreePicture (dpy, overlay_pic); 1051 XRenderFreePicture (dpy, overlay_pic);
984 XRenderFreePicture (dpy, back_pic); 1052 XRenderFreePicture (dpy, back_pic);
985# if DO_TIMING_TEST 1053# if DO_TIMING_TEST
986 XSync (dpy, False); 1054 XSync (dpy, False);
1008} 1076}
1009 1077
1010bool 1078bool
1011bgPixmap_t::set_root_pixmap () 1079bgPixmap_t::set_root_pixmap ()
1012{ 1080{
1013 Pixmap new_root_pixmap = None;
1014
1015 new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); 1081 Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID);
1016 if (new_root_pixmap == None) 1082 if (new_root_pixmap == None)
1017 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); 1083 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1018 1084
1019 if (new_root_pixmap != root_pixmap) 1085 if (new_root_pixmap != root_pixmap)
1020 { 1086 {
1021 root_pixmap = new_root_pixmap; 1087 root_pixmap = new_root_pixmap;
1022 return true; 1088 return true;
1023 } 1089 }
1090
1024 return false; 1091 return false;
1025} 1092}
1026# endif /* ENABLE_TRANSPARENCY */ 1093# endif /* ENABLE_TRANSPARENCY */
1027 1094
1028# ifndef HAVE_AFTERIMAGE 1095# ifndef HAVE_AFTERIMAGE
1029static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); 1096static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm);
1030# endif 1097# endif
1031
1032 1098
1033bool 1099bool
1034bgPixmap_t::render () 1100bgPixmap_t::render ()
1035{ 1101{
1036 unsigned long background_flags = 0; 1102 unsigned long background_flags = 0;
1118 ShadeXImage (target, result, shade, c.r, c.g, c.b); 1184 ShadeXImage (target, result, shade, c.r, c.g, c.b);
1119 } 1185 }
1120 } 1186 }
1121# endif /* HAVE_AFTERIMAGE */ 1187# endif /* HAVE_AFTERIMAGE */
1122 1188
1123 if (result != NULL) 1189 if (result)
1124 { 1190 {
1125 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1191 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1192
1126 if (gc) 1193 if (gc)
1127 { 1194 {
1128 if (/*pmap_depth != target->depth &&*/ pixmap != None) 1195 if (/*pmap_depth != target->depth &&*/ pixmap != None)
1129 { 1196 {
1130 XFreePixmap (target->dpy, pixmap); 1197 XFreePixmap (target->dpy, pixmap);
1131 pixmap = None; 1198 pixmap = None;
1132 } 1199 }
1200
1133 if (pixmap == None) 1201 if (pixmap == None)
1134 { 1202 {
1135 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);
1136 pmap_width = result->width; 1204 pmap_width = result->width;
1137 pmap_height = result->height; 1205 pmap_height = result->height;
1138 pmap_depth = target->depth; 1206 pmap_depth = target->depth;
1139 } 1207 }
1208
1140 if (pmap_depth != result->depth) 1209 if (pmap_depth != result->depth)
1210 {
1141 { /* Bad Match error will ensue ! stupid X !!!! */ 1211 /* Bad Match error will ensue ! stupid X !!!! */
1142 if( result->depth == 24 && pmap_depth == 32) 1212 if (result->depth == 24 && pmap_depth == 32)
1143 result->depth = 32; 1213 result->depth = 32;
1144 else if( result->depth == 32 && pmap_depth == 24) 1214 else if (result->depth == 32 && pmap_depth == 24)
1145 result->depth = 24; 1215 result->depth = 24;
1146 else 1216 else
1147 { 1217 {
1148 /* TODO: implement image recoding */ 1218 /* TODO: implement image recoding */
1149 } 1219 }
1150 } 1220 }
1221
1151 if (pmap_depth == result->depth) 1222 if (pmap_depth == result->depth)
1152 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
1153 XFreeGC (target->dpy, gc); 1225 XFreeGC (target->dpy, gc);
1154 flags = flags & ~isInvalid; 1226 flags = flags & ~isInvalid;
1155 } 1227 }
1228
1156 XDestroyImage (result); 1229 XDestroyImage (result);
1157 } 1230 }
1158 1231
1159 if (flags & isInvalid) 1232 if (flags & isInvalid)
1160 { 1233 {
1186 } 1259 }
1187 return false; 1260 return false;
1188} 1261}
1189 1262
1190void 1263void
1191bgPixmap_t::apply() 1264bgPixmap_t::apply ()
1192{ 1265{
1193 if (target) 1266 if (target)
1194 { 1267 {
1195 flags &= ~isVtOrigin; 1268 flags &= ~isVtOrigin;
1196 if (pixmap != None) 1269 if (pixmap != None)
1270 {
1197 { /* set target's background to pixmap */ 1271 /* set target's background to pixmap */
1198# ifdef ENABLE_TRANSPARENCY 1272# ifdef ENABLE_TRANSPARENCY
1199 if (flags & isTransparent) 1273 if (flags & isTransparent)
1200 { 1274 {
1201 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); 1275 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap);
1202 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); 1276 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative);
1218 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1292 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1219# endif 1293# endif
1220 } 1294 }
1221 } 1295 }
1222 else 1296 else
1297 {
1223 { /* set target background to a pixel */ 1298 /* set target background to a pixel */
1224 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); 1299 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1225 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); 1300 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]);
1226 /* do we also need to set scrollbar's background here ? */ 1301 /* do we also need to set scrollbar's background here ? */
1227# if HAVE_SCROLLBARS 1302# if HAVE_SCROLLBARS
1228 if (target->scrollBar.win) 1303 if (target->scrollBar.win)
1244 target->want_refresh = 1; 1319 target->want_refresh = 1;
1245 flags |= hasChanged; 1320 flags |= hasChanged;
1246 } 1321 }
1247} 1322}
1248 1323
1249#endif /* HAVE_BG_PIXMAP */ 1324#endif /* HAVE_BG_PIXMAP */
1250 1325
1251#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT 1326#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT
1252/* taken from aterm-0.4.2 */ 1327/* taken from aterm-0.4.2 */
1253 1328
1254typedef uint32_t RUINT32T; 1329typedef uint32_t RUINT32T;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines