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.26 by root, Wed Jan 23 11:10:27 2008 UTC vs.
Revision 1.63 by sf-exg, Sun Oct 3 21:44:39 2010 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) 2005-2006 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com>
7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> 7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net>
8 * 8 *
9 * 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
10 * 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
11 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
27#define DO_TIMING_TEST 0 27#define DO_TIMING_TEST 0
28 28
29#if DO_TIMING_TEST 29#if DO_TIMING_TEST
30# include <sys/time.h> 30# include <sys/time.h>
31#define TIMING_TEST_START(id) \ 31#define TIMING_TEST_START(id) \
32 struct timeval timing_test_##id##_stv;\ 32 struct timeval timing_test_##id##_stv; \
33 gettimeofday (&timing_test_##id##_stv, NULL); 33 gettimeofday (&timing_test_##id##_stv, NULL);
34 34
35#define TIMING_TEST_PRINT_RESULT(id) \ 35#define TIMING_TEST_PRINT_RESULT(id) \
36 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ 36 do { \
37 struct timeval tv; \
38 gettimeofday (&tv, NULL); \
39 tv.tv_sec -= (timing_test_##id##_stv).tv_sec; \
37 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ 40 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__, \
38 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) 41 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec); \
42 } while (0)
39 43
40#else 44#else
41#define TIMING_TEST_START(id) do{}while (0) 45#define TIMING_TEST_START(id) do {} while (0)
42#define TIMING_TEST_PRINT_RESULT(id) do{}while (0) 46#define TIMING_TEST_PRINT_RESULT(id) do {} while (0)
43#endif 47#endif
44 48
45/* 49/*
46 * Pixmap geometry string interpretation : 50 * Pixmap geometry string interpretation :
47 * Each geometry string contains zero or one scale/position 51 * Each geometry string contains zero or one scale/position
48 * adjustment and may optionally be followed by a colon and one or more 52 * adjustment and may optionally be followed by a colon and one or more
49 * colon-delimited pixmap operations. 53 * colon-delimited pixmap operations.
50 * The following table shows the valid geometry strings and their 54 * The following table shows the valid geometry strings and their
51 * affects on the background image : 55 * effects on the background image :
52 * 56 *
53 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. 57 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%.
54 * W and H are percentages of the terminal window size. 58 * W and H are percentages of the terminal window size.
55 * X and Y are also percentages; e.g., +50+50 centers 59 * X and Y are also percentages; e.g., +50+50 centers
56 * the image in the window. 60 * the image in the window.
57 * WxH+X Assumes Y == X 61 * WxH+X Assumes Y == X
58 * WxH Assumes Y == X == 50 (centers the image) 62 * WxH Assumes Y == X == 50 (centers the image)
59 * W+X+Y Assumes H == W 63 * W+X+Y Assumes H == W
60 * W+X Assumes H == W and Y == X 64 * W+X Assumes H == W and Y == X
61 * W Assumes H == W and Y == X == 50 65 * W Assumes H == W and Y == X == 50
62 * 66 *
63 * Adjusting position only : 67 * Adjusting position only :
64 * =+X+Y Set position to X% by Y% (absolute). 68 * =+X+Y Set position to X% by Y% (absolute).
65 * =+X Set position to X% by X%. 69 * =+X Set position to X% by X%.
66 * +X+Y Adjust position horizontally X% and vertically Y% 70 * +X+Y Adjust position horizontally X% and vertically Y%
67 * from current position (relative). 71 * from current position (relative).
68 * +X Adjust position horizontally X% and vertically X% 72 * +X Adjust position horizontally X% and vertically X%
69 * from current position. 73 * from current position.
70 * 74 *
71 * Adjusting scale only : 75 * Adjusting scale only :
72 * Wx0 Multiply horizontal scaling factor by W% 76 * Wx0 Multiply horizontal scaling factor by W%
73 * 0xH Multiply vertical scaling factor by H% 77 * 0xH Multiply vertical scaling factor by H%
74 * 0x0 No scaling (show image at normal size). 78 * 0x0 No scaling (show image at normal size).
75 * 79 *
76 * Pixmap Operations : (should be prepended by a colon) 80 * Pixmap Operations : (should be prepended by a colon)
77 * tile Tile image. Scaling/position modifiers above will affect 81 * tile Tile image. Scaling/position modifiers above will affect
78 * the tile size and origin. 82 * the tile size and origin.
79 * propscale When scaling, scale proportionally. That is, maintain the 83 * propscale When scaling, scale proportionally. That is, maintain the
80 * proper aspect ratio for the image. Any portion of the 84 * proper aspect ratio for the image. Any portion of the
81 * background not covered by the image is filled with the 85 * background not covered by the image is filled with the
82 * current background color. 86 * current background color.
83 * hscale Scale horizontally, tile vertically ? 87 * hscale Scale horizontally, tile vertically ?
84 * vscale Tile horizontally, scale vertically ? 88 * vscale Tile horizontally, scale vertically ?
92 // this is basically redundant as bgPixmap_t is only used in 96 // this is basically redundant as bgPixmap_t is only used in
93 // zero_initialised-derived structs 97 // zero_initialised-derived structs
94#ifdef HAVE_AFTERIMAGE 98#ifdef HAVE_AFTERIMAGE
95 original_asim = NULL; 99 original_asim = NULL;
96#endif 100#endif
101#ifdef HAVE_PIXBUF
102 pixbuf = NULL;
103#endif
97#ifdef BG_IMAGE_FROM_FILE 104#ifdef BG_IMAGE_FROM_FILE
105 have_image = false;
98 h_scale = v_scale = 0; 106 h_scale = v_scale = 0;
99 h_align = v_align = 0; 107 h_align = v_align = 0;
100#endif 108#endif
101 flags = 0; 109 flags = 0;
102 pixmap = None; 110 pixmap = None;
110#ifdef HAVE_AFTERIMAGE 118#ifdef HAVE_AFTERIMAGE
111 if (original_asim) 119 if (original_asim)
112 safe_asimage_destroy (original_asim); 120 safe_asimage_destroy (original_asim);
113#endif 121#endif
114 122
123#ifdef HAVE_PIXBUF
124 if (pixbuf)
125 g_object_unref (pixbuf);
126#endif
127
115 if (pixmap && target) 128 if (pixmap && target)
116 XFreePixmap (target->dpy, pixmap); 129 XFreePixmap (target->dpy, pixmap);
117} 130}
118 131
119bool 132bool
123 if (flags & isTransparent) 136 if (flags & isTransparent)
124 return true; 137 return true;
125# endif 138# endif
126 139
127# ifdef BG_IMAGE_FROM_FILE 140# ifdef BG_IMAGE_FROM_FILE
128# ifdef HAVE_AFTERIMAGE 141 if (have_image)
129 if (original_asim)
130# endif
131 { 142 {
132 if (h_scale != 0 || v_scale != 0 143 if (flags & sizeSensitive)
133 || h_align != 0 || v_align != 0)
134 return true; 144 return true;
135 } 145 }
136# endif 146# endif
137 147
138 return false; 148 return false;
139} 149}
140 150
141bool 151bool
142bgPixmap_t::window_position_sensitive () 152bgPixmap_t::window_position_sensitive ()
143{ 153{
144# ifdef ENABLE_TRANSPARENCY 154# ifdef ENABLE_TRANSPARENCY
145 if (flags & isTransparent) 155 if (flags & isTransparent)
146 return true; 156 return true;
147# endif 157# endif
148 158
149# ifdef BG_IMAGE_FROM_FILE 159# ifdef BG_IMAGE_FROM_FILE
150# ifdef HAVE_AFTERIMAGE 160 if (have_image)
151 if (original_asim)
152# endif
153 { 161 {
154 if (h_align == rootAlign || v_align == rootAlign) 162 if (flags & rootAlign)
155 return true; 163 return true;
156 } 164 }
157# endif 165# endif
158 166
159 return false; 167 return false;
199static inline bool 207static inline bool
200check_set_align_value (int geom_flags, int flag, int &align, int new_value) 208check_set_align_value (int geom_flags, int flag, int &align, int new_value)
201{ 209{
202 if (geom_flags & flag) 210 if (geom_flags & flag)
203 { 211 {
204 if (new_value != bgPixmap_t::rootAlign)
205 {
206 if (new_value < -100) 212 if (new_value < -100)
207 new_value = -100; 213 new_value = -100;
208 else if (new_value > 200) 214 else if (new_value > 200)
209 new_value = 200; 215 new_value = 200;
210 }
211 if (new_value != align) 216 if (new_value != align)
212 { 217 {
213 align = new_value; 218 align = new_value;
214 return true; 219 return true;
215 } 220 }
219 224
220static inline int 225static inline int
221make_align_position (int align, int window_size, int image_size) 226make_align_position (int align, int window_size, int image_size)
222{ 227{
223 int diff = window_size - image_size; 228 int diff = window_size - image_size;
224 int smaller = MIN (image_size,window_size); 229 int smaller = min (image_size, window_size);
225 230
226 if (align >= 0 && align <= 50) 231 if (align >= 0 && align <= 50)
227 return diff * align / 100; 232 return diff * align / 100;
228 else if (align > 50 && align <= 100) 233 else if (align > 50 && align <= 100)
229 return window_size - image_size - diff * (100 - align) / 100; 234 return window_size - image_size - diff * (100 - align) / 100;
238make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size) 243make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size)
239{ 244{
240 int src_pos = 0; 245 int src_pos = 0;
241 dst_pos = 0; 246 dst_pos = 0;
242 dst_size = size; 247 dst_size = size;
243 if (pos < 0 && size > target_size) 248 if (pos < 0)
244 { 249 {
245 src_pos = -pos; 250 src_pos = -pos;
246 dst_size += pos; 251 dst_size += pos;
247 } 252 }
248 else if (pos > 0) 253 else if (pos > 0)
259 int geom_flags = 0, changed = 0; 264 int geom_flags = 0, changed = 0;
260 int x = 0, y = 0; 265 int x = 0, y = 0;
261 unsigned int w = 0, h = 0; 266 unsigned int w = 0, h = 0;
262 unsigned int n; 267 unsigned int n;
263 unsigned long new_flags = (flags & (~geometryFlags)); 268 unsigned long new_flags = (flags & (~geometryFlags));
264 char *p; 269 const char *p;
265# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ 270# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */
266 271
267 if (geom == NULL) 272 if (geom == NULL)
268 return false; 273 return false;
269 274
379 w = h = noScale; 384 w = h = noScale;
380 geom_flags |= WidthValue|HeightValue; 385 geom_flags |= WidthValue|HeightValue;
381 } 386 }
382 else if (CHECK_GEOM_OPS ("propscale")) 387 else if (CHECK_GEOM_OPS ("propscale"))
383 { 388 {
384 if (w == 0 && h == 0)
385 {
386 w = windowScale;
387 geom_flags |= WidthValue;
388 }
389 new_flags |= propScale; 389 new_flags |= propScale;
390 } 390 }
391 else if (CHECK_GEOM_OPS ("hscale")) 391 else if (CHECK_GEOM_OPS ("hscale"))
392 { 392 {
393 if (w == 0) w = windowScale; 393 if (w == 0) w = windowScale;
415 x = y = centerAlign; 415 x = y = centerAlign;
416 geom_flags |= WidthValue|HeightValue|XValue|YValue; 416 geom_flags |= WidthValue|HeightValue|XValue|YValue;
417 } 417 }
418 else if (CHECK_GEOM_OPS ("root")) 418 else if (CHECK_GEOM_OPS ("root"))
419 { 419 {
420 new_flags |= rootAlign;
420 w = h = noScale; 421 w = h = noScale;
421 x = y = rootAlign;
422 geom_flags |= WidthValue|HeightValue|XValue|YValue; 422 geom_flags |= WidthValue|HeightValue;
423 } 423 }
424# undef CHECK_GEOM_OPS 424# undef CHECK_GEOM_OPS
425 425
426 while (*ops != ':' && *ops != '\0') ++ops; 426 while (*ops != ':' && *ops != '\0') ++ops;
427 } /* done parsing ops */ 427 } /* done parsing ops */
437 { 437 {
438 flags = new_flags; 438 flags = new_flags;
439 changed++; 439 changed++;
440 } 440 }
441 441
442//fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", 442 //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n",
443// flags, h_scale, v_scale, h_align, v_align); 443 // flags, h_scale, v_scale, h_align, v_align);
444 return (changed > 0); 444 return (changed > 0);
445}
446
447void
448bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y)
449{
450 int target_width = target->szHint.width;
451 int target_height = target->szHint.height;
452
453 if (flags & propScale)
454 {
455 float scale = (float)target_width / image_width;
456 min_it (scale, (float)target_height / image_height);
457 w = image_width * scale + 0.5;
458 h = image_height * scale + 0.5;
459 }
460 else
461 {
462 w = h_scale * target_width / 100;
463 h = v_scale * target_height / 100;
464 }
465
466 if (flags & rootAlign)
467 {
468 target->get_window_origin (x, y);
469 x = -x;
470 y = -y;
471 }
472 else
473 {
474 x = make_align_position (h_align, target_width, w > 0 ? w : image_width);
475 y = make_align_position (v_align, target_height, h > 0 ? h : image_height);
476 }
477
478 flags &= ~sizeSensitive;
479 if (h_scale != 0 || v_scale != 0
480 || h_align != 0 || v_align != 0
481 || image_width > target_width || image_height > target_height)
482 flags |= sizeSensitive;
445} 483}
446 484
447# ifdef HAVE_AFTERIMAGE 485# ifdef HAVE_AFTERIMAGE
448bool 486bool
449bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) 487bgPixmap_t::render_image (unsigned long background_flags)
450{ 488{
451 if (target == NULL) 489 if (target == NULL)
452 return false; 490 return false;
453 491
492 target->init_asv ();
493
494 ASImage *background = NULL;
495 ARGB32 background_tint = TINT_LEAVE_SAME;
496
497# ifdef ENABLE_TRANSPARENCY
498 if (background_flags)
499 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
500
501 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
502 {
503 ShadingInfo as_shade;
504 as_shade.shading = (shade == 0) ? 100 : shade;
505
506 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
507 if (flags & tintSet)
508 tint.get (c);
509 as_shade.tintColor.red = c.r;
510 as_shade.tintColor.green = c.g;
511 as_shade.tintColor.blue = c.b;
512
513 background_tint = shading2tint32 (&as_shade);
514 }
515
516 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL)
517 {
518 ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF,
519 (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage,
520 100, ASIMAGE_QUALITY_DEFAULT);
521 if (tmp)
522 {
523 destroy_asimage (&background);
524 background = tmp;
525 }
526 }
527# endif
528
529 ASImage *result = 0;
530
454 int target_width = (int)target->szHint.width; 531 int target_width = target->szHint.width;
455 int target_height = (int)target->szHint.height; 532 int target_height = target->szHint.height;
456 int new_pmap_width = target_width, new_pmap_height = target_height; 533 int new_pmap_width = target_width;
457 ASImage *result = NULL; 534 int new_pmap_height = target_height;
458 535
459 int x = 0; 536 int x = 0;
460 int y = 0; 537 int y = 0;
461 int w = h_scale * target_width / 100; 538 int w = 0;
462 int h = v_scale * target_height / 100; 539 int h = 0;
463 540
464 TIMING_TEST_START (asim); 541 TIMING_TEST_START (asim);
465 542
466 if (original_asim) 543 if (original_asim)
467 { 544 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y);
468 if (h_align == rootAlign || v_align == rootAlign)
469 {
470 target->get_window_origin(x, y);
471 x = -x;
472 y = -y;
473 }
474
475 if (h_align != rootAlign)
476 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width);
477
478 if (v_align != rootAlign)
479 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height);
480 }
481 545
482 if (!original_asim 546 if (!original_asim
483 || x >= target_width 547 || x >= target_width
484 || y >= target_height 548 || y >= target_height
485 || (w > 0 && x + w <= 0) 549 || (w > 0 && x + w <= 0)
491 new_pmap_height = background->height; 555 new_pmap_height = background->height;
492 result = background; 556 result = background;
493 557
494 if (background_tint != TINT_LEAVE_SAME) 558 if (background_tint != TINT_LEAVE_SAME)
495 { 559 {
496 ASImage* tmp = tile_asimage (target->asv, background, 0, 0, 560 ASImage *tmp = tile_asimage (target->asv, background, 0, 0,
497 target_width, target_height, background_tint, 561 target_width, target_height, background_tint,
498 ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); 562 ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT);
499 if (tmp) 563 if (tmp)
500 result = tmp; 564 result = tmp;
501 } 565 }
517 100, ASIMAGE_QUALITY_DEFAULT); 581 100, ASIMAGE_QUALITY_DEFAULT);
518 } 582 }
519 583
520 if (background == NULL) 584 if (background == NULL)
521 { 585 {
522 /* if tiling - pixmap has to be sized exactly as the image,
523 but there is no need to make it bigger than the window! */
524 if (h_scale == 0)
525 new_pmap_width = min (result->width, target_width);
526 if (v_scale == 0)
527 new_pmap_height = min (result->height, target_height);
528 /* we also need to tile our image in one or both directions */
529 if (h_scale == 0 || v_scale == 0) 586 if (h_scale == 0 || v_scale == 0)
530 { 587 {
588 /* if tiling - pixmap has to be sized exactly as the image,
589 but there is no need to make it bigger than the window! */
590 new_pmap_width = min (result->width, target_width);
591 new_pmap_height = min (result->height, target_height);
592
593 /* we also need to tile our image in both directions */
531 ASImage *tmp = tile_asimage (target->asv, result, 594 ASImage *tmp = tile_asimage (target->asv, result,
532 (h_scale > 0) ? 0 : (int)result->width - x, 595 (int)result->width - x,
533 (v_scale > 0) ? 0 : (int)result->height - y, 596 (int)result->height - y,
534 new_pmap_width, 597 new_pmap_width,
535 new_pmap_height, 598 new_pmap_height,
536 TINT_LEAVE_SAME, ASA_XImage, 599 TINT_LEAVE_SAME, ASA_XImage,
537 100, ASIMAGE_QUALITY_DEFAULT); 600 100, ASIMAGE_QUALITY_DEFAULT);
538 if (tmp) 601 if (tmp)
539 { 602 {
546 } 609 }
547 else 610 else
548 { 611 {
549 /* if blending background and image - pixmap has to be sized same as target window */ 612 /* if blending background and image - pixmap has to be sized same as target window */
550 ASImageLayer *layers = create_image_layers (2); 613 ASImageLayer *layers = create_image_layers (2);
551 ASImage *merged_im = NULL;
552 614
553 layers[0].im = background; 615 layers[0].im = background;
554 layers[0].clip_width = target_width; 616 layers[0].clip_width = target_width;
555 layers[0].clip_height = target_height; 617 layers[0].clip_height = target_height;
556 layers[0].tint = background_tint; 618 layers[0].tint = background_tint;
603 free (layers); 665 free (layers);
604 } 666 }
605 } 667 }
606 TIMING_TEST_PRINT_RESULT (asim); 668 TIMING_TEST_PRINT_RESULT (asim);
607 669
608 if (pixmap) 670 bool ret = false;
609 {
610 if (result == NULL
611 || pmap_width != new_pmap_width
612 || pmap_height != new_pmap_height
613 || pmap_depth != target->depth)
614 {
615 XFreePixmap (target->dpy, pixmap);
616 pixmap = None;
617 }
618 }
619 671
620 if (result) 672 if (result)
621 { 673 {
622 XGCValues gcv; 674 XGCValues gcv;
623 GC gc; 675 GC gc;
676
677 if (pixmap)
678 {
679 if (pmap_width != new_pmap_width
680 || pmap_height != new_pmap_height
681 || pmap_depth != target->depth)
682 {
683 XFreePixmap (target->dpy, pixmap);
684 pixmap = None;
685 }
686 }
624 687
625 /* create Pixmap */ 688 /* create Pixmap */
626 if (pixmap == None) 689 if (pixmap == None)
627 { 690 {
628 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 691 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
629 pmap_width = new_pmap_width; 692 pmap_width = new_pmap_width;
630 pmap_height = new_pmap_height; 693 pmap_height = new_pmap_height;
631 pmap_depth = target->depth; 694 pmap_depth = target->depth;
632 } 695 }
633 /* fill with background color ( if result's not completely overlapping it)*/ 696 /* fill with background color (if result's not completely overlapping it) */
634 gcv.foreground = target->pix_colors[Color_bg]; 697 gcv.foreground = target->pix_colors[Color_bg];
635 gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); 698 gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv);
636 699
637 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; 700 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0;
638 int dst_width = result->width, dst_height = result->height; 701 int dst_width = result->width, dst_height = result->height;
639 if (background == NULL) 702 if (background == NULL)
640 { 703 {
704 if (!(h_scale == 0 || v_scale == 0))
705 {
641 if (h_scale > 0) src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); 706 src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width );
642 if (v_scale > 0) src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); 707 src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height);
708 }
643 709
644 if (dst_x > 0 || dst_y > 0 710 if (dst_x > 0 || dst_y > 0
645 || dst_x + dst_width < new_pmap_width 711 || dst_x + dst_width < new_pmap_width
646 || dst_y + dst_height < new_pmap_height) 712 || dst_y + dst_height < new_pmap_height)
647 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 713 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
654 if (result != background && result != original_asim) 720 if (result != background && result != original_asim)
655 destroy_asimage (&result); 721 destroy_asimage (&result);
656 722
657 XFreeGC (target->dpy, gc); 723 XFreeGC (target->dpy, gc);
658 TIMING_TEST_PRINT_RESULT (asim); 724 TIMING_TEST_PRINT_RESULT (asim);
659 }
660 725
726 ret = true;
727 }
728
729 if (background)
730 destroy_asimage (&background);
731
661 return true; 732 return ret;
662} 733}
663# endif /* HAVE_AFTERIMAGE */ 734# endif /* HAVE_AFTERIMAGE */
735
736# ifdef HAVE_PIXBUF
737bool
738bgPixmap_t::render_image (unsigned long background_flags)
739{
740 if (target == NULL)
741 return false;
742
743 if (!pixbuf)
744 return false;
745
746 // TODO: add alpha blending
747 if (background_flags)
748 return false;
749
750 GdkPixbuf *result;
751
752 int image_width = gdk_pixbuf_get_width (pixbuf);
753 int image_height = gdk_pixbuf_get_height (pixbuf);
754
755 int target_width = target->szHint.width;
756 int target_height = target->szHint.height;
757 int new_pmap_width = target_width;
758 int new_pmap_height = target_height;
759
760 int x = 0;
761 int y = 0;
762 int w = 0;
763 int h = 0;
764
765 get_image_geometry (image_width, image_height, w, h, x, y);
766
767 if (x >= target_width
768 || y >= target_height
769 || (w > 0 && x + w <= 0)
770 || (h > 0 && y + h <= 0))
771 return false;
772
773 result = pixbuf;
774
775 if ((w > 0 && w != image_width)
776 || (h > 0 && h != image_height))
777 {
778 result = gdk_pixbuf_scale_simple (pixbuf,
779 w > 0 ? w : image_width,
780 h > 0 ? h : image_height,
781 GDK_INTERP_BILINEAR);
782 }
783
784 bool ret = false;
785
786 if (result)
787 {
788 XGCValues gcv;
789 GC gc;
790
791 image_width = gdk_pixbuf_get_width (result);
792 image_height = gdk_pixbuf_get_height (result);
793
794 if (h_scale == 0 || v_scale == 0)
795 {
796 new_pmap_width = min (image_width, target_width);
797 new_pmap_height = min (image_height, target_height);
798 }
799
800 if (pixmap)
801 {
802 if (pmap_width != new_pmap_width
803 || pmap_height != new_pmap_height
804 || pmap_depth != target->depth)
805 {
806 XFreePixmap (target->dpy, pixmap);
807 pixmap = None;
808 }
809 }
810
811 if (pixmap == None)
812 {
813 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
814 pmap_width = new_pmap_width;
815 pmap_height = new_pmap_height;
816 pmap_depth = target->depth;
817 }
818
819 gcv.foreground = target->pix_colors[Color_bg];
820 gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv);
821
822 if (h_scale == 0 || v_scale == 0)
823 {
824 Pixmap tile = XCreatePixmap (target->dpy, target->vt, image_width, image_height, target->depth);
825 gdk_pixbuf_xlib_render_to_drawable (result, tile, gc,
826 0, 0,
827 0, 0,
828 image_width, image_height,
829 XLIB_RGB_DITHER_NONE,
830 0, 0);
831
832 gcv.tile = tile;
833 gcv.fill_style = FillTiled;
834 gcv.ts_x_origin = x;
835 gcv.ts_y_origin = y;
836 XChangeGC (target->dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
837
838 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
839 XFreePixmap (target->dpy, tile);
840 }
841 else
842 {
843 int src_x, src_y, dst_x, dst_y;
844 int dst_width, dst_height;
845
846 src_x = make_clip_rectangle (x, image_width , new_pmap_width , dst_x, dst_width );
847 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height);
848
849 if (dst_x > 0 || dst_y > 0
850 || dst_x + dst_width < new_pmap_width
851 || dst_y + dst_height < new_pmap_height)
852 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
853
854 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
855 gdk_pixbuf_xlib_render_to_drawable (result, pixmap, gc,
856 src_x, src_y,
857 dst_x, dst_y,
858 dst_width, dst_height,
859 XLIB_RGB_DITHER_NONE,
860 0, 0);
861 }
862
863 if (result != pixbuf)
864 g_object_unref (result);
865
866 XFreeGC (target->dpy, gc);
867
868 ret = true;
869 }
870
871 return ret;
872}
873# endif /* HAVE_PIXBUF */
664 874
665bool 875bool
666bgPixmap_t::set_file (const char *file) 876bgPixmap_t::set_file (const char *file)
667{ 877{
668 char *f;
669
670 assert (file); 878 assert (file);
671 879
672 if (*file) 880 if (*file)
673 { 881 {
674# ifdef HAVE_AFTERIMAGE 882 if (const char *p = strchr (file, ';'))
675 if (target->asimman == NULL)
676 target->asimman = create_generic_imageman (target->rs[Rs_path]);
677
678 if ((f = strchr (file, ';')) == NULL)
679 original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100);
680 else
681 { 883 {
682 size_t len = f - file; 884 size_t len = p - file;
683 f = (char *)malloc (len + 1); 885 char *f = rxvt_temp_buf<char> (len + 1);
684 memcpy (f, file, len); 886 memcpy (f, file, len);
685 f[len] = '\0'; 887 f[len] = '\0';
888 file = f;
889 }
890
891# ifdef HAVE_AFTERIMAGE
892 if (!target->asimman)
893 target->asimman = create_generic_imageman (target->rs[Rs_path]);
686 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); 894 original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100);
687 free (f); 895 if (original_asim)
688 } 896 have_image = true;
897 return have_image;
898# endif
689 899
690 return original_asim; 900# ifdef HAVE_PIXBUF
901 pixbuf = gdk_pixbuf_new_from_file (file, NULL);
902 if (pixbuf)
903 have_image = true;
904 return have_image;
691# endif 905# endif
692 } 906 }
693 907
694 return false; 908 return false;
695} 909}
715 int changed = 0; 929 int changed = 0;
716 unsigned int hr, vr; 930 unsigned int hr, vr;
717 int junk; 931 int junk;
718 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); 932 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr);
719 933
720 if (!(geom_flags&WidthValue)) 934 if (!(geom_flags & WidthValue))
721 hr = 1; 935 hr = 1;
722 if (!(geom_flags&HeightValue)) 936 if (!(geom_flags & HeightValue))
723 vr = hr; 937 vr = hr;
724 938
725 if (h_blurRadius != hr) 939 if (h_blurRadius != hr)
726 { 940 {
727 ++changed; 941 ++changed;
737 if (v_blurRadius == 0 && h_blurRadius == 0) 951 if (v_blurRadius == 0 && h_blurRadius == 0)
738 flags &= ~blurNeeded; 952 flags &= ~blurNeeded;
739 else 953 else
740 flags |= blurNeeded; 954 flags |= blurNeeded;
741 955
742 return (changed>0); 956 return (changed > 0);
743} 957}
744 958
745static inline unsigned long 959static inline unsigned long
746compute_tint_shade_flags (rxvt_color *tint, int shade) 960compute_tint_shade_flags (rxvt_color *tint, int shade)
747{ 961{
764 flags |= bgPixmap_t::tintNeeded; 978 flags |= bgPixmap_t::tintNeeded;
765 else if (tint) 979 else if (tint)
766 { 980 {
767 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) 981 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700)
768 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) 982 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700))
769 { 983 {
770 flags |= bgPixmap_t::tintNeeded; 984 flags |= bgPixmap_t::tintNeeded;
771 } 985 }
772 } 986 }
773 987
774 if (flags & bgPixmap_t::tintNeeded) 988 if (flags & bgPixmap_t::tintNeeded)
775 { 989 {
776 if (flags & bgPixmap_t::tintWholesome) 990 if (flags & bgPixmap_t::tintWholesome)
805{ 1019{
806 unsigned long new_flags = compute_tint_shade_flags (NULL, shade); 1020 unsigned long new_flags = compute_tint_shade_flags (NULL, shade);
807 1021
808 if (new_flags != (flags & tintFlags)) 1022 if (new_flags != (flags & tintFlags))
809 { 1023 {
810 flags = (flags&~tintFlags)|new_flags; 1024 flags = (flags & ~tintFlags) | new_flags;
811 return true; 1025 return true;
812 } 1026 }
813 1027
814 return false; 1028 return false;
815} 1029}
816 1030
846 unsigned long result = 0; 1060 unsigned long result = 0;
847 1061
848 if (target == NULL) 1062 if (target == NULL)
849 return 0; 1063 return 0;
850 1064
851 /* root dimentions may change from call to call - but Display structure should 1065 /* root dimensions may change from call to call - but Display structure should
852 * be always up-to-date, so let's use it : 1066 * be always up-to-date, so let's use it :
853 */ 1067 */
854 Window root = target->display->root; 1068 Window root = target->display->root;
855 int screen = target->display->screen; 1069 int screen = target->display->screen;
856 Display *dpy = target->dpy; 1070 Display *dpy = target->dpy;
901 1115
902 attr.background_pixmap = ParentRelative; 1116 attr.background_pixmap = ParentRelative;
903 attr.backing_store = Always; 1117 attr.backing_store = Always;
904 attr.event_mask = ExposureMask; 1118 attr.event_mask = ExposureMask;
905 attr.override_redirect = True; 1119 attr.override_redirect = True;
906 src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, 1120 src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0,
907 CopyFromParent, CopyFromParent, CopyFromParent, 1121 CopyFromParent, CopyFromParent, CopyFromParent,
908 CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, 1122 CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask,
909 &attr); 1123 &attr);
910 1124
911 if (src != None) 1125 if (src != None)
935 XDestroyWindow (dpy, src); 1149 XDestroyWindow (dpy, src);
936 XUngrabServer (dpy); 1150 XUngrabServer (dpy);
937 //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); 1151 //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count);
938 } 1152 }
939 1153
940 if (!success) 1154 if (!success)
941 { 1155 {
942 XFreePixmap (dpy, tiled_root_pmap); 1156 XFreePixmap (dpy, tiled_root_pmap);
943 tiled_root_pmap = None; 1157 tiled_root_pmap = None;
944 } 1158 }
945 else 1159 else
946 result |= transpPmapTiled; 1160 result |= transpPmapTiled;
947 } 1161 }
948 else 1162 else
949 { 1163 {
950 /* strightforward pixmap copy */ 1164 /* straightforward pixmap copy */
951 gcv.tile = root_pixmap; 1165 gcv.tile = root_pixmap;
952 gcv.fill_style = FillTiled; 1166 gcv.fill_style = FillTiled;
953 1167
954 while (sx < 0) sx += (int)root_width; 1168 while (sx < 0) sx += (int)root_width;
955 while (sy < 0) sy += (int)root_height; 1169 while (sy < 0) sy += (int)root_height;
1068# if DO_TIMING_TEST 1282# if DO_TIMING_TEST
1069 XSync (dpy, False); 1283 XSync (dpy, False);
1070# endif 1284# endif
1071# endif 1285# endif
1072 } 1286 }
1073 } 1287 }
1074 } /* server side rendering completed */ 1288 } /* server side rendering completed */
1075 1289
1076 if (pixmap) 1290 if (pixmap)
1077 XFreePixmap (dpy, pixmap); 1291 XFreePixmap (dpy, pixmap);
1078 1292
1106 return false; 1320 return false;
1107} 1321}
1108# endif /* ENABLE_TRANSPARENCY */ 1322# endif /* ENABLE_TRANSPARENCY */
1109 1323
1110# ifndef HAVE_AFTERIMAGE 1324# ifndef HAVE_AFTERIMAGE
1111static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); 1325static void ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm);
1112# endif 1326# endif
1113 1327
1114bool 1328bool
1115bgPixmap_t::render () 1329bgPixmap_t::render ()
1116{ 1330{
1119 if (target == NULL) 1333 if (target == NULL)
1120 return false; 1334 return false;
1121 1335
1122 TIMING_TEST_START (tp); 1336 TIMING_TEST_START (tp);
1123 1337
1124 invalidate(); 1338 invalidate ();
1125# ifdef ENABLE_TRANSPARENCY 1339# ifdef ENABLE_TRANSPARENCY
1126 if (flags & isTransparent) 1340 if (flags & isTransparent)
1127 { 1341 {
1128 /* we need to re-generate transparency pixmap in that case ! */ 1342 /* we need to re-generate transparency pixmap in that case ! */
1129 background_flags = make_transparency_pixmap (); 1343 background_flags = make_transparency_pixmap ();
1130 if (background_flags == 0) 1344 if (background_flags == 0)
1131 return false; 1345 return false;
1132 else if ((background_flags & transpTransformations) == (flags & transpTransformations) 1346 else if ((background_flags & transpTransformations) == (flags & transpTransformations)
1133 && pmap_depth == target->depth) 1347 && pmap_depth == target->depth)
1134 flags = flags & ~isInvalid; 1348 flags = flags & ~isInvalid;
1135 } 1349 }
1136# endif 1350# endif
1137 1351
1352# ifdef BG_IMAGE_FROM_FILE
1353 if (have_image
1354 || (background_flags & transpTransformations) != (flags & transpTransformations))
1355 {
1356 if (render_image (background_flags))
1357 flags = flags & ~isInvalid;
1358 }
1359# endif
1360
1138 XImage *result = NULL; 1361 XImage *result = NULL;
1139# ifdef HAVE_AFTERIMAGE 1362
1140 if (original_asim 1363 if (background_flags && (flags & isInvalid))
1141 || (background_flags & transpTransformations) != (flags & transpTransformations)) 1364 {
1365 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1142 { 1366 }
1143 ASImage *background = NULL;
1144 ARGB32 as_tint = TINT_LEAVE_SAME;
1145 if (background_flags)
1146 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
1147 1367
1148# ifdef ENABLE_TRANSPARENCY 1368 if (result)
1369 {
1370# if !defined(HAVE_AFTERIMAGE) && !XFT
1371 /* our own client-side tinting */
1372 /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side.
1373 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1149 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1374 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
1150 {
1151 ShadingInfo as_shade;
1152 as_shade.shading = (shade == 0) ? 100 : shade;
1153
1154 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1155 if (flags & tintSet)
1156 tint.get (c);
1157 as_shade.tintColor.red = c.r;
1158 as_shade.tintColor.green = c.g;
1159 as_shade.tintColor.blue = c.b;
1160
1161 as_tint = shading2tint32 (&as_shade);
1162 }
1163 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL)
1164 {
1165 ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF,
1166 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage,
1167 100, ASIMAGE_QUALITY_DEFAULT);
1168 if (tmp)
1169 {
1170 destroy_asimage (&background);
1171 background = tmp;
1172 }
1173 }
1174# endif
1175
1176 if (render_asim (background, as_tint))
1177 flags = flags & ~isInvalid;
1178 if (background)
1179 destroy_asimage (&background);
1180 }
1181 else if (background_flags && pmap_depth != target->depth)
1182 {
1183 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1184 }
1185
1186# elif !XFT /* our own client-side tinting */
1187
1188 /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side.
1189 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1190
1191 if (background_flags && (flags & isInvalid))
1192 {
1193 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1194 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded))
1195 { 1375 {
1196 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1376 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1197 if (flags & tintSet) 1377 if (flags & tintSet)
1198 tint.get (c); 1378 tint.get (c);
1199 ShadeXImage (target, result, shade, c.r, c.g, c.b); 1379 ShadeXImage (target, result, shade, c.r, c.g, c.b);
1200 } 1380 }
1201 } 1381# endif
1202# endif /* HAVE_AFTERIMAGE */
1203 1382
1204 if (result)
1205 {
1206 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1383 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1207 1384
1208 if (gc) 1385 if (gc)
1209 { 1386 {
1210 if (/*pmap_depth != target->depth &&*/ pixmap != None) 1387 if (/*pmap_depth != target->depth &&*/ pixmap != None)
1239 1416
1240 XFreeGC (target->dpy, gc); 1417 XFreeGC (target->dpy, gc);
1241 flags = flags & ~isInvalid; 1418 flags = flags & ~isInvalid;
1242 } 1419 }
1243 1420
1244 XDestroyImage (result); 1421 XDestroyImage (result);
1245 } 1422 }
1246 1423
1247 if (flags & isInvalid) 1424 if (flags & isInvalid)
1248 { 1425 {
1249 if (pixmap != None) 1426 if (pixmap != None)
1273# ifdef ENABLE_TRANSPARENCY 1450# ifdef ENABLE_TRANSPARENCY
1274 root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); 1451 root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen));
1275# endif 1452# endif
1276 return true; 1453 return true;
1277 } 1454 }
1455
1278 return false; 1456 return false;
1279} 1457}
1280 1458
1281void 1459void
1282bgPixmap_t::apply () 1460bgPixmap_t::apply ()
1283{ 1461{
1284 if (target) 1462 if (target)
1285 { 1463 {
1286 flags &= ~isVtOrigin; 1464 flags &= ~isVtOrigin;
1465
1287 if (pixmap != None) 1466 if (pixmap != None)
1288 { 1467 {
1289 /* set target's background to pixmap */ 1468 /* set target's background to pixmap */
1290# ifdef ENABLE_TRANSPARENCY 1469# ifdef ENABLE_TRANSPARENCY
1291 if (flags & isTransparent) 1470 if (flags & isTransparent)
1292 { 1471 {
1293 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); 1472 XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap);
1294 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); 1473 XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative);
1295# if HAVE_SCROLLBARS 1474
1296 if (target->scrollBar.win) 1475 if (target->scrollBar.win)
1297 XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); 1476 XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative);
1298# endif
1299 } 1477 }
1300 else 1478 else
1301# endif 1479# endif
1302 { 1480 {
1303 flags |= isVtOrigin; 1481 flags |= isVtOrigin;
1304 /* force old pixmap dereference in case it was transparent before :*/ 1482 /* force old pixmap dereference in case it was transparent before :*/
1305 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); 1483 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1306 XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); 1484 XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap);
1307 /* do we also need to set scrollbar's background here ? */ 1485 /* do we also need to set scrollbar's background here ? */
1308# if HAVE_SCROLLBARS 1486
1309 if (target->scrollBar.win) 1487 if (target->scrollBar.win)
1310 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1488 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1311# endif
1312 } 1489 }
1313 } 1490 }
1314 else 1491 else
1315 { 1492 {
1316 /* set target background to a pixel */ 1493 /* set target background to a pixel */
1317 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); 1494 XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]);
1318 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); 1495 XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]);
1319 /* do we also need to set scrollbar's background here ? */ 1496 /* do we also need to set scrollbar's background here ? */
1320# if HAVE_SCROLLBARS
1321 if (target->scrollBar.win) 1497 if (target->scrollBar.win)
1322 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); 1498 XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]);
1323# endif
1324 } 1499 }
1500
1325 /* don't want Expose on the parent or vt. It is better to use 1501 /* don't want Expose on the parent or vt. It is better to use
1326 scr_touch or we get a great deal of flicker otherwise: */ 1502 scr_touch or we get a great deal of flicker otherwise: */
1327 XClearWindow (target->dpy, target->parent[0]); 1503 XClearWindow (target->dpy, target->parent[0]);
1328 1504
1329# if HAVE_SCROLLBARS 1505 if (target->scrollBar.state && target->scrollBar.win)
1330 if (target->scrollBar.win)
1331 { 1506 {
1332 target->scrollBar.setIdle (); 1507 target->scrollBar.state = STATE_IDLE;
1333 target->scrollbar_show (0); 1508 target->scrollBar.show (0);
1334 } 1509 }
1335# endif
1336 1510
1337 target->want_refresh = 1; 1511 target->want_refresh = 1;
1338 flags |= hasChanged; 1512 flags |= hasChanged;
1339 } 1513 }
1340} 1514}
1345/* taken from aterm-0.4.2 */ 1519/* taken from aterm-0.4.2 */
1346 1520
1347typedef uint32_t RUINT32T; 1521typedef uint32_t RUINT32T;
1348 1522
1349static void 1523static void
1350ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) 1524ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm)
1351{ 1525{
1352 int sh_r, sh_g, sh_b; 1526 int sh_r, sh_g, sh_b;
1353 RUINT32T mask_r, mask_g, mask_b; 1527 RUINT32T mask_r, mask_g, mask_b;
1354 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; 1528 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
1355 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 1529 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines