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.1 by sasha, Wed Sep 12 20:29:24 2007 UTC vs.
Revision 1.22 by sasha, Fri Jan 4 21:25:57 2008 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: background.C - former xmp.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) \
38 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ 36 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\
39 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ 37 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\
40 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) 38 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0)
41 39
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
90bgPixmap_t::bgPixmap_t ()
91{
92#ifdef HAVE_AFTERIMAGE
93 original_asim = NULL;
94#endif
95#ifdef BG_IMAGE_FROM_FILE
96 h_scale = v_scale = 0;
97 h_align = v_align = 0;
98#endif
99 flags = 0;
100 pixmap = None;
101 valid_since = invalid_since = 0;
102}
103
104void
105bgPixmap_t::destroy ()
106{
107#ifdef HAVE_AFTERIMAGE
108 if (original_asim)
109 safe_asimage_destroy (original_asim);
110#endif
111
112 if (pixmap && target)
113 XFreePixmap (target->dpy, pixmap);
114}
115
92bool 116bool
93bgPixmap_t::window_size_sensitive () 117bgPixmap_t::window_size_sensitive ()
94{ 118{
95# ifdef XPM_BACKGROUND
96# ifdef HAVE_AFTERIMAGE
97 if (original_asim != NULL)
98# endif
99 {
100 if (h_scale != 0 || v_scale != 0
101 || h_align != 0 || v_align != 0)
102 return true;
103 }
104# endif
105# ifdef ENABLE_TRANSPARENCY 119# ifdef ENABLE_TRANSPARENCY
106 if (flags & isTransparent) 120 if (flags & isTransparent)
107 return true; 121 return true;
108# endif 122# endif
123
124# ifdef BG_IMAGE_FROM_FILE
125# ifdef HAVE_AFTERIMAGE
126 if (original_asim != NULL)
127# endif
128 {
129 if (h_scale != 0 || v_scale != 0
130 || h_align != 0 || v_align != 0)
131 return true;
132 }
133# endif
134
109 return false; 135 return false;
110} 136}
137
138bool
139bgPixmap_t::window_position_sensitive ()
140{
141# ifdef ENABLE_TRANSPARENCY
142 if (flags & isTransparent)
143 return true;
144# endif
145
146# ifdef BG_IMAGE_FROM_FILE
147# ifdef HAVE_AFTERIMAGE
148 if (original_asim != NULL)
149# endif
150 {
151 if (h_align == rootAlign || v_align == rootAlign)
152 return true;
153 }
154# endif
155
156 return false;
157};
111 158
112bool bgPixmap_t::need_client_side_rendering () 159bool bgPixmap_t::need_client_side_rendering ()
113{ 160{
114# ifdef HAVE_AFTERIMAGE 161# ifdef HAVE_AFTERIMAGE
115 if (original_asim != NULL) 162 if (original_asim != NULL)
116 return true; 163 return true;
117# endif 164# endif
118# ifdef ENABLE_TRANSPARENCY 165# ifdef ENABLE_TRANSPARENCY
119 if (flags & isTransparent) 166 if (flags & isTransparent)
120 { 167 {
168# ifdef HAVE_AFTERIMAGE // can't blur without libAI anyways
121 if (((flags & blurNeeded) && !(flags & blurServerSide)) 169 if ((flags & blurNeeded) && !(flags & blurServerSide))
170 return true;
171# endif
122 || ((flags & tintNeeded) && !(flags & tintServerSide))) 172 if ((flags & tintNeeded) && !(flags & tintServerSide))
123 return true; 173 return true;
124 } 174 }
125# endif 175# endif
126 return false; 176 return false;
127} 177}
128 178
129# ifdef XPM_BACKGROUND 179# ifdef BG_IMAGE_FROM_FILE
130static inline bool 180static inline bool
131check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value) 181check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value)
132{ 182{
133 if (geom_flags & flag) 183 if (geom_flags & flag)
134 { 184 {
146static inline bool 196static inline bool
147check_set_align_value (int geom_flags, int flag, int &align, int new_value) 197check_set_align_value (int geom_flags, int flag, int &align, int new_value)
148{ 198{
149 if (geom_flags & flag) 199 if (geom_flags & flag)
150 { 200 {
201 if (new_value != bgPixmap_t::rootAlign)
202 {
151 if (new_value < -100) 203 if (new_value < -100)
152 new_value = -100; 204 new_value = -100;
153 else if (new_value > 200) 205 else if (new_value > 200)
154 new_value = 200; 206 new_value = 200;
207 }
155 if (new_value != align) 208 if (new_value != align)
156 { 209 {
157 align = new_value; 210 align = new_value;
158 return true; 211 return true;
159 } 212 }
251 y = x; 304 y = x;
252 geom_flags |= YValue; 305 geom_flags |= YValue;
253 } 306 }
254 307
255 if (flags & geometrySet) 308 if (flags & geometrySet)
309 {
256 {/* new geometry is an adjustment to the old one ! */ 310 /* new geometry is an adjustment to the old one ! */
257 if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) 311 if ((geom_flags & WidthValue) && (geom_flags & HeightValue))
258 { 312 {
259 if (w == 0 && h != 0) 313 if (w == 0 && h != 0)
260 { 314 {
261 w = h_scale; 315 w = h_scale;
277 } 331 }
278 } 332 }
279 else /* setting up geometry from scratch */ 333 else /* setting up geometry from scratch */
280 { 334 {
281 if (!(geom_flags & XValue)) 335 if (!(geom_flags & XValue))
336 {
282 {/* use default geometry - centered */ 337 /* use default geometry - centered */
283 x = y = defaultAlign; 338 x = y = defaultAlign;
284 } 339 }
285 else if (!(geom_flags & YValue)) 340 else if (!(geom_flags & YValue))
286 y = x; 341 y = x;
287 342
288 if ((geom_flags & (WidthValue|HeightValue)) == 0) 343 if ((geom_flags & (WidthValue|HeightValue)) == 0)
344 {
289 {/* use default geometry - scaled */ 345 /* use default geometry - scaled */
290 w = h = defaultScale; 346 w = h = defaultScale;
291 } 347 }
292 else if (geom_flags & WidthValue) 348 else if (geom_flags & WidthValue)
293 { 349 {
294 if (!(geom_flags & HeightValue)) 350 if (!(geom_flags & HeightValue))
297 else 353 else
298 w = h; 354 w = h;
299 } 355 }
300 } /* done parsing geometry string */ 356 } /* done parsing geometry string */
301 else if (!(flags & geometrySet)) 357 else if (!(flags & geometrySet))
358 {
302 { /* default geometry - scaled and centered */ 359 /* default geometry - scaled and centered */
303 x = y = defaultAlign; 360 x = y = defaultAlign;
304 w = h = defaultScale; 361 w = h = defaultScale;
305 } 362 }
306 363
307 if (!(flags & geometrySet)) 364 if (!(flags & geometrySet))
308 geom_flags |= WidthValue|HeightValue|XValue|YValue; 365 geom_flags |= WidthValue|HeightValue|XValue|YValue;
309 366
310 if (ops) 367 if (ops)
311 { 368 {
313 { 370 {
314 while (*ops == ':' || isspace(*ops)) ++ops; 371 while (*ops == ':' || isspace(*ops)) ++ops;
315# define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) 372# define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0)
316 if (CHECK_GEOM_OPS("tile")) 373 if (CHECK_GEOM_OPS("tile"))
317 { 374 {
318 w = h = 0; 375 w = h = noScale;
319 geom_flags |= WidthValue|HeightValue; 376 geom_flags |= WidthValue|HeightValue;
320 } 377 }
321 else if (CHECK_GEOM_OPS("propscale")) 378 else if (CHECK_GEOM_OPS("propscale"))
322 { 379 {
323 if (w == 0 && h == 0) 380 if (w == 0 && h == 0)
324 { 381 {
325 w = 100; 382 w = windowScale;
326 geom_flags |= WidthValue; 383 geom_flags |= WidthValue;
327 } 384 }
328 new_flags |= propScale; 385 new_flags |= propScale;
329 } 386 }
330 else if (CHECK_GEOM_OPS("hscale")) 387 else if (CHECK_GEOM_OPS("hscale"))
331 { 388 {
332 if (w == 0) 389 if (w == 0)
333 w = 100; 390 w = windowScale;
334 h = 0; 391 h = noScale;
335 geom_flags |= WidthValue|HeightValue; 392 geom_flags |= WidthValue|HeightValue;
336 } 393 }
337 else if (CHECK_GEOM_OPS("vscale")) 394 else if (CHECK_GEOM_OPS("vscale"))
338 { 395 {
339 if (h == 0) 396 if (h == 0)
340 h = 100; 397 h = windowScale;
341 w = 0; 398 w = noScale;
342 geom_flags |= WidthValue|HeightValue; 399 geom_flags |= WidthValue|HeightValue;
343 } 400 }
344 else if (CHECK_GEOM_OPS("scale")) 401 else if (CHECK_GEOM_OPS("scale"))
345 { 402 {
346 if (h == 0) 403 if (h == 0)
347 h = 100; 404 h = windowScale;
348 if (w == 0) 405 if (w == 0)
349 w = 100; 406 w = windowScale;
350 geom_flags |= WidthValue|HeightValue; 407 geom_flags |= WidthValue|HeightValue;
351 } 408 }
352 else if (CHECK_GEOM_OPS("auto")) 409 else if (CHECK_GEOM_OPS("auto"))
353 { 410 {
411 w = h = windowScale;
412 x = y = centerAlign;
413 geom_flags |= WidthValue|HeightValue|XValue|YValue;
414 }
415 else if (CHECK_GEOM_OPS("root"))
416 {
354 w = h = 100; 417 w = h = noScale;
355 x = y = 50; 418 x = y = rootAlign;
356 geom_flags |= WidthValue|HeightValue|XValue|YValue; 419 geom_flags |= WidthValue|HeightValue|XValue|YValue;
357 } 420 }
358# undef CHECK_GEOM_OPS 421# undef CHECK_GEOM_OPS
359 while (*ops != ':' && *ops != '\0') ++ops; 422 while (*ops != ':' && *ops != '\0') ++ops;
360 } /* done parsing ops */ 423 } /* done parsing ops */
373 if (new_flags != flags) 436 if (new_flags != flags)
374 { 437 {
375 flags = new_flags; 438 flags = new_flags;
376 changed++; 439 changed++;
377 } 440 }
378//fprintf( stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", 441//fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n",
379// flags, h_scale, v_scale, h_align, v_align); 442// flags, h_scale, v_scale, h_align, v_align);
380 return (changed > 0); 443 return (changed > 0);
381} 444}
382 445
383# ifdef HAVE_AFTERIMAGE 446# ifdef HAVE_AFTERIMAGE
399 462
400 TIMING_TEST_START (asim); 463 TIMING_TEST_START (asim);
401 464
402 if (original_asim) 465 if (original_asim)
403 { 466 {
467 if (h_align == rootAlign || v_align == rootAlign)
468 {
469 target->get_window_origin(x, y);
470 x = -x;
471 y = -y;
472 }
473 if (h_align != rootAlign)
404 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); 474 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width);
475 if (v_align != rootAlign)
405 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); 476 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height);
406 } 477 }
407 478
408 if (original_asim == NULL 479 if (original_asim == NULL
409 || x >= target_width 480 || x >= target_width
410 || y >= target_height 481 || y >= target_height
432 { 503 {
433 result = original_asim; 504 result = original_asim;
434 if ((w > 0 && w != original_asim->width) 505 if ((w > 0 && w != original_asim->width)
435 || (h > 0 && h != original_asim->height)) 506 || (h > 0 && h != original_asim->height))
436 { 507 {
437 result = scale_asimage (target->asv, original_asim, 508 result = scale_asimage (target->asv, original_asim,
438 w > 0 ? w : original_asim->width, 509 w > 0 ? w : original_asim->width,
439 h > 0 ? h : original_asim->height, 510 h > 0 ? h : original_asim->height,
440 background ? ASA_ASImage : ASA_XImage, 511 background ? ASA_ASImage : ASA_XImage,
441 100, ASIMAGE_QUALITY_DEFAULT); 512 100, ASIMAGE_QUALITY_DEFAULT);
442 } 513 }
443 if (background == NULL) 514 if (background == NULL)
515 {
444 {/* if tiling - pixmap has to be sized exactly as the image */ 516 /* if tiling - pixmap has to be sized exactly as the image,
517 but there is no need to make it bigger then the window! */
445 if (h_scale == 0) 518 if (h_scale == 0)
446 new_pmap_width = result->width; 519 new_pmap_width = min (result->width, target_width);
447 if (v_scale == 0) 520 if (v_scale == 0)
448 new_pmap_height = result->height; 521 new_pmap_height = min (result->height, target_height);
449 /* we also need to tile our image in one or both directions */ 522 /* we also need to tile our image in one or both directions */
450 if (h_scale == 0 || v_scale == 0) 523 if (h_scale == 0 || v_scale == 0)
451 { 524 {
452 ASImage *tmp = tile_asimage (target->asv, result, 525 ASImage *tmp = tile_asimage (target->asv, result,
453 (h_scale > 0) ? 0 : (int)result->width - x, 526 (h_scale > 0) ? 0 : (int)result->width - x,
454 (v_scale > 0) ? 0 : (int)result->height - y, 527 (v_scale > 0) ? 0 : (int)result->height - y,
528 new_pmap_width,
455 result->width, result->height, 529 new_pmap_height,
456 TINT_LEAVE_SAME, ASA_XImage, 530 TINT_LEAVE_SAME, ASA_XImage,
457 100, ASIMAGE_QUALITY_DEFAULT); 531 100, ASIMAGE_QUALITY_DEFAULT);
458 if (tmp) 532 if (tmp)
459 { 533 {
460 if (result != original_asim) 534 if (result != original_asim)
462 result = tmp; 536 result = tmp;
463 } 537 }
464 } 538 }
465 } 539 }
466 else 540 else
541 {
467 {/* if blending background and image - pixmap has to be sized same as target window */ 542 /* if blending background and image - pixmap has to be sized same as target window */
468 ASImageLayer *layers = create_image_layers (2); 543 ASImageLayer *layers = create_image_layers (2);
469 ASImage *merged_im = NULL; 544 ASImage *merged_im = NULL;
470 545
471 layers[0].im = background; 546 layers[0].im = background;
472 layers[0].clip_width = target_width; 547 layers[0].clip_width = target_width;
473 layers[0].clip_height = target_height; 548 layers[0].clip_height = target_height;
474 layers[0].tint = background_tint; 549 layers[0].tint = background_tint;
475 layers[1].im = result; 550 layers[1].im = result;
476 if (w <= 0) 551 if (w <= 0)
552 {
477 {/* tile horizontally */ 553 /* tile horizontally */
478 while (x > 0) x -= (int)result->width; 554 while (x > 0) x -= (int)result->width;
479 layers[1].dst_x = x; 555 layers[1].dst_x = x;
480 layers[1].clip_width = result->width+target_width; 556 layers[1].clip_width = result->width+target_width;
481 } 557 }
482 else 558 else
559 {
483 {/* clip horizontally */ 560 /* clip horizontally */
484 layers[1].dst_x = x; 561 layers[1].dst_x = x;
485 layers[1].clip_width = result->width; 562 layers[1].clip_width = result->width;
486 } 563 }
487 if (h <= 0) 564 if (h <= 0)
488 { 565 {
561 } 638 }
562 639
563 /* put result on pixmap */ 640 /* put result on pixmap */
564 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 641 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
565 asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); 642 asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True);
566 643
567 if (result != background && result != original_asim) 644 if (result != background && result != original_asim)
568 destroy_asimage (&result); 645 destroy_asimage (&result);
569 646
570 XFreeGC (target->dpy, gc); 647 XFreeGC (target->dpy, gc);
571 TIMING_TEST_PRINT_RESULT (asim); 648 TIMING_TEST_PRINT_RESULT (asim);
597 f[len] = '\0'; 674 f[len] = '\0';
598 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); 675 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100);
599 free (f); 676 free (f);
600 } 677 }
601 return (original_asim != NULL); 678 return (original_asim != NULL);
602# endif 679# endif
603 } 680 }
604 return false; 681 return false;
605} 682}
606 683
607# endif /* XPM_BACKGROUND */ 684# endif /* BG_IMAGE_FROM_FILE */
608 685
609# ifdef ENABLE_TRANSPARENCY 686# ifdef ENABLE_TRANSPARENCY
610bool 687bool
611bgPixmap_t::set_transparent () 688bgPixmap_t::set_transparent ()
612{ 689{
613 if (!(flags & isTransparent)) 690 if (!(flags & isTransparent))
614 { 691 {
615 flags |= isTransparent; 692 flags |= isTransparent;
640 if (v_blurRadius != vr) 717 if (v_blurRadius != vr)
641 { 718 {
642 ++changed; 719 ++changed;
643 v_blurRadius = vr; 720 v_blurRadius = vr;
644 } 721 }
645 722
646 if (v_blurRadius == 0 && h_blurRadius == 0) 723 if (v_blurRadius == 0 && h_blurRadius == 0)
647 flags &= ~blurNeeded; 724 flags &= ~blurNeeded;
648 else 725 else
649 flags |= blurNeeded; 726 flags |= blurNeeded;
650 727
654static inline unsigned long 731static inline unsigned long
655compute_tint_shade_flags (rxvt_color *tint, int shade) 732compute_tint_shade_flags (rxvt_color *tint, int shade)
656{ 733{
657 unsigned long flags = 0; 734 unsigned long flags = 0;
658 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 735 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
736 bool has_shade = (shade > 0 && shade < 100) || (shade > 100 && shade < 200);
659 737
660 if (tint) 738 if (tint)
661 { 739 {
662 tint->get (c); 740 tint->get (c);
663# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) 741# define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700)
664 if (IS_COMPONENT_WHOLESOME (c.r) 742 if (!has_shade && IS_COMPONENT_WHOLESOME (c.r)
665 && IS_COMPONENT_WHOLESOME (c.g) 743 && IS_COMPONENT_WHOLESOME (c.g)
666 && IS_COMPONENT_WHOLESOME (c.b)) 744 && IS_COMPONENT_WHOLESOME (c.b))
667 flags |= bgPixmap_t::tintWholesome; 745 flags |= bgPixmap_t::tintWholesome;
668# undef IS_COMPONENT_WHOLESOME 746# undef IS_COMPONENT_WHOLESOME
669 } 747 }
670 748
671 if ((shade > 0 && shade < 100) || (shade > 100 && shade < 200)) 749 if (has_shade)
672 flags |= bgPixmap_t::tintNeeded; 750 flags |= bgPixmap_t::tintNeeded;
673 else if (tint) 751 else if (tint)
674 { 752 {
675 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) 753 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700)
676 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) 754 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700))
677 { 755 {
678 flags |= bgPixmap_t::tintNeeded; 756 flags |= bgPixmap_t::tintNeeded;
679 } 757 }
680 } 758 }
681 759
682 if (flags & bgPixmap_t::tintNeeded) 760 if (flags & bgPixmap_t::tintNeeded)
683 { 761 {
684 if (flags & bgPixmap_t::tintWholesome) 762 if (flags & bgPixmap_t::tintWholesome)
685 flags |= bgPixmap_t::tintServerSide; 763 flags |= bgPixmap_t::tintServerSide;
764 else
765 {
686#if XFT 766#if XFT
687 flags |= bgPixmap_t::tintServerSide; 767 flags |= bgPixmap_t::tintServerSide;
688#endif 768#endif
769 }
689 } 770 }
690 771
691 return flags; 772 return flags;
692} 773}
693 774
699 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); 780 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade);
700 tint = new_tint; 781 tint = new_tint;
701 flags = (flags & ~tintFlags) | new_flags | tintSet; 782 flags = (flags & ~tintFlags) | new_flags | tintSet;
702 return true; 783 return true;
703 } 784 }
785
704 return false; 786 return false;
705} 787}
706 788
707bool 789bool
708bgPixmap_t::unset_tint () 790bgPixmap_t::unset_tint ()
712 if (new_flags != (flags & tintFlags)) 794 if (new_flags != (flags & tintFlags))
713 { 795 {
714 flags = (flags&~tintFlags)|new_flags; 796 flags = (flags&~tintFlags)|new_flags;
715 return true; 797 return true;
716 } 798 }
799
717 return false; 800 return false;
718} 801}
719 802
720bool 803bool
721bgPixmap_t::set_shade (const char *shade_str) 804bgPixmap_t::set_shade (const char *shade_str)
722{ 805{
723 int new_shade = (shade_str) ? atoi (shade_str) : 0; 806 int new_shade = (shade_str) ? atoi (shade_str) : 0;
724 807
808 if (new_shade < 0 && new_shade > -100)
809 new_shade = 200 - (100 + new_shade);
725 if (new_shade == 100) 810 else if (new_shade == 100)
726 new_shade = 0; 811 new_shade = 0;
727 812
728 if (new_shade != shade) 813 if (new_shade != shade)
729 { 814 {
730 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); 815 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade);
731 shade = new_shade; 816 shade = new_shade;
732 flags = (flags & ~tintFlags) | new_flags; 817 flags = (flags & (~tintFlags | tintSet)) | new_flags;
733 return true; 818 return true;
734 } 819 }
820
735 return false; 821 return false;
736} 822}
737 823
738/* make_transparency_pixmap() 824/* make_transparency_pixmap()
739 * Builds a pixmap sized the same as terminal window, with depth same as the root window 825 * Builds a pixmap sized the same as terminal window, with depth same as the root window
740 * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by 826 * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by
741 * our window. 827 * our window.
742 */ 828 */
743unsigned long 829unsigned long
744bgPixmap_t::make_transparency_pixmap () 830bgPixmap_t::make_transparency_pixmap ()
745{ 831{
769 if (sx + window_width <= 0 || sy + window_height <= 0 855 if (sx + window_width <= 0 || sy + window_height <= 0
770 || sx >= root_width || sy >= root_height) 856 || sx >= root_width || sy >= root_height)
771 return 0; 857 return 0;
772 858
773 if (root_pixmap != None) 859 if (root_pixmap != None)
860 {
774 {/* we want to validate the pixmap and get it's size at the same time : */ 861 /* we want to validate the pixmap and get it's size at the same time : */
775 int junk; 862 int junk;
776 unsigned int ujunk; 863 unsigned int ujunk;
777 /* root pixmap may be bad - allow a error */ 864 /* root pixmap may be bad - allow a error */
778 target->allowedxerror = -1; 865 target->allowedxerror = -1;
779 866
788 875
789 if (tiled_root_pmap == None) /* something really bad happened - abort */ 876 if (tiled_root_pmap == None) /* something really bad happened - abort */
790 return 0; 877 return 0;
791 878
792 if (root_pixmap == None) 879 if (root_pixmap == None)
880 {
793 { /* use tricks to obtain the root background image :*/ 881 /* use tricks to obtain the root background image :*/
794 /* we want to create Overrideredirect window overlapping out window 882 /* we want to create Overrideredirect window overlapping out window
795 with background type of Parent Relative and then grab it */ 883 with background type of Parent Relative and then grab it */
796 XSetWindowAttributes attr; 884 XSetWindowAttributes attr;
797 Window src; 885 Window src;
798 bool success = false; 886 bool success = false;
813 XGrabServer (dpy); 901 XGrabServer (dpy);
814 XMapRaised (dpy, src); 902 XMapRaised (dpy, src);
815 XSync (dpy, False); 903 XSync (dpy, False);
816 904
817 /* XSync should get window where it's properly exposed, 905 /* XSync should get window where it's properly exposed,
818 * but to be on the safe side - let's check for the actuall event to arrive : */ 906 * but to be on the safe side - let's check for the actual event to arrive : */
819 while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) 907 while (XCheckWindowEvent (dpy, src, ExposureMask, &event))
820 ++ev_count; 908 ++ev_count;
821 909
822 if (ev_count > 0); 910 if (ev_count > 0);
911 {
823 { /* hooray! - we can grab the image! */ 912 /* hooray! - we can grab the image! */
824 gc = XCreateGC (dpy, root, 0, NULL); 913 gc = XCreateGC (dpy, root, 0, NULL);
825 if (gc) 914 if (gc)
826 { 915 {
827 XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0); 916 XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0);
828 success = true; 917 success = true;
829 } 918 }
830 } 919 }
920
831 XDestroyWindow (dpy, src); 921 XDestroyWindow (dpy, src);
832 XUngrabServer (dpy); 922 XUngrabServer (dpy);
833 //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); 923 //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count);
834 } 924 }
835 925
840 } 930 }
841 else 931 else
842 result |= transpPmapTiled; 932 result |= transpPmapTiled;
843 } 933 }
844 else 934 else
935 {
845 {/* strightforward pixmap copy */ 936 /* strightforward pixmap copy */
846 gcv.tile = root_pixmap; 937 gcv.tile = root_pixmap;
847 gcv.fill_style = FillTiled; 938 gcv.fill_style = FillTiled;
848 939
849 while (sx < 0) sx += (int)window_width; 940 while (sx < 0) sx += (int)root_width;
850 while (sy < 0) sy += (int)window_height; 941 while (sy < 0) sy += (int)root_height;
851 942
852 gcv.ts_x_origin = -sx; 943 gcv.ts_x_origin = -sx;
853 gcv.ts_y_origin = -sy; 944 gcv.ts_y_origin = -sy;
854 gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 945 gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
855 946
861 } 952 }
862 TIMING_TEST_PRINT_RESULT (tp); 953 TIMING_TEST_PRINT_RESULT (tp);
863 954
864 if (tiled_root_pmap != None) 955 if (tiled_root_pmap != None)
865 { 956 {
866 if (!need_client_side_rendering ()) 957 if (!need_client_side_rendering ())
867 { 958 {
868 if ((flags & tintNeeded)) 959 if ((flags & tintNeeded))
869 { 960 {
870 if (flags & tintWholesome) 961 if (flags & tintWholesome)
871 { 962 {
872 /* In this case we can tint image server-side getting significant 963 /* In this case we can tint image server-side getting significant
873 * performance improvements, as we eliminate XImage transfer 964 * performance improvements, as we eliminate XImage transfer
898 { 989 {
899 c.r = (c.r * shade) / 100; 990 c.r = (c.r * shade) / 100;
900 c.g = (c.g * shade) / 100; 991 c.g = (c.g * shade) / 100;
901 c.b = (c.b * shade) / 100; 992 c.b = (c.b * shade) / 100;
902 } 993 }
903 else if( shade > 100 && shade < 200) 994 else if (shade > 100 && shade < 200)
904 { 995 {
905 c.r = (c.r * (200 - shade)) / 100; 996 c.r = (c.r * (200 - shade)) / 100;
906 c.g = (c.g * (200 - shade)) / 100; 997 c.g = (c.g * (200 - shade)) / 100;
907 c.b = (c.b * (200 - shade)) / 100; 998 c.b = (c.b * (200 - shade)) / 100;
908 } 999 }
914 pf.direct.greenMask = 0xff; 1005 pf.direct.greenMask = 0xff;
915 pf.direct.blueMask = 0xff; 1006 pf.direct.blueMask = 0xff;
916 pf.direct.alphaMask = 0xff; 1007 pf.direct.alphaMask = 0xff;
917 1008
918 XRenderPictFormat *solid_format = XRenderFindFormat (dpy, 1009 XRenderPictFormat *solid_format = XRenderFindFormat (dpy,
919 (PictFormatType| 1010 (PictFormatType|
920 PictFormatDepth| 1011 PictFormatDepth|
921 PictFormatRedMask| 1012 PictFormatRedMask|
922 PictFormatGreenMask| 1013 PictFormatGreenMask|
923 PictFormatBlueMask| 1014 PictFormatBlueMask|
924 PictFormatAlphaMask), 1015 PictFormatAlphaMask),
925 &pf, 1016 &pf,
926 0); 1017 0);
927 XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); 1018 XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen)));
928 XRenderPictureAttributes pa ; 1019 XRenderPictureAttributes pa ;
929 1020
930 back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); 1021 back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa);
931 1022
933 1024
934 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 1025 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
935 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); 1026 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
936 XFreePixmap (dpy, overlay_pmap); 1027 XFreePixmap (dpy, overlay_pmap);
937 1028
938 pa.component_alpha = True; 1029 pa.component_alpha = True;
939 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); 1030 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
940 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); 1031 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa);
941 XFreePixmap (dpy, mask_pmap); 1032 XFreePixmap (dpy, mask_pmap);
942 1033
943 if (mask_pic && overlay_pic && back_pic) 1034 if (mask_pic && overlay_pic && back_pic)
945 XRenderColor mask_c; 1036 XRenderColor mask_c;
946 1037
947 memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); 1038 memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c));
948 mask_c.alpha = 0xffff; 1039 mask_c.alpha = 0xffff;
949 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1040 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
950 memset (&mask_c, 0x0, sizeof (mask_c)); 1041
951 mask_c.alpha = 0; 1042 mask_c.alpha = 0;
952 1043 mask_c.red = 0xffff - c.r;
953 if (c.r == c.b && c.b == c.g) /* pure shading */ 1044 mask_c.green = 0xffff - c.g;
954 { 1045 mask_c.blue = 0xffff - c.b;
955 mask_c.red = mask_c.green = mask_c.blue = 0xffff - c.r;
956 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); 1046 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
957 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); 1047 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
958 }
959 else
960 {
961 mask_c.red = 0xffff - c.r;
962 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
963 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
964 mask_c.red = 0;
965 mask_c.green = 0xffff - c.g;
966 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
967 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
968 mask_c.green = 0;
969 mask_c.blue = 0xffff - c.b;
970 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
971 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
972 }
973 result |= transpPmapTinted; 1048 result |= transpPmapTinted;
974 } 1049 }
1050
975 XRenderFreePicture (dpy, mask_pic); 1051 XRenderFreePicture (dpy, mask_pic);
976 XRenderFreePicture (dpy, overlay_pic); 1052 XRenderFreePicture (dpy, overlay_pic);
977 XRenderFreePicture (dpy, back_pic); 1053 XRenderFreePicture (dpy, back_pic);
978# if DO_TIMING_TEST 1054# if DO_TIMING_TEST
979 XSync (dpy, False); 1055 XSync (dpy, False);
980# endif 1056# endif
981# endif 1057# endif
982 } 1058 }
983 } 1059 }
984 } /* server side rendering completed */ 1060 } /* server side rendering completed */
985 1061
989 pixmap = tiled_root_pmap; 1065 pixmap = tiled_root_pmap;
990 pmap_width = window_width; 1066 pmap_width = window_width;
991 pmap_height = window_height; 1067 pmap_height = window_height;
992 pmap_depth = root_depth; 1068 pmap_depth = root_depth;
993 } 1069 }
994 1070
995 if (gc) 1071 if (gc)
996 XFreeGC (dpy, gc); 1072 XFreeGC (dpy, gc);
997 1073
998 TIMING_TEST_PRINT_RESULT (tp); 1074 TIMING_TEST_PRINT_RESULT (tp);
999 1075
1000 return result; 1076 return result;
1001} 1077}
1002 1078
1003bool 1079bool
1004bgPixmap_t::set_root_pixmap () 1080bgPixmap_t::set_root_pixmap ()
1005{ 1081{
1006 Pixmap new_root_pixmap = None;
1007
1008 new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); 1082 Pixmap new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID);
1009 if (new_root_pixmap == None) 1083 if (new_root_pixmap == None)
1010 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); 1084 new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID);
1011 1085
1012 if (new_root_pixmap != root_pixmap) 1086 if (new_root_pixmap != root_pixmap)
1013 { 1087 {
1014 root_pixmap = new_root_pixmap; 1088 root_pixmap = new_root_pixmap;
1015 return true; 1089 return true;
1016 } 1090 }
1091
1017 return false; 1092 return false;
1018} 1093}
1019# endif /* ENABLE_TRANSPARENCY */ 1094# endif /* ENABLE_TRANSPARENCY */
1020 1095
1021# ifndef HAVE_AFTERIMAGE 1096# ifndef HAVE_AFTERIMAGE
1022static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); 1097static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm);
1023# endif 1098# endif
1024 1099
1025
1026bool 1100bool
1027bgPixmap_t::render () 1101bgPixmap_t::render ()
1028{ 1102{
1029 unsigned long background_flags = 0; 1103 unsigned long background_flags = 0;
1030 1104
1031 if (target == NULL) 1105 if (target == NULL)
1032 return false; 1106 return false;
1107
1108 TIMING_TEST_START (tp);
1033 1109
1034 invalidate(); 1110 invalidate();
1035# ifdef ENABLE_TRANSPARENCY 1111# ifdef ENABLE_TRANSPARENCY
1036 if (flags & isTransparent) 1112 if (flags & isTransparent)
1037 { 1113 {
1090 } 1166 }
1091 else if (background_flags && pmap_depth != target->depth) 1167 else if (background_flags && pmap_depth != target->depth)
1092 { 1168 {
1093 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1169 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1094 } 1170 }
1171
1095# else /* our own client-side tinting */ 1172# elif !XFT /* our own client-side tinting */
1173
1174 /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side.
1175 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1176
1096 if (background_flags && (flags & isInvalid)) 1177 if (background_flags && (flags & isInvalid))
1097 { 1178 {
1098 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1179 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1099 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1180 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded))
1100 { 1181 {
1104 ShadeXImage (target, result, shade, c.r, c.g, c.b); 1185 ShadeXImage (target, result, shade, c.r, c.g, c.b);
1105 } 1186 }
1106 } 1187 }
1107# endif /* HAVE_AFTERIMAGE */ 1188# endif /* HAVE_AFTERIMAGE */
1108 1189
1109 if (result != NULL) 1190 if (result)
1110 { 1191 {
1111 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1192 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1193
1112 if (gc) 1194 if (gc)
1113 { 1195 {
1114 if (/*pmap_depth != target->depth &&*/ pixmap != None) 1196 if (/*pmap_depth != target->depth &&*/ pixmap != None)
1115 { 1197 {
1116 XFreePixmap (target->dpy, pixmap); 1198 XFreePixmap (target->dpy, pixmap);
1117 pixmap = None; 1199 pixmap = None;
1118 } 1200 }
1201
1119 if (pixmap == None) 1202 if (pixmap == None)
1120 { 1203 {
1121 pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth); 1204 pixmap = XCreatePixmap (target->dpy, target->vt, result->width, result->height, target->depth);
1122 pmap_width = result->width; 1205 pmap_width = result->width;
1123 pmap_height = result->height; 1206 pmap_height = result->height;
1124 pmap_depth = target->depth; 1207 pmap_depth = target->depth;
1125 } 1208 }
1209
1126 if (pmap_depth != result->depth) 1210 if (pmap_depth != result->depth)
1211 {
1127 { /* Bad Match error will ensue ! stupid X !!!! */ 1212 /* Bad Match error will ensue ! stupid X !!!! */
1128 if( result->depth == 24 && pmap_depth == 32) 1213 if (result->depth == 24 && pmap_depth == 32)
1129 result->depth = 32; 1214 result->depth = 32;
1130 else if( result->depth == 32 && pmap_depth == 24) 1215 else if (result->depth == 32 && pmap_depth == 24)
1131 result->depth = 24; 1216 result->depth = 24;
1132 else 1217 else
1133 { 1218 {
1134 /* TODO: implement image recoding */ 1219 /* TODO: implement image recoding */
1135 } 1220 }
1136 } 1221 }
1222
1137 if (pmap_depth == result->depth) 1223 if (pmap_depth == result->depth)
1138 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); 1224 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
1225
1139 XFreeGC (target->dpy, gc); 1226 XFreeGC (target->dpy, gc);
1140 flags = flags & ~isInvalid; 1227 flags = flags & ~isInvalid;
1141 } 1228 }
1229
1142 XDestroyImage (result); 1230 XDestroyImage (result);
1143 } 1231 }
1144 1232
1145 if (flags & isInvalid) 1233 if (flags & isInvalid)
1146 { 1234 {
1151 } 1239 }
1152 } 1240 }
1153 1241
1154 apply (); 1242 apply ();
1155 1243
1244 XSync (target->dpy, False);
1245 valid_since = ev::now ();
1246
1247 TIMING_TEST_PRINT_RESULT (tp);
1248
1156 return true; 1249 return true;
1157} 1250}
1158 1251
1159bool 1252bool
1160bgPixmap_t::set_target (rxvt_term *new_target) 1253bgPixmap_t::set_target (rxvt_term *new_target)
1161{ 1254{
1162 if (new_target) 1255 if (new_target)
1163 if (target != new_target) 1256 if (target != new_target)
1164 { 1257 {
1170 } 1263 }
1171 return false; 1264 return false;
1172} 1265}
1173 1266
1174void 1267void
1175bgPixmap_t::apply() 1268bgPixmap_t::apply ()
1176{ 1269{
1177 if (target) 1270 if (target)
1178 { 1271 {
1179 flags &= ~isVtOrigin; 1272 flags &= ~isVtOrigin;
1180 if (pixmap != None) 1273 if (pixmap != None)
1274 {
1181 { /* set target's background to pixmap */ 1275 /* set target's background to pixmap */
1182# ifdef ENABLE_TRANSPARENCY 1276# ifdef ENABLE_TRANSPARENCY
1183 if (flags & isTransparent) 1277 if (flags & isTransparent)
1184 { 1278 {
1185 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); 1279 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap);
1186 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); 1280 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative);
1202 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1296 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1203# endif 1297# endif
1204 } 1298 }
1205 } 1299 }
1206 else 1300 else
1301 {
1207 { /* set target background to a pixel */ 1302 /* set target background to a pixel */
1208 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); 1303 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1209 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); 1304 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]);
1210 /* do we also need to set scrollbar's background here ? */ 1305 /* do we also need to set scrollbar's background here ? */
1211# if HAVE_SCROLLBARS 1306# if HAVE_SCROLLBARS
1212 if (target->scrollBar.win) 1307 if (target->scrollBar.win)
1213 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1308 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1214# endif 1309# endif
1215 } 1310 }
1216 1311 /* don't want Expose on the parent or vt. It is better to use
1217 /* don't want Expose on the parent */ 1312 scr_touch or we get a great deal of flicker otherwise: */
1218 XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); 1313 XClearWindow (target->dpy, target->parent[0]);
1219 /* do want Expose on the vt, so we get refreshed properly */
1220 XClearArea (target->dpy, target->vt, 0, 0, 0, 0, True);
1221 1314
1222# if HAVE_SCROLLBARS 1315# if HAVE_SCROLLBARS
1223 if (target->scrollBar.win) 1316 if (target->scrollBar.win)
1224 { 1317 {
1225 target->scrollBar.setIdle (); 1318 target->scrollBar.setIdle ();
1226 target->scrollbar_show (0); 1319 target->scrollbar_show (0);
1227 } 1320 }
1228# endif 1321# endif
1229 }
1230}
1231 1322
1323 target->want_refresh = 1;
1324 flags |= hasChanged;
1325 }
1326}
1327
1232#endif /* HAVE_BG_PIXMAP */ 1328#endif /* HAVE_BG_PIXMAP */
1233 1329
1234#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) 1330#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT
1235/* taken from aterm-0.4.2 */ 1331/* taken from aterm-0.4.2 */
1236 1332
1237typedef uint32_t RUINT32T; 1333typedef uint32_t RUINT32T;
1238 1334
1239static void 1335static void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines