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.140 by sf-exg, Sun Jan 23 12:28:47 2011 UTC vs.
Revision 1.144 by sf-exg, Fri Jan 28 00:20:47 2011 UTC

59 * scale Scale both up and down 59 * scale Scale both up and down
60 * auto Same as 100x100+50+50 60 * auto Same as 100x100+50+50
61 */ 61 */
62 62
63#ifdef HAVE_BG_PIXMAP 63#ifdef HAVE_BG_PIXMAP
64bgPixmap_t::bgPixmap_t ()
65{
66 // this is basically redundant as bgPixmap_t is only used in
67 // zero_initialised-derived structs
68#ifdef HAVE_AFTERIMAGE
69 original_asim = NULL;
70#endif
71#ifdef HAVE_PIXBUF
72 pixbuf = NULL;
73#endif
74#ifdef BG_IMAGE_FROM_FILE
75 have_image = false;
76 h_scale = v_scale = 0;
77 h_align = v_align = 0;
78#endif
79#ifdef ENABLE_TRANSPARENCY
80 shade = 100;
81#endif
82 flags = 0;
83 pixmap = None;
84 valid_since = 0;
85 target = 0;
86 target_x = target_y = 0;
87}
88
89void 64void
90bgPixmap_t::destroy () 65rxvt_term::bg_destroy ()
91{ 66{
92#ifdef HAVE_AFTERIMAGE 67#ifdef HAVE_AFTERIMAGE
93 if (original_asim) 68 if (original_asim)
94 safe_asimage_destroy (original_asim); 69 safe_asimage_destroy (original_asim);
95#endif 70#endif
97#ifdef HAVE_PIXBUF 72#ifdef HAVE_PIXBUF
98 if (pixbuf) 73 if (pixbuf)
99 g_object_unref (pixbuf); 74 g_object_unref (pixbuf);
100#endif 75#endif
101 76
102 if (pixmap && target) 77 if (bg_pixmap)
103 XFreePixmap (target->dpy, pixmap); 78 XFreePixmap (dpy, bg_pixmap);
104} 79}
105 80
106bool 81bool
107bgPixmap_t::set_position (int x, int y) 82rxvt_term::bg_set_position (int x, int y)
108{ 83{
109 84
110 if (target_x != x 85 if (target_x != x
111 || target_y != y) 86 || target_y != y)
112 { 87 {
116 } 91 }
117 return false; 92 return false;
118} 93}
119 94
120bool 95bool
121bgPixmap_t::window_size_sensitive () 96rxvt_term::bg_window_size_sensitive ()
122{ 97{
123# ifdef ENABLE_TRANSPARENCY 98# ifdef ENABLE_TRANSPARENCY
124 if (flags & isTransparent) 99 if (bg_flags & BG_IS_TRANSPARENT)
125 return true; 100 return true;
126# endif 101# endif
127 102
128# ifdef BG_IMAGE_FROM_FILE 103# ifdef BG_IMAGE_FROM_FILE
129 if (have_image) 104 if (bg_flags & BG_IS_FROM_FILE)
130 { 105 {
131 if (flags & sizeSensitive) 106 if (bg_flags & BG_IS_SIZE_SENSITIVE)
132 return true; 107 return true;
133 } 108 }
134# endif 109# endif
135 110
136 return false; 111 return false;
137} 112}
138 113
139bool 114bool
140bgPixmap_t::window_position_sensitive () 115rxvt_term::bg_window_position_sensitive ()
141{ 116{
142# ifdef ENABLE_TRANSPARENCY 117# ifdef ENABLE_TRANSPARENCY
143 if (flags & isTransparent) 118 if (bg_flags & BG_IS_TRANSPARENT)
144 return true; 119 return true;
145# endif 120# endif
146 121
147# ifdef BG_IMAGE_FROM_FILE 122# ifdef BG_IMAGE_FROM_FILE
148 if (have_image) 123 if (bg_flags & BG_IS_FROM_FILE)
149 { 124 {
150 if (flags & rootAlign) 125 if (bg_flags & BG_ROOT_ALIGN)
151 return true; 126 return true;
152 } 127 }
153# endif 128# endif
154 129
155 return false; 130 return false;
222 dst_size = target_size - dst_pos; 197 dst_size = target_size - dst_pos;
223 return src_pos; 198 return src_pos;
224} 199}
225 200
226bool 201bool
227bgPixmap_t::set_geometry (const char *geom, bool update) 202rxvt_term::bg_set_geometry (const char *geom, bool update)
228{ 203{
229 bool changed = false; 204 bool changed = false;
230 int geom_flags = 0; 205 int geom_flags = 0;
231 int x = 0, y = 0; 206 int x = 0, y = 0;
232 unsigned int w = 0, h = 0; 207 unsigned int w = 0, h = 0;
233 unsigned int n; 208 unsigned int n;
234 unsigned long new_flags = (flags & (~geometryFlags)); 209 unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS));
235 const char *ops; 210 const char *ops;
236 211
237 if (geom == NULL) 212 if (geom == NULL)
238 return false; 213 return false;
239 214
286 w = h = noScale; 261 w = h = noScale;
287 geom_flags |= WidthValue|HeightValue; 262 geom_flags |= WidthValue|HeightValue;
288 } 263 }
289 else if (!strcasecmp (arr[i], "propscale")) 264 else if (!strcasecmp (arr[i], "propscale"))
290 { 265 {
291 new_flags |= propScale; 266 new_flags |= BG_PROP_SCALE;
292 } 267 }
293 else if (!strcasecmp (arr[i], "hscale")) 268 else if (!strcasecmp (arr[i], "hscale"))
294 { 269 {
295 if (w == 0) w = windowScale; 270 if (w == 0) w = windowScale;
296 271
317 x = y = centerAlign; 292 x = y = centerAlign;
318 geom_flags |= WidthValue|HeightValue|XValue|YValue; 293 geom_flags |= WidthValue|HeightValue|XValue|YValue;
319 } 294 }
320 else if (!strcasecmp (arr[i], "root")) 295 else if (!strcasecmp (arr[i], "root"))
321 { 296 {
322 new_flags |= rootAlign; 297 new_flags |= BG_ROOT_ALIGN;
323 w = h = noScale; 298 w = h = noScale;
324 geom_flags |= WidthValue|HeightValue; 299 geom_flags |= WidthValue|HeightValue;
325 } 300 }
326 } /* done parsing ops */ 301 } /* done parsing ops */
327 302
331 if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; 306 if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true;
332 if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; 307 if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true;
333 if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; 308 if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true;
334 if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; 309 if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true;
335 310
336 if (new_flags != flags) 311 if (new_flags != bg_flags)
337 { 312 {
338 flags = new_flags; 313 bg_flags = new_flags;
339 changed = true; 314 changed = true;
340 } 315 }
341 316
342 return changed; 317 return changed;
343} 318}
344 319
345void 320void
346bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) 321rxvt_term::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y)
347{ 322{
348 int target_width = target->szHint.width; 323 int target_width = szHint.width;
349 int target_height = target->szHint.height; 324 int target_height = szHint.height;
350 325
351 if (flags & propScale) 326 if (bg_flags & BG_PROP_SCALE)
352 { 327 {
353 float scale = (float)target_width / image_width; 328 float scale = (float)target_width / image_width;
354 min_it (scale, (float)target_height / image_height); 329 min_it (scale, (float)target_height / image_height);
355 w = image_width * scale + 0.5; 330 w = image_width * scale + 0.5;
356 h = image_height * scale + 0.5; 331 h = image_height * scale + 0.5;
362 } 337 }
363 338
364 if (!w) w = image_width; 339 if (!w) w = image_width;
365 if (!h) h = image_height; 340 if (!h) h = image_height;
366 341
367 if (flags & rootAlign) 342 if (bg_flags & BG_ROOT_ALIGN)
368 { 343 {
369 x = -target_x; 344 x = -target_x;
370 y = -target_y; 345 y = -target_y;
371 } 346 }
372 else 347 else
373 { 348 {
374 x = make_align_position (h_align, target_width, w); 349 x = make_align_position (h_align, target_width, w);
375 y = make_align_position (v_align, target_height, h); 350 y = make_align_position (v_align, target_height, h);
376 } 351 }
377 352
378 flags &= ~sizeSensitive; 353 bg_flags &= ~BG_IS_SIZE_SENSITIVE;
379 if ((flags & propScale) || h_scale || v_scale 354 if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale
380 || (!(flags & rootAlign) && (h_align || v_align)) 355 || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align))
381 || w > target_width || h > target_height) 356 || w > target_width || h > target_height)
382 flags |= sizeSensitive; 357 bg_flags |= BG_IS_SIZE_SENSITIVE;
383} 358}
384 359
385# ifdef HAVE_AFTERIMAGE 360# ifdef HAVE_AFTERIMAGE
386bool 361bool
387bgPixmap_t::render_image (unsigned long background_flags) 362rxvt_term::render_image (unsigned long tr_flags)
388{ 363{
389 if (target == NULL)
390 return false;
391
392 target->init_asv (); 364 init_asv ();
393 365
394 ASImage *background = NULL; 366 ASImage *background = NULL;
395 ARGB32 background_tint = TINT_LEAVE_SAME; 367 ARGB32 background_tint = TINT_LEAVE_SAME;
396 368
397# ifdef ENABLE_TRANSPARENCY 369# ifdef ENABLE_TRANSPARENCY
398 if (background_flags) 370 if (tr_flags)
399 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); 371 background = pixmap2ximage (asv, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, 100);
400 372
401 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 373 if (tr_flags & BG_NEEDS_TINT)
402 { 374 {
403 ShadingInfo as_shade; 375 ShadingInfo as_shade;
404 as_shade.shading = shade; 376 as_shade.shading = shade;
405 377
406 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 378 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
407 if (flags & tintSet) 379 if (bg_flags & BG_TINT_SET)
408 tint.get (c); 380 tint.get (c);
409 as_shade.tintColor.red = c.r; 381 as_shade.tintColor.red = c.r;
410 as_shade.tintColor.green = c.g; 382 as_shade.tintColor.green = c.g;
411 as_shade.tintColor.blue = c.b; 383 as_shade.tintColor.blue = c.b;
412 384
413 background_tint = shading2tint32 (&as_shade); 385 background_tint = shading2tint32 (&as_shade);
414 } 386 }
415 387
416 if (!(background_flags & transpPmapBlurred) && (flags & blurNeeded) && background != NULL) 388 if ((tr_flags & BG_NEEDS_BLUR) && background != NULL)
417 { 389 {
418 ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, 390 ASImage *tmp = blur_asimage_gauss (asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF,
419 (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, 391 (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage,
420 100, ASIMAGE_QUALITY_DEFAULT); 392 100, ASIMAGE_QUALITY_DEFAULT);
421 if (tmp) 393 if (tmp)
422 { 394 {
423 destroy_asimage (&background); 395 destroy_asimage (&background);
426 } 398 }
427# endif 399# endif
428 400
429 ASImage *result = 0; 401 ASImage *result = 0;
430 402
431 int target_width = target->szHint.width; 403 int target_width = szHint.width;
432 int target_height = target->szHint.height; 404 int target_height = szHint.height;
433 int new_pmap_width = target_width; 405 int new_pmap_width = target_width;
434 int new_pmap_height = target_height; 406 int new_pmap_height = target_height;
435 407
436 int x = 0; 408 int x = 0;
437 int y = 0; 409 int y = 0;
440 412
441 if (original_asim) 413 if (original_asim)
442 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); 414 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y);
443 415
444 if (!original_asim 416 if (!original_asim
445 || (!(flags & rootAlign) 417 || (!(bg_flags & BG_ROOT_ALIGN)
446 && (x >= target_width 418 && (x >= target_width
447 || y >= target_height 419 || y >= target_height
448 || (x + w <= 0) 420 || (x + w <= 0)
449 || (y + h <= 0)))) 421 || (y + h <= 0))))
450 { 422 {
454 new_pmap_height = background->height; 426 new_pmap_height = background->height;
455 result = background; 427 result = background;
456 428
457 if (background_tint != TINT_LEAVE_SAME) 429 if (background_tint != TINT_LEAVE_SAME)
458 { 430 {
459 ASImage *tmp = tile_asimage (target->asv, background, 0, 0, 431 ASImage *tmp = tile_asimage (asv, background, 0, 0,
460 target_width, target_height, background_tint, 432 target_width, target_height, background_tint,
461 ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); 433 ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT);
462 if (tmp) 434 if (tmp)
463 result = tmp; 435 result = tmp;
464 } 436 }
471 result = original_asim; 443 result = original_asim;
472 444
473 if ((w != original_asim->width) 445 if ((w != original_asim->width)
474 || (h != original_asim->height)) 446 || (h != original_asim->height))
475 { 447 {
476 result = scale_asimage (target->asv, original_asim, 448 result = scale_asimage (asv, original_asim,
477 w, h, 449 w, h,
478 background ? ASA_ASImage : ASA_XImage, 450 background ? ASA_ASImage : ASA_XImage,
479 100, ASIMAGE_QUALITY_DEFAULT); 451 100, ASIMAGE_QUALITY_DEFAULT);
480 } 452 }
481 453
487 but there is no need to make it bigger than the window! */ 459 but there is no need to make it bigger than the window! */
488 new_pmap_width = min (result->width, target_width); 460 new_pmap_width = min (result->width, target_width);
489 new_pmap_height = min (result->height, target_height); 461 new_pmap_height = min (result->height, target_height);
490 462
491 /* we also need to tile our image in both directions */ 463 /* we also need to tile our image in both directions */
492 ASImage *tmp = tile_asimage (target->asv, result, 464 ASImage *tmp = tile_asimage (asv, result,
493 (int)result->width - x, 465 (int)result->width - x,
494 (int)result->height - y, 466 (int)result->height - y,
495 new_pmap_width, 467 new_pmap_width,
496 new_pmap_height, 468 new_pmap_height,
497 TINT_LEAVE_SAME, ASA_XImage, 469 TINT_LEAVE_SAME, ASA_XImage,
540 { 512 {
541 layers[1].dst_y = y; 513 layers[1].dst_y = y;
542 layers[1].clip_height = result->height; 514 layers[1].clip_height = result->height;
543 } 515 }
544 516
545 if (target->rs[Rs_blendtype]) 517 if (rs[Rs_blendtype])
546 { 518 {
547 layers[1].merge_scanlines = blend_scanlines_name2func (target->rs[Rs_blendtype]); 519 layers[1].merge_scanlines = blend_scanlines_name2func (rs[Rs_blendtype]);
548 if (layers[1].merge_scanlines == NULL) 520 if (layers[1].merge_scanlines == NULL)
549 layers[1].merge_scanlines = alphablend_scanlines; 521 layers[1].merge_scanlines = alphablend_scanlines;
550 } 522 }
551 523
552 ASImage *tmp = merge_layers (target->asv, layers, 2, target_width, target_height, 524 ASImage *tmp = merge_layers (asv, layers, 2, target_width, target_height,
553 ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); 525 ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT);
554 526
555 if (tmp) 527 if (tmp)
556 { 528 {
557 if (result != original_asim) 529 if (result != original_asim)
570 { 542 {
571 XGCValues gcv; 543 XGCValues gcv;
572 GC gc; 544 GC gc;
573 545
574 /* create Pixmap */ 546 /* create Pixmap */
575 if (pixmap == None 547 if (bg_pixmap == None
576 || pmap_width != new_pmap_width 548 || bg_pmap_width != new_pmap_width
577 || pmap_height != new_pmap_height) 549 || bg_pmap_height != new_pmap_height)
578 { 550 {
579 if (pixmap) 551 if (bg_pixmap)
580 XFreePixmap (target->dpy, pixmap); 552 XFreePixmap (dpy, bg_pixmap);
581 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 553 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth);
582 pmap_width = new_pmap_width; 554 bg_pmap_width = new_pmap_width;
583 pmap_height = new_pmap_height; 555 bg_pmap_height = new_pmap_height;
584 } 556 }
585 /* fill with background color (if result's not completely overlapping it) */ 557 /* fill with background color (if result's not completely overlapping it) */
586 gcv.foreground = target->pix_colors[Color_bg]; 558 gcv.foreground = pix_colors[Color_bg];
587 gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); 559 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
588 560
589 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; 561 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0;
590 int dst_width = result->width, dst_height = result->height; 562 int dst_width = result->width, dst_height = result->height;
591 if (background == NULL) 563 if (background == NULL)
592 { 564 {
597 } 569 }
598 570
599 if (dst_x > 0 || dst_y > 0 571 if (dst_x > 0 || dst_y > 0
600 || dst_x + dst_width < new_pmap_width 572 || dst_x + dst_width < new_pmap_width
601 || dst_y + dst_height < new_pmap_height) 573 || dst_y + dst_height < new_pmap_height)
602 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 574 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
603 } 575 }
604 576
605 /* put result on pixmap */ 577 /* put result on pixmap */
606 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 578 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
607 asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); 579 asimage2drawable (asv, bg_pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True);
608 580
609 if (result != background && result != original_asim) 581 if (result != background && result != original_asim)
610 destroy_asimage (&result); 582 destroy_asimage (&result);
611 583
612 XFreeGC (target->dpy, gc); 584 XFreeGC (dpy, gc);
613 585
614 ret = true; 586 ret = true;
615 } 587 }
616 588
617 if (background) 589 if (background)
621} 593}
622# endif /* HAVE_AFTERIMAGE */ 594# endif /* HAVE_AFTERIMAGE */
623 595
624# ifdef HAVE_PIXBUF 596# ifdef HAVE_PIXBUF
625bool 597bool
626bgPixmap_t::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, 598rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc,
627 int src_x, int src_y, int dst_x, int dst_y, 599 int src_x, int src_y, int dst_x, int dst_y,
628 unsigned int width, unsigned int height) 600 unsigned int width, unsigned int height)
629{ 601{
630 XImage *ximage; 602 XImage *ximage;
631 char *data, *line; 603 char *data, *line;
632 int bytes_per_pixel; 604 int bytes_per_pixel;
633 int width_r, width_g, width_b; 605 int width_r, width_g, width_b;
634 int sh_r, sh_g, sh_b; 606 int sh_r, sh_g, sh_b;
635 int rowstride; 607 int rowstride;
636 int channels; 608 int channels;
637 unsigned char *row; 609 unsigned char *row;
638 Visual *visual = target->visual;
639 int depth = target->depth;
640 610
641 if (visual->c_class != TrueColor) 611 if (visual->c_class != TrueColor)
642 return false; 612 return false;
643 613
644 if (depth == 24 || depth == 32) 614 if (depth == 24 || depth == 32)
664 634
665 data = (char *)malloc (width * height * bytes_per_pixel); 635 data = (char *)malloc (width * height * bytes_per_pixel);
666 if (!data) 636 if (!data)
667 return false; 637 return false;
668 638
669 ximage = XCreateImage (target->dpy, visual, depth, ZPixmap, 0, data, 639 ximage = XCreateImage (dpy, visual, depth, ZPixmap, 0, data,
670 width, height, bytes_per_pixel * 8, 0); 640 width, height, bytes_per_pixel * 8, 0);
671 if (!ximage) 641 if (!ximage)
672 { 642 {
673 free (data); 643 free (data);
674 return false; 644 return false;
700 670
701 row += rowstride; 671 row += rowstride;
702 line += ximage->bytes_per_line; 672 line += ximage->bytes_per_line;
703 } 673 }
704 674
705 XPutImage (target->dpy, pixmap, gc, ximage, 0, 0, dst_x, dst_y, width, height); 675 XPutImage (dpy, pixmap, gc, ximage, 0, 0, dst_x, dst_y, width, height);
706 XDestroyImage (ximage); 676 XDestroyImage (ximage);
707 return true; 677 return true;
708} 678}
709 679
710bool 680bool
711bgPixmap_t::render_image (unsigned long background_flags) 681rxvt_term::render_image (unsigned long tr_flags)
712{ 682{
713 if (target == NULL)
714 return false;
715
716 if (!pixbuf) 683 if (!pixbuf)
717 return false; 684 return false;
718 685
719 if (background_flags 686 if (tr_flags
720 && !(flags & HAS_RENDER)) 687 && !(bg_flags & BG_HAS_RENDER))
721 return false; 688 return false;
722 689
723 GdkPixbuf *result; 690 GdkPixbuf *result;
724 691
725 int image_width = gdk_pixbuf_get_width (pixbuf); 692 int image_width = gdk_pixbuf_get_width (pixbuf);
726 int image_height = gdk_pixbuf_get_height (pixbuf); 693 int image_height = gdk_pixbuf_get_height (pixbuf);
727 694
728 int target_width = target->szHint.width; 695 int target_width = szHint.width;
729 int target_height = target->szHint.height; 696 int target_height = szHint.height;
730 int new_pmap_width = target_width; 697 int new_pmap_width = target_width;
731 int new_pmap_height = target_height; 698 int new_pmap_height = target_height;
732 699
733 int x = 0; 700 int x = 0;
734 int y = 0; 701 int y = 0;
735 int w = 0; 702 int w = 0;
736 int h = 0; 703 int h = 0;
737 704
738 get_image_geometry (image_width, image_height, w, h, x, y); 705 get_image_geometry (image_width, image_height, w, h, x, y);
739 706
740 if (!(flags & rootAlign) 707 if (!(bg_flags & BG_ROOT_ALIGN)
741 && (x >= target_width 708 && (x >= target_width
742 || y >= target_height 709 || y >= target_height
743 || (x + w <= 0) 710 || (x + w <= 0)
744 || (y + h <= 0))) 711 || (y + h <= 0)))
745 return false; 712 return false;
763 Pixmap root_pmap; 730 Pixmap root_pmap;
764 731
765 image_width = gdk_pixbuf_get_width (result); 732 image_width = gdk_pixbuf_get_width (result);
766 image_height = gdk_pixbuf_get_height (result); 733 image_height = gdk_pixbuf_get_height (result);
767 734
768 if (background_flags) 735 if (tr_flags)
769 { 736 {
770 root_pmap = pixmap; 737 root_pmap = bg_pixmap;
771 pixmap = None; 738 bg_pixmap = None;
772 } 739 }
773 else 740 else
774 { 741 {
775 if (h_scale == 0 || v_scale == 0) 742 if (h_scale == 0 || v_scale == 0)
776 { 743 {
777 new_pmap_width = min (image_width, target_width); 744 new_pmap_width = min (image_width, target_width);
778 new_pmap_height = min (image_height, target_height); 745 new_pmap_height = min (image_height, target_height);
779 } 746 }
780 } 747 }
781 748
782 if (pixmap == None 749 if (bg_pixmap == None
783 || pmap_width != new_pmap_width 750 || bg_pmap_width != new_pmap_width
784 || pmap_height != new_pmap_height) 751 || bg_pmap_height != new_pmap_height)
785 { 752 {
786 if (pixmap) 753 if (bg_pixmap)
787 XFreePixmap (target->dpy, pixmap); 754 XFreePixmap (dpy, bg_pixmap);
788 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 755 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth);
789 pmap_width = new_pmap_width; 756 bg_pmap_width = new_pmap_width;
790 pmap_height = new_pmap_height; 757 bg_pmap_height = new_pmap_height;
791 } 758 }
792 759
793 gcv.foreground = target->pix_colors[Color_bg]; 760 gcv.foreground = pix_colors[Color_bg];
794 gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); 761 gc = XCreateGC (dpy, vt, GCForeground, &gcv);
795 762
796 if (h_scale == 0 || v_scale == 0) 763 if (h_scale == 0 || v_scale == 0)
797 { 764 {
798 Pixmap tile = XCreatePixmap (target->dpy, target->vt, image_width, image_height, target->depth); 765 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth);
799 pixbuf_to_pixmap (result, tile, gc, 766 pixbuf_to_pixmap (result, tile, gc,
800 0, 0, 767 0, 0,
801 0, 0, 768 0, 0,
802 image_width, image_height); 769 image_width, image_height);
803 770
804 gcv.tile = tile; 771 gcv.tile = tile;
805 gcv.fill_style = FillTiled; 772 gcv.fill_style = FillTiled;
806 gcv.ts_x_origin = x; 773 gcv.ts_x_origin = x;
807 gcv.ts_y_origin = y; 774 gcv.ts_y_origin = y;
808 XChangeGC (target->dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 775 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
809 776
810 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 777 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
811 XFreePixmap (target->dpy, tile); 778 XFreePixmap (dpy, tile);
812 } 779 }
813 else 780 else
814 { 781 {
815 int src_x, src_y, dst_x, dst_y; 782 int src_x, src_y, dst_x, dst_y;
816 int dst_width, dst_height; 783 int dst_width, dst_height;
819 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height); 786 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height);
820 787
821 if (dst_x > 0 || dst_y > 0 788 if (dst_x > 0 || dst_y > 0
822 || dst_x + dst_width < new_pmap_width 789 || dst_x + dst_width < new_pmap_width
823 || dst_y + dst_height < new_pmap_height) 790 || dst_y + dst_height < new_pmap_height)
824 XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 791 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
825 792
826 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 793 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
827 pixbuf_to_pixmap (result, pixmap, gc, 794 pixbuf_to_pixmap (result, bg_pixmap, gc,
828 src_x, src_y, 795 src_x, src_y,
829 dst_x, dst_y, 796 dst_x, dst_y,
830 dst_width, dst_height); 797 dst_width, dst_height);
831 } 798 }
832 799
833#if XRENDER 800#if XRENDER
834 if (background_flags) 801 if (tr_flags)
835 { 802 {
836 Display *dpy = target->dpy;
837 XRenderPictureAttributes pa; 803 XRenderPictureAttributes pa;
838 804
839 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, target->visual); 805 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual);
840 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 806 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa);
841 807
842 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); 808 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
843 Picture dst = XRenderCreatePicture (dpy, pixmap, dst_format, 0, &pa); 809 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa);
844 810
845 pa.repeat = True; 811 pa.repeat = True;
846 Pixmap mask_pmap = XCreatePixmap (dpy, target->vt, 1, 1, 8); 812 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
847 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); 813 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
848 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); 814 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
849 XFreePixmap (dpy, mask_pmap); 815 XFreePixmap (dpy, mask_pmap);
850 816
851 if (src && dst && mask) 817 if (src && dst && mask)
869#endif 835#endif
870 836
871 if (result != pixbuf) 837 if (result != pixbuf)
872 g_object_unref (result); 838 g_object_unref (result);
873 839
874 XFreeGC (target->dpy, gc); 840 XFreeGC (dpy, gc);
875 841
876 ret = true; 842 ret = true;
877 } 843 }
878 844
879 return ret; 845 return ret;
880} 846}
881# endif /* HAVE_PIXBUF */ 847# endif /* HAVE_PIXBUF */
882 848
883bool 849bool
884bgPixmap_t::set_file (const char *file) 850rxvt_term::bg_set_file (const char *file)
885{ 851{
886 if (!file || !*file) 852 if (!file || !*file)
887 return false; 853 return false;
888 854
889 if (const char *p = strchr (file, ';')) 855 if (const char *p = strchr (file, ';'))
894 f[len] = '\0'; 860 f[len] = '\0';
895 file = f; 861 file = f;
896 } 862 }
897 863
898# ifdef HAVE_AFTERIMAGE 864# ifdef HAVE_AFTERIMAGE
899 if (!target->asimman) 865 if (!asimman)
900 target->asimman = create_generic_imageman (target->rs[Rs_path]); 866 asimman = create_generic_imageman (rs[Rs_path]);
901 ASImage *image = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); 867 ASImage *image = get_asimage (asimman, file, 0xFFFFFFFF, 100);
902 if (image) 868 if (image)
903 { 869 {
904 if (original_asim) 870 if (original_asim)
905 safe_asimage_destroy (original_asim); 871 safe_asimage_destroy (original_asim);
906 original_asim = image; 872 original_asim = image;
907 flags |= CLIENT_RENDER; 873 bg_flags |= BG_IS_FROM_FILE | BG_CLIENT_RENDER;
908 have_image = true;
909 return true; 874 return true;
910 } 875 }
911# endif 876# endif
912 877
913# ifdef HAVE_PIXBUF 878# ifdef HAVE_PIXBUF
915 if (image) 880 if (image)
916 { 881 {
917 if (pixbuf) 882 if (pixbuf)
918 g_object_unref (pixbuf); 883 g_object_unref (pixbuf);
919 pixbuf = image; 884 pixbuf = image;
920 have_image = true; 885 bg_flags |= BG_IS_FROM_FILE;
921 return true; 886 return true;
922 } 887 }
923# endif 888# endif
924 889
925 return false; 890 return false;
927 892
928# endif /* BG_IMAGE_FROM_FILE */ 893# endif /* BG_IMAGE_FROM_FILE */
929 894
930# ifdef ENABLE_TRANSPARENCY 895# ifdef ENABLE_TRANSPARENCY
931bool 896bool
932bgPixmap_t::set_transparent () 897rxvt_term::bg_set_transparent ()
933{ 898{
934 if (!(flags & isTransparent)) 899 if (!(bg_flags & BG_IS_TRANSPARENT))
935 { 900 {
936 flags |= isTransparent; 901 bg_flags |= BG_IS_TRANSPARENT;
937 return true; 902 return true;
938 } 903 }
939 904
940 return false; 905 return false;
941} 906}
942 907
943bool 908bool
944bgPixmap_t::set_blur_radius (const char *geom) 909rxvt_term::bg_set_blur (const char *geom)
945{ 910{
946 bool changed = false; 911 bool changed = false;
947 unsigned int hr, vr; 912 unsigned int hr, vr;
948 int junk; 913 int junk;
949 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); 914 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr);
967 changed = true; 932 changed = true;
968 v_blurRadius = vr; 933 v_blurRadius = vr;
969 } 934 }
970 935
971 if (v_blurRadius == 0 && h_blurRadius == 0) 936 if (v_blurRadius == 0 && h_blurRadius == 0)
972 flags &= ~blurNeeded; 937 bg_flags &= ~BG_NEEDS_BLUR;
973 else 938 else
974 flags |= blurNeeded; 939 bg_flags |= BG_NEEDS_BLUR;
975 940
976 return changed; 941 return changed;
977} 942}
978 943
979static inline unsigned long 944static inline unsigned long
988 tint->get (c); 953 tint->get (c);
989 if (!has_shade 954 if (!has_shade
990 && (c.r <= 0x00ff || c.r >= 0xff00) 955 && (c.r <= 0x00ff || c.r >= 0xff00)
991 && (c.g <= 0x00ff || c.g >= 0xff00) 956 && (c.g <= 0x00ff || c.g >= 0xff00)
992 && (c.b <= 0x00ff || c.b >= 0xff00)) 957 && (c.b <= 0x00ff || c.b >= 0xff00))
993 flags |= bgPixmap_t::tintWholesome; 958 flags |= rxvt_term::BG_TINT_BITAND;
994 } 959 }
995 960
996 if (has_shade || tint) 961 if (has_shade || tint)
997 flags |= bgPixmap_t::tintNeeded; 962 flags |= rxvt_term::BG_NEEDS_TINT;
998 963
999 return flags; 964 return flags;
1000} 965}
1001 966
1002bool 967bool
1003bgPixmap_t::set_tint (rxvt_color &new_tint) 968rxvt_term::bg_set_tint (rxvt_color &new_tint)
1004{ 969{
1005 if (!(flags & tintSet) || tint != new_tint) 970 if (!(bg_flags & BG_TINT_SET) || tint != new_tint)
1006 { 971 {
1007 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); 972 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade);
1008 tint = new_tint; 973 tint = new_tint;
1009 flags = (flags & ~tintFlags) | new_flags | tintSet; 974 bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags | BG_TINT_SET;
1010 return true; 975 return true;
1011 } 976 }
1012 977
1013 return false; 978 return false;
1014} 979}
1015 980
1016bool 981bool
1017bgPixmap_t::set_shade (const char *shade_str) 982rxvt_term::bg_set_shade (const char *shade_str)
1018{ 983{
1019 int new_shade = (shade_str) ? atoi (shade_str) : 100; 984 int new_shade = (shade_str) ? atoi (shade_str) : 100;
1020 985
1021 clamp_it (new_shade, -100, 200); 986 clamp_it (new_shade, -100, 200);
1022 if (new_shade < 0) 987 if (new_shade < 0)
1023 new_shade = 200 - (100 + new_shade); 988 new_shade = 200 - (100 + new_shade);
1024 989
1025 if (new_shade != shade) 990 if (new_shade != shade)
1026 { 991 {
1027 unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); 992 unsigned long new_flags = compute_tint_shade_flags ((bg_flags & BG_TINT_SET) ? &tint : NULL, new_shade);
1028 shade = new_shade; 993 shade = new_shade;
1029 flags = (flags & ~tintFlags) | new_flags; 994 bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags;
1030 return true; 995 return true;
1031 } 996 }
1032 997
1033 return false; 998 return false;
1034} 999}
1055 params[i+2] = XDoubleToFixed (kernel[i] / sum); 1020 params[i+2] = XDoubleToFixed (kernel[i] / sum);
1056} 1021}
1057#endif 1022#endif
1058 1023
1059bool 1024bool
1060bgPixmap_t::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) 1025rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height)
1061{ 1026{
1062 bool ret = false; 1027 bool ret = false;
1063#if XRENDER 1028#if XRENDER
1064 int size = max (h_blurRadius, v_blurRadius) * 2 + 1; 1029 int size = max (h_blurRadius, v_blurRadius) * 2 + 1;
1065 double *kernel = (double *)malloc (size * sizeof (double)); 1030 double *kernel = (double *)malloc (size * sizeof (double));
1066 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 1031 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
1067 1032
1068 Display *dpy = target->dpy;
1069 XRenderPictureAttributes pa; 1033 XRenderPictureAttributes pa;
1070 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1034 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1071 1035
1072 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1036 Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1073 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1037 Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1093 1057
1094 if (v_blurRadius) 1058 if (v_blurRadius)
1095 { 1059 {
1096 size = v_blurRadius * 2 + 1; 1060 size = v_blurRadius * 2 + 1;
1097 get_gaussian_kernel (v_blurRadius, size, kernel, params); 1061 get_gaussian_kernel (v_blurRadius, size, kernel, params);
1098 swap (params[0], params[1]); 1062 ::swap (params[0], params[1]);
1099 1063
1100 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2); 1064 XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2);
1101 XRenderComposite (dpy, 1065 XRenderComposite (dpy,
1102 PictOpSrc, 1066 PictOpSrc,
1103 src, 1067 src,
1119#endif 1083#endif
1120 return ret; 1084 return ret;
1121} 1085}
1122 1086
1123bool 1087bool
1124bgPixmap_t::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height) 1088rxvt_term::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height)
1125{ 1089{
1126 Display *dpy = target->dpy;
1127 bool ret = false; 1090 bool ret = false;
1128 1091
1129 if (flags & tintWholesome) 1092 if (bg_flags & BG_TINT_BITAND)
1130 { 1093 {
1131 XGCValues gcv; 1094 XGCValues gcv;
1132 GC gc; 1095 GC gc;
1133 1096
1134 /* In this case we can tint image server-side getting significant 1097 /* In this case we can tint image server-side getting significant
1148 else 1111 else
1149 { 1112 {
1150# if XRENDER 1113# if XRENDER
1151 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1114 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1152 1115
1153 if (flags & tintSet) 1116 if (bg_flags & BG_TINT_SET)
1154 tint.get (c); 1117 tint.get (c);
1155 1118
1156 if (shade <= 100) 1119 if (shade <= 100)
1157 { 1120 {
1158 c.r = (c.r * shade) / 100; 1121 c.r = (c.r * shade) / 100;
1223 * Builds a pixmap of the same size as the terminal window that contains 1186 * Builds a pixmap of the same size as the terminal window that contains
1224 * the tiled portion of the root pixmap that is supposed to be covered by 1187 * the tiled portion of the root pixmap that is supposed to be covered by
1225 * our window. 1188 * our window.
1226 */ 1189 */
1227unsigned long 1190unsigned long
1228bgPixmap_t::make_transparency_pixmap () 1191rxvt_term::make_transparency_pixmap ()
1229{ 1192{
1230 unsigned long result = 0; 1193 unsigned long result = 0;
1231
1232 if (target == NULL)
1233 return 0;
1234 1194
1235 /* root dimensions may change from call to call - but Display structure should 1195 /* root dimensions may change from call to call - but Display structure should
1236 * be always up-to-date, so let's use it : 1196 * be always up-to-date, so let's use it :
1237 */ 1197 */
1238 int screen = target->display->screen; 1198 int screen = display->screen;
1239 Display *dpy = target->dpy;
1240 int root_depth = DefaultDepth (dpy, screen); 1199 int root_depth = DefaultDepth (dpy, screen);
1241 int root_width = DisplayWidth (dpy, screen); 1200 int root_width = DisplayWidth (dpy, screen);
1242 int root_height = DisplayHeight (dpy, screen); 1201 int root_height = DisplayHeight (dpy, screen);
1243 unsigned int root_pmap_width, root_pmap_height; 1202 unsigned int root_pmap_width, root_pmap_height;
1244 int window_width = target->szHint.width; 1203 int window_width = szHint.width;
1245 int window_height = target->szHint.height; 1204 int window_height = szHint.height;
1246 int sx, sy; 1205 int sx, sy;
1247 XGCValues gcv; 1206 XGCValues gcv;
1248 GC gc; 1207 GC gc;
1249 1208
1250 sx = target_x; 1209 sx = target_x;
1260 { 1219 {
1261 Window wdummy; 1220 Window wdummy;
1262 int idummy; 1221 int idummy;
1263 unsigned int udummy; 1222 unsigned int udummy;
1264 1223
1265 target->allowedxerror = -1; 1224 allowedxerror = -1;
1266 1225
1267 if (!XGetGeometry (dpy, root_pixmap, &wdummy, &idummy, &idummy, &root_pmap_width, &root_pmap_height, &udummy, &udummy)) 1226 if (!XGetGeometry (dpy, root_pixmap, &wdummy, &idummy, &idummy, &root_pmap_width, &root_pmap_height, &udummy, &udummy))
1268 root_pixmap = None; 1227 root_pixmap = None;
1269 1228
1270 target->allowedxerror = 0; 1229 allowedxerror = 0;
1271 } 1230 }
1272 1231
1273 Pixmap recoded_root_pmap = root_pixmap; 1232 Pixmap recoded_root_pmap = root_pixmap;
1274 1233
1275 if (root_pixmap != None && root_depth != target->depth) 1234 if (root_pixmap != None && root_depth != depth)
1276 { 1235 {
1277#if XRENDER 1236#if XRENDER
1278 if (flags & HAS_RENDER) 1237 if (bg_flags & BG_HAS_RENDER)
1279 { 1238 {
1280 XRenderPictureAttributes pa; 1239 XRenderPictureAttributes pa;
1281 1240
1282 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); 1241 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen));
1283 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); 1242 Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa);
1284 1243
1285 recoded_root_pmap = XCreatePixmap (dpy, target->vt, root_pmap_width, root_pmap_height, target->depth); 1244 recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth);
1286 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, target->visual); 1245 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
1287 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); 1246 Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa);
1288 1247
1289 if (src && dst) 1248 if (src && dst)
1290 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); 1249 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height);
1291 else 1250 else
1303 } 1262 }
1304 1263
1305 if (root_pixmap == None) 1264 if (root_pixmap == None)
1306 return 0; 1265 return 0;
1307 1266
1308 if (pixmap == None 1267 if (bg_pixmap == None
1309 || pmap_width != window_width 1268 || bg_pmap_width != window_width
1310 || pmap_height != window_height) 1269 || bg_pmap_height != window_height)
1311 { 1270 {
1312 if (pixmap) 1271 if (bg_pixmap)
1313 XFreePixmap (target->dpy, pixmap); 1272 XFreePixmap (dpy, bg_pixmap);
1314 pixmap = XCreatePixmap (target->dpy, target->vt, window_width, window_height, target->depth); 1273 bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth);
1315 pmap_width = window_width; 1274 bg_pmap_width = window_width;
1316 pmap_height = window_height; 1275 bg_pmap_height = window_height;
1317 } 1276 }
1318 1277
1319 if (pixmap == None) 1278 if (bg_pixmap == None)
1320 return 0; 1279 return 0;
1321 1280
1322 /* straightforward pixmap copy */ 1281 /* straightforward pixmap copy */
1323 while (sx < 0) sx += (int)root_width; 1282 while (sx < 0) sx += (int)root_width;
1324 while (sy < 0) sy += (int)root_height; 1283 while (sy < 0) sy += (int)root_height;
1325 1284
1326 gcv.tile = recoded_root_pmap; 1285 gcv.tile = recoded_root_pmap;
1327 gcv.fill_style = FillTiled; 1286 gcv.fill_style = FillTiled;
1328 gcv.ts_x_origin = -sx; 1287 gcv.ts_x_origin = -sx;
1329 gcv.ts_y_origin = -sy; 1288 gcv.ts_y_origin = -sy;
1330 gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 1289 gc = XCreateGC (dpy, vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
1331 1290
1332 if (gc) 1291 if (gc)
1333 { 1292 {
1334 XFillRectangle (dpy, pixmap, gc, 0, 0, window_width, window_height); 1293 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1335 result |= transpPmapTiled; 1294 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1336 XFreeGC (dpy, gc); 1295 XFreeGC (dpy, gc);
1337 1296
1338 if (!(flags & CLIENT_RENDER)) 1297 if (!(bg_flags & BG_CLIENT_RENDER))
1339 { 1298 {
1340 if ((flags & blurNeeded) 1299 if ((bg_flags & BG_NEEDS_BLUR)
1341 && (flags & HAS_RENDER_CONV)) 1300 && (bg_flags & BG_HAS_RENDER_CONV))
1342 { 1301 {
1343 if (blur_pixmap (pixmap, target->visual, window_width, window_height)) 1302 if (blur_pixmap (bg_pixmap, visual, window_width, window_height))
1344 result |= transpPmapBlurred; 1303 result &= ~BG_NEEDS_BLUR;
1345 }
1346 if ((flags & tintNeeded)
1347 && (flags & (tintWholesome | HAS_RENDER)))
1348 { 1304 }
1305 if ((bg_flags & BG_NEEDS_TINT)
1306 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER)))
1307 {
1349 if (tint_pixmap (pixmap, target->visual, window_width, window_height)) 1308 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1350 result |= transpPmapTinted; 1309 result &= ~BG_NEEDS_TINT;
1351 } 1310 }
1352 } /* server side rendering completed */ 1311 } /* server side rendering completed */
1353 } 1312 }
1354 1313
1355 if (recoded_root_pmap != root_pixmap) 1314 if (recoded_root_pmap != root_pixmap)
1357 1316
1358 return result; 1317 return result;
1359} 1318}
1360 1319
1361void 1320void
1362bgPixmap_t::set_root_pixmap () 1321rxvt_term::bg_set_root_pixmap ()
1363{ 1322{
1364 Pixmap new_root_pixmap = target->get_pixmap_property (target->xa[XA_XROOTPMAP_ID]); 1323 Pixmap new_root_pixmap = get_pixmap_property (xa[XA_XROOTPMAP_ID]);
1365 if (new_root_pixmap == None) 1324 if (new_root_pixmap == None)
1366 new_root_pixmap = target->get_pixmap_property (target->xa[XA_ESETROOT_PMAP_ID]); 1325 new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]);
1367 1326
1368 root_pixmap = new_root_pixmap; 1327 root_pixmap = new_root_pixmap;
1369} 1328}
1370# endif /* ENABLE_TRANSPARENCY */ 1329# endif /* ENABLE_TRANSPARENCY */
1371 1330
1372#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) 1331#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1373static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c); 1332static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c);
1374# endif 1333# endif
1375 1334
1376bool 1335bool
1377bgPixmap_t::render () 1336rxvt_term::bg_render ()
1378{ 1337{
1379 unsigned long background_flags = 0; 1338 unsigned long tr_flags = 0;
1380 1339
1381 if (target == NULL)
1382 return false;
1383
1384 invalidate (); 1340 bg_invalidate ();
1385# ifdef ENABLE_TRANSPARENCY 1341# ifdef ENABLE_TRANSPARENCY
1386 if (flags & isTransparent) 1342 if (bg_flags & BG_IS_TRANSPARENT)
1387 { 1343 {
1388 /* we need to re-generate transparency pixmap in that case ! */ 1344 /* we need to re-generate transparency pixmap in that case ! */
1389 background_flags = make_transparency_pixmap (); 1345 tr_flags = make_transparency_pixmap ();
1390 if (background_flags == 0) 1346 if (tr_flags == 0)
1391 return false; 1347 return false;
1392 else if ((background_flags & transpTransformations) == (flags & transpTransformations)) 1348 else if (!(tr_flags & BG_EFFECTS_FLAGS))
1393 flags |= isValid; 1349 bg_flags |= BG_IS_VALID;
1394 } 1350 }
1395# endif 1351# endif
1396 1352
1397# ifdef BG_IMAGE_FROM_FILE 1353# ifdef BG_IMAGE_FROM_FILE
1398 if (have_image 1354 if ((bg_flags & BG_IS_FROM_FILE)
1399 || (background_flags & transpTransformations) != (flags & transpTransformations)) 1355 || (tr_flags & BG_EFFECTS_FLAGS))
1400 { 1356 {
1401 if (render_image (background_flags)) 1357 if (render_image (tr_flags))
1402 flags |= isValid; 1358 bg_flags |= BG_IS_VALID;
1403 } 1359 }
1404# endif 1360# endif
1405 1361
1406# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) 1362# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1407 XImage *result = NULL; 1363 XImage *result = NULL;
1408 1364
1409 if (background_flags && !(flags & isValid)) 1365 if (tr_flags && !(bg_flags & BG_IS_VALID))
1410 { 1366 {
1411 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1367 result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1412 } 1368 }
1413 1369
1414 if (result) 1370 if (result)
1415 { 1371 {
1416 /* our own client-side tinting */ 1372 /* our own client-side tinting */
1417 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1373 if (tr_flags & BG_NEEDS_TINT)
1418 { 1374 {
1419 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1375 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1420 if (flags & tintSet) 1376 if (bg_flags & BG_TINT_SET)
1421 tint.get (c); 1377 tint.get (c);
1422 shade_ximage (DefaultVisual (target->dpy, target->display->screen), result, shade, c); 1378 shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c);
1423 } 1379 }
1424 1380
1425 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1381 GC gc = XCreateGC (dpy, vt, 0UL, NULL);
1426 1382
1427 if (gc) 1383 if (gc)
1428 { 1384 {
1429 XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); 1385 XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
1430 1386
1431 XFreeGC (target->dpy, gc); 1387 XFreeGC (dpy, gc);
1432 flags |= isValid; 1388 bg_flags |= BG_IS_VALID;
1433 } 1389 }
1434 1390
1435 XDestroyImage (result); 1391 XDestroyImage (result);
1436 } 1392 }
1437# endif 1393# endif
1438 1394
1439 if (!(flags & isValid)) 1395 if (!(bg_flags & BG_IS_VALID))
1440 { 1396 {
1441 if (pixmap != None) 1397 if (bg_pixmap != None)
1442 { 1398 {
1443 XFreePixmap (target->dpy, pixmap); 1399 XFreePixmap (dpy, bg_pixmap);
1444 pixmap = None; 1400 bg_pixmap = None;
1445 } 1401 }
1446 } 1402 }
1447 1403
1448 target->scr_recolour (false); 1404 scr_recolour (false);
1449 flags |= hasChanged; 1405 bg_flags |= BG_NEEDS_REFRESH;
1450 1406
1451 valid_since = ev::now (); 1407 bg_valid_since = ev::now ();
1452 1408
1453 return true; 1409 return true;
1454} 1410}
1455 1411
1456void 1412void
1457bgPixmap_t::set_target (rxvt_term *new_target) 1413rxvt_term::bg_init ()
1458{ 1414{
1459 target = new_target; 1415#ifdef ENABLE_TRANSPARENCY
1416 shade = 100;
1417#endif
1460 1418
1461 flags &= ~(HAS_RENDER | HAS_RENDER_CONV); 1419 bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV);
1462#if XRENDER 1420#if XRENDER
1463 int major, minor; 1421 int major, minor;
1464 if (XRenderQueryVersion (target->dpy, &major, &minor)) 1422 if (XRenderQueryVersion (dpy, &major, &minor))
1465 flags |= HAS_RENDER; 1423 bg_flags |= BG_HAS_RENDER;
1466 XFilters *filters = XRenderQueryFilters (target->dpy, target->vt); 1424 XFilters *filters = XRenderQueryFilters (dpy, vt);
1467 if (filters) 1425 if (filters)
1468 { 1426 {
1469 for (int i = 0; i < filters->nfilter; i++) 1427 for (int i = 0; i < filters->nfilter; i++)
1470 if (!strcmp (filters->filter[i], FilterConvolution)) 1428 if (!strcmp (filters->filter[i], FilterConvolution))
1471 flags |= HAS_RENDER_CONV; 1429 bg_flags |= BG_HAS_RENDER_CONV;
1472 1430
1473 XFree (filters); 1431 XFree (filters);
1474 } 1432 }
1475#endif 1433#endif
1476} 1434}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines