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> |
6 | * Copyright (c) 1997 Carsten Haitzler <raster@zip.com.au> |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
… | |
… | |
31 | |
31 | |
32 | #if DO_TIMING_TEST |
32 | #if DO_TIMING_TEST |
33 | #define TIMING_TEST_START(id) \ |
33 | #define TIMING_TEST_START(id) \ |
34 | struct timeval timing_test_##id##_stv;\ |
34 | struct timeval timing_test_##id##_stv;\ |
35 | gettimeofday (&timing_test_##id##_stv, NULL); |
35 | gettimeofday (&timing_test_##id##_stv, NULL); |
36 | |
36 | |
37 | #define TIMING_TEST_PRINT_RESULT(id) \ |
37 | #define TIMING_TEST_PRINT_RESULT(id) \ |
38 | do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ |
38 | 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__,\ |
39 | 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) |
40 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) |
41 | |
41 | |
… | |
… | |
87 | * scale Scale both up and down |
87 | * scale Scale both up and down |
88 | * auto Same as 100x100+50+50 |
88 | * auto Same as 100x100+50+50 |
89 | */ |
89 | */ |
90 | |
90 | |
91 | #ifdef HAVE_BG_PIXMAP |
91 | #ifdef HAVE_BG_PIXMAP |
92 | bgPixmap_t::bgPixmap_t() |
92 | bgPixmap_t::bgPixmap_t () |
93 | { |
93 | { |
94 | #ifdef HAVE_AFTERIMAGE |
94 | #ifdef HAVE_AFTERIMAGE |
95 | original_asim = NULL; |
95 | original_asim = NULL; |
96 | #endif |
96 | #endif |
97 | #ifdef BG_IMAGE_FROM_FILE |
97 | #ifdef BG_IMAGE_FROM_FILE |
… | |
… | |
100 | #endif |
100 | #endif |
101 | flags = 0; |
101 | flags = 0; |
102 | pixmap = None; |
102 | pixmap = None; |
103 | } |
103 | } |
104 | |
104 | |
|
|
105 | void |
|
|
106 | bgPixmap_t::destroy () |
|
|
107 | { |
|
|
108 | #ifdef HAVE_AFTERIMAGE |
|
|
109 | if (original_asim) |
|
|
110 | safe_asimage_destroy (original_asim); |
|
|
111 | #endif |
|
|
112 | |
|
|
113 | if (pixmap && target) |
|
|
114 | XFreePixmap (target->dpy, pixmap); |
|
|
115 | } |
105 | |
116 | |
106 | bool |
117 | bool |
107 | bgPixmap_t::window_size_sensitive () |
118 | bgPixmap_t::window_size_sensitive () |
108 | { |
119 | { |
|
|
120 | # ifdef ENABLE_TRANSPARENCY |
|
|
121 | if (flags & isTransparent) |
|
|
122 | return true; |
|
|
123 | # endif |
|
|
124 | |
109 | # ifdef BG_IMAGE_FROM_FILE |
125 | # ifdef BG_IMAGE_FROM_FILE |
110 | # ifdef HAVE_AFTERIMAGE |
126 | # ifdef HAVE_AFTERIMAGE |
111 | if (original_asim != NULL) |
127 | if (original_asim != NULL) |
112 | # endif |
128 | # endif |
113 | { |
129 | { |
114 | if (h_scale != 0 || v_scale != 0 |
130 | if (h_scale != 0 || v_scale != 0 |
115 | || h_align != 0 || v_align != 0) |
131 | || h_align != 0 || v_align != 0) |
116 | return true; |
132 | return true; |
117 | } |
133 | } |
118 | # endif |
134 | # endif |
|
|
135 | |
|
|
136 | return false; |
|
|
137 | } |
|
|
138 | |
|
|
139 | bool |
|
|
140 | bgPixmap_t::window_position_sensitive () |
|
|
141 | { |
119 | # ifdef ENABLE_TRANSPARENCY |
142 | # ifdef ENABLE_TRANSPARENCY |
120 | if (flags & isTransparent) |
143 | if (flags & isTransparent) |
121 | return true; |
144 | return true; |
122 | # endif |
145 | # endif |
|
|
146 | |
|
|
147 | # ifdef BG_IMAGE_FROM_FILE |
|
|
148 | # ifdef HAVE_AFTERIMAGE |
|
|
149 | if (original_asim != NULL) |
|
|
150 | # endif |
|
|
151 | { |
|
|
152 | if (h_align == rootAlign || v_align == rootAlign) |
|
|
153 | return true; |
|
|
154 | } |
|
|
155 | # endif |
|
|
156 | |
123 | return false; |
157 | return false; |
124 | } |
158 | }; |
125 | |
159 | |
126 | bool bgPixmap_t::need_client_side_rendering () |
160 | bool bgPixmap_t::need_client_side_rendering () |
127 | { |
161 | { |
128 | # ifdef HAVE_AFTERIMAGE |
162 | # ifdef HAVE_AFTERIMAGE |
129 | if (original_asim != NULL) |
163 | if (original_asim != NULL) |
130 | return true; |
164 | return true; |
131 | # endif |
165 | # endif |
132 | # ifdef ENABLE_TRANSPARENCY |
166 | # ifdef ENABLE_TRANSPARENCY |
133 | if (flags & isTransparent) |
167 | if (flags & isTransparent) |
134 | { |
168 | { |
|
|
169 | # ifdef HAVE_AFTERIMAGE // can't blur without libAI anyways |
135 | if (((flags & blurNeeded) && !(flags & blurServerSide)) |
170 | if ((flags & blurNeeded) && !(flags & blurServerSide)) |
|
|
171 | return true; |
|
|
172 | # endif |
136 | || ((flags & tintNeeded) && !(flags & tintServerSide))) |
173 | if ((flags & tintNeeded) && !(flags & tintServerSide)) |
137 | return true; |
174 | return true; |
138 | } |
175 | } |
139 | # endif |
176 | # endif |
140 | return false; |
177 | return false; |
141 | } |
178 | } |
142 | |
179 | |
… | |
… | |
160 | static inline bool |
197 | static inline bool |
161 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
198 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
162 | { |
199 | { |
163 | if (geom_flags & flag) |
200 | if (geom_flags & flag) |
164 | { |
201 | { |
|
|
202 | if (new_value != bgPixmap_t::rootAlign) |
|
|
203 | { |
165 | if (new_value < -100) |
204 | if (new_value < -100) |
166 | new_value = -100; |
205 | new_value = -100; |
167 | else if (new_value > 200) |
206 | else if (new_value > 200) |
168 | new_value = 200; |
207 | new_value = 200; |
|
|
208 | } |
169 | if (new_value != align) |
209 | if (new_value != align) |
170 | { |
210 | { |
171 | align = new_value; |
211 | align = new_value; |
172 | return true; |
212 | return true; |
173 | } |
213 | } |
… | |
… | |
315 | else if (!(flags & geometrySet)) |
355 | else if (!(flags & geometrySet)) |
316 | { /* default geometry - scaled and centered */ |
356 | { /* default geometry - scaled and centered */ |
317 | x = y = defaultAlign; |
357 | x = y = defaultAlign; |
318 | w = h = defaultScale; |
358 | w = h = defaultScale; |
319 | } |
359 | } |
320 | |
360 | |
321 | if (!(flags & geometrySet)) |
361 | if (!(flags & geometrySet)) |
322 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
362 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
323 | |
363 | |
324 | if (ops) |
364 | if (ops) |
325 | { |
365 | { |
… | |
… | |
327 | { |
367 | { |
328 | while (*ops == ':' || isspace(*ops)) ++ops; |
368 | while (*ops == ':' || isspace(*ops)) ++ops; |
329 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) |
369 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) |
330 | if (CHECK_GEOM_OPS("tile")) |
370 | if (CHECK_GEOM_OPS("tile")) |
331 | { |
371 | { |
332 | w = h = 0; |
372 | w = h = noScale; |
333 | geom_flags |= WidthValue|HeightValue; |
373 | geom_flags |= WidthValue|HeightValue; |
334 | } |
374 | } |
335 | else if (CHECK_GEOM_OPS("propscale")) |
375 | else if (CHECK_GEOM_OPS("propscale")) |
336 | { |
376 | { |
337 | if (w == 0 && h == 0) |
377 | if (w == 0 && h == 0) |
338 | { |
378 | { |
339 | w = 100; |
379 | w = windowScale; |
340 | geom_flags |= WidthValue; |
380 | geom_flags |= WidthValue; |
341 | } |
381 | } |
342 | new_flags |= propScale; |
382 | new_flags |= propScale; |
343 | } |
383 | } |
344 | else if (CHECK_GEOM_OPS("hscale")) |
384 | else if (CHECK_GEOM_OPS("hscale")) |
345 | { |
385 | { |
346 | if (w == 0) |
386 | if (w == 0) |
347 | w = 100; |
387 | w = windowScale; |
348 | h = 0; |
388 | h = noScale; |
349 | geom_flags |= WidthValue|HeightValue; |
389 | geom_flags |= WidthValue|HeightValue; |
350 | } |
390 | } |
351 | else if (CHECK_GEOM_OPS("vscale")) |
391 | else if (CHECK_GEOM_OPS("vscale")) |
352 | { |
392 | { |
353 | if (h == 0) |
393 | if (h == 0) |
354 | h = 100; |
394 | h = windowScale; |
355 | w = 0; |
395 | w = noScale; |
356 | geom_flags |= WidthValue|HeightValue; |
396 | geom_flags |= WidthValue|HeightValue; |
357 | } |
397 | } |
358 | else if (CHECK_GEOM_OPS("scale")) |
398 | else if (CHECK_GEOM_OPS("scale")) |
359 | { |
399 | { |
360 | if (h == 0) |
400 | if (h == 0) |
361 | h = 100; |
401 | h = windowScale; |
362 | if (w == 0) |
402 | if (w == 0) |
363 | w = 100; |
403 | w = windowScale; |
364 | geom_flags |= WidthValue|HeightValue; |
404 | geom_flags |= WidthValue|HeightValue; |
365 | } |
405 | } |
366 | else if (CHECK_GEOM_OPS("auto")) |
406 | else if (CHECK_GEOM_OPS("auto")) |
367 | { |
407 | { |
|
|
408 | w = h = windowScale; |
|
|
409 | x = y = centerAlign; |
|
|
410 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
|
|
411 | } |
|
|
412 | else if (CHECK_GEOM_OPS("root")) |
|
|
413 | { |
368 | w = h = 100; |
414 | w = h = noScale; |
369 | x = y = 50; |
415 | x = y = rootAlign; |
370 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
416 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
371 | } |
417 | } |
372 | # undef CHECK_GEOM_OPS |
418 | # undef CHECK_GEOM_OPS |
373 | while (*ops != ':' && *ops != '\0') ++ops; |
419 | while (*ops != ':' && *ops != '\0') ++ops; |
374 | } /* done parsing ops */ |
420 | } /* done parsing ops */ |
… | |
… | |
413 | |
459 | |
414 | TIMING_TEST_START (asim); |
460 | TIMING_TEST_START (asim); |
415 | |
461 | |
416 | if (original_asim) |
462 | if (original_asim) |
417 | { |
463 | { |
|
|
464 | if (h_align == rootAlign || v_align == rootAlign) |
|
|
465 | { |
|
|
466 | target->get_window_origin(x, y); |
|
|
467 | x = -x; |
|
|
468 | y = -y; |
|
|
469 | } |
|
|
470 | if (h_align != rootAlign) |
418 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
471 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
|
|
472 | if (v_align != rootAlign) |
419 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
473 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
420 | } |
474 | } |
421 | |
475 | |
422 | if (original_asim == NULL |
476 | if (original_asim == NULL |
423 | || x >= target_width |
477 | || x >= target_width |
424 | || y >= target_height |
478 | || y >= target_height |
… | |
… | |
446 | { |
500 | { |
447 | result = original_asim; |
501 | result = original_asim; |
448 | if ((w > 0 && w != original_asim->width) |
502 | if ((w > 0 && w != original_asim->width) |
449 | || (h > 0 && h != original_asim->height)) |
503 | || (h > 0 && h != original_asim->height)) |
450 | { |
504 | { |
451 | result = scale_asimage (target->asv, original_asim, |
505 | result = scale_asimage (target->asv, original_asim, |
452 | w > 0 ? w : original_asim->width, |
506 | w > 0 ? w : original_asim->width, |
453 | h > 0 ? h : original_asim->height, |
507 | h > 0 ? h : original_asim->height, |
454 | background ? ASA_ASImage : ASA_XImage, |
508 | background ? ASA_ASImage : ASA_XImage, |
455 | 100, ASIMAGE_QUALITY_DEFAULT); |
509 | 100, ASIMAGE_QUALITY_DEFAULT); |
456 | } |
510 | } |
457 | if (background == NULL) |
511 | if (background == NULL) |
458 | {/* if tiling - pixmap has to be sized exactly as the image */ |
512 | {/* if tiling - pixmap has to be sized exactly as the image, |
|
|
513 | but there is no need to make it bigger then the window! */ |
459 | if (h_scale == 0) |
514 | if (h_scale == 0) |
460 | new_pmap_width = result->width; |
515 | new_pmap_width = min (result->width, target_width); |
461 | if (v_scale == 0) |
516 | if (v_scale == 0) |
462 | new_pmap_height = result->height; |
517 | new_pmap_height = min (result->height, target_height); |
463 | /* we also need to tile our image in one or both directions */ |
518 | /* we also need to tile our image in one or both directions */ |
464 | if (h_scale == 0 || v_scale == 0) |
519 | if (h_scale == 0 || v_scale == 0) |
465 | { |
520 | { |
466 | ASImage *tmp = tile_asimage (target->asv, result, |
521 | ASImage *tmp = tile_asimage (target->asv, result, |
467 | (h_scale > 0) ? 0 : (int)result->width - x, |
522 | (h_scale > 0) ? 0 : (int)result->width - x, |
468 | (v_scale > 0) ? 0 : (int)result->height - y, |
523 | (v_scale > 0) ? 0 : (int)result->height - y, |
|
|
524 | new_pmap_width, |
469 | result->width, result->height, |
525 | new_pmap_height, |
470 | TINT_LEAVE_SAME, ASA_XImage, |
526 | TINT_LEAVE_SAME, ASA_XImage, |
471 | 100, ASIMAGE_QUALITY_DEFAULT); |
527 | 100, ASIMAGE_QUALITY_DEFAULT); |
472 | if (tmp) |
528 | if (tmp) |
473 | { |
529 | { |
474 | if (result != original_asim) |
530 | if (result != original_asim) |
… | |
… | |
575 | } |
631 | } |
576 | |
632 | |
577 | /* put result on pixmap */ |
633 | /* put result on pixmap */ |
578 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
634 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
579 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
635 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
580 | |
636 | |
581 | if (result != background && result != original_asim) |
637 | if (result != background && result != original_asim) |
582 | destroy_asimage (&result); |
638 | destroy_asimage (&result); |
583 | |
639 | |
584 | XFreeGC (target->dpy, gc); |
640 | XFreeGC (target->dpy, gc); |
585 | TIMING_TEST_PRINT_RESULT (asim); |
641 | TIMING_TEST_PRINT_RESULT (asim); |
… | |
… | |
611 | f[len] = '\0'; |
667 | f[len] = '\0'; |
612 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
668 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
613 | free (f); |
669 | free (f); |
614 | } |
670 | } |
615 | return (original_asim != NULL); |
671 | return (original_asim != NULL); |
616 | # endif |
672 | # endif |
617 | } |
673 | } |
618 | return false; |
674 | return false; |
619 | } |
675 | } |
620 | |
676 | |
621 | # endif /* BG_IMAGE_FROM_FILE */ |
677 | # endif /* BG_IMAGE_FROM_FILE */ |
622 | |
678 | |
623 | # ifdef ENABLE_TRANSPARENCY |
679 | # ifdef ENABLE_TRANSPARENCY |
624 | bool |
680 | bool |
625 | bgPixmap_t::set_transparent () |
681 | bgPixmap_t::set_transparent () |
626 | { |
682 | { |
627 | if (!(flags & isTransparent)) |
683 | if (!(flags & isTransparent)) |
628 | { |
684 | { |
629 | flags |= isTransparent; |
685 | flags |= isTransparent; |
… | |
… | |
654 | if (v_blurRadius != vr) |
710 | if (v_blurRadius != vr) |
655 | { |
711 | { |
656 | ++changed; |
712 | ++changed; |
657 | v_blurRadius = vr; |
713 | v_blurRadius = vr; |
658 | } |
714 | } |
659 | |
715 | |
660 | if (v_blurRadius == 0 && h_blurRadius == 0) |
716 | if (v_blurRadius == 0 && h_blurRadius == 0) |
661 | flags &= ~blurNeeded; |
717 | flags &= ~blurNeeded; |
662 | else |
718 | else |
663 | flags |= blurNeeded; |
719 | flags |= blurNeeded; |
664 | |
720 | |
… | |
… | |
691 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
747 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
692 | { |
748 | { |
693 | flags |= bgPixmap_t::tintNeeded; |
749 | flags |= bgPixmap_t::tintNeeded; |
694 | } |
750 | } |
695 | } |
751 | } |
696 | |
752 | |
697 | if (flags & bgPixmap_t::tintNeeded) |
753 | if (flags & bgPixmap_t::tintNeeded) |
698 | { |
754 | { |
699 | if (flags & bgPixmap_t::tintWholesome) |
755 | if (flags & bgPixmap_t::tintWholesome) |
700 | flags |= bgPixmap_t::tintServerSide; |
756 | flags |= bgPixmap_t::tintServerSide; |
701 | else |
757 | else |
… | |
… | |
738 | bool |
794 | bool |
739 | bgPixmap_t::set_shade (const char *shade_str) |
795 | bgPixmap_t::set_shade (const char *shade_str) |
740 | { |
796 | { |
741 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
797 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
742 | |
798 | |
|
|
799 | if (new_shade < 0 && new_shade > -100) |
|
|
800 | new_shade = 200 - (100 + new_shade); |
743 | if (new_shade == 100) |
801 | else if (new_shade == 100) |
744 | new_shade = 0; |
802 | new_shade = 0; |
745 | |
803 | |
746 | if (new_shade != shade) |
804 | if (new_shade != shade) |
747 | { |
805 | { |
748 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
806 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
… | |
… | |
751 | return true; |
809 | return true; |
752 | } |
810 | } |
753 | return false; |
811 | return false; |
754 | } |
812 | } |
755 | |
813 | |
756 | /* make_transparency_pixmap() |
814 | /* make_transparency_pixmap() |
757 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
815 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
758 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
816 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
759 | * our window. |
817 | * our window. |
760 | */ |
818 | */ |
761 | unsigned long |
819 | unsigned long |
762 | bgPixmap_t::make_transparency_pixmap () |
820 | bgPixmap_t::make_transparency_pixmap () |
763 | { |
821 | { |
… | |
… | |
862 | else |
920 | else |
863 | {/* strightforward pixmap copy */ |
921 | {/* strightforward pixmap copy */ |
864 | gcv.tile = root_pixmap; |
922 | gcv.tile = root_pixmap; |
865 | gcv.fill_style = FillTiled; |
923 | gcv.fill_style = FillTiled; |
866 | |
924 | |
867 | while (sx < 0) sx += (int)window_width; |
925 | while (sx < 0) sx += (int)root_width; |
868 | while (sy < 0) sy += (int)window_height; |
926 | while (sy < 0) sy += (int)root_height; |
869 | |
927 | |
870 | gcv.ts_x_origin = -sx; |
928 | gcv.ts_x_origin = -sx; |
871 | gcv.ts_y_origin = -sy; |
929 | gcv.ts_y_origin = -sy; |
872 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
930 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
873 | |
931 | |
… | |
… | |
879 | } |
937 | } |
880 | TIMING_TEST_PRINT_RESULT (tp); |
938 | TIMING_TEST_PRINT_RESULT (tp); |
881 | |
939 | |
882 | if (tiled_root_pmap != None) |
940 | if (tiled_root_pmap != None) |
883 | { |
941 | { |
884 | if (!need_client_side_rendering ()) |
942 | if (!need_client_side_rendering ()) |
885 | { |
943 | { |
886 | if ((flags & tintNeeded)) |
944 | if ((flags & tintNeeded)) |
887 | { |
945 | { |
888 | if (flags & tintWholesome) |
946 | if (flags & tintWholesome) |
889 | { |
947 | { |
890 | /* In this case we can tint image server-side getting significant |
948 | /* In this case we can tint image server-side getting significant |
891 | * performance improvements, as we eliminate XImage transfer |
949 | * performance improvements, as we eliminate XImage transfer |
… | |
… | |
932 | pf.direct.greenMask = 0xff; |
990 | pf.direct.greenMask = 0xff; |
933 | pf.direct.blueMask = 0xff; |
991 | pf.direct.blueMask = 0xff; |
934 | pf.direct.alphaMask = 0xff; |
992 | pf.direct.alphaMask = 0xff; |
935 | |
993 | |
936 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
994 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
937 | (PictFormatType| |
995 | (PictFormatType| |
938 | PictFormatDepth| |
996 | PictFormatDepth| |
939 | PictFormatRedMask| |
997 | PictFormatRedMask| |
940 | PictFormatGreenMask| |
998 | PictFormatGreenMask| |
941 | PictFormatBlueMask| |
999 | PictFormatBlueMask| |
942 | PictFormatAlphaMask), |
1000 | PictFormatAlphaMask), |
943 | &pf, |
1001 | &pf, |
944 | 0); |
1002 | 0); |
945 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
1003 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
946 | XRenderPictureAttributes pa ; |
1004 | XRenderPictureAttributes pa ; |
947 | |
1005 | |
948 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
1006 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
949 | |
1007 | |
… | |
… | |
951 | |
1009 | |
952 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
1010 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
953 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
1011 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
954 | XFreePixmap (dpy, overlay_pmap); |
1012 | XFreePixmap (dpy, overlay_pmap); |
955 | |
1013 | |
956 | pa.component_alpha = True; |
1014 | pa.component_alpha = True; |
957 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
1015 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
958 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
1016 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
959 | XFreePixmap (dpy, mask_pmap); |
1017 | XFreePixmap (dpy, mask_pmap); |
960 | |
1018 | |
961 | if (mask_pic && overlay_pic && back_pic) |
1019 | if (mask_pic && overlay_pic && back_pic) |
… | |
… | |
977 | XRenderFreePicture (dpy, mask_pic); |
1035 | XRenderFreePicture (dpy, mask_pic); |
978 | XRenderFreePicture (dpy, overlay_pic); |
1036 | XRenderFreePicture (dpy, overlay_pic); |
979 | XRenderFreePicture (dpy, back_pic); |
1037 | XRenderFreePicture (dpy, back_pic); |
980 | # if DO_TIMING_TEST |
1038 | # if DO_TIMING_TEST |
981 | XSync (dpy, False); |
1039 | XSync (dpy, False); |
982 | # endif |
1040 | # endif |
983 | # endif |
1041 | # endif |
984 | } |
1042 | } |
985 | } |
1043 | } |
986 | } /* server side rendering completed */ |
1044 | } /* server side rendering completed */ |
987 | |
1045 | |
… | |
… | |
991 | pixmap = tiled_root_pmap; |
1049 | pixmap = tiled_root_pmap; |
992 | pmap_width = window_width; |
1050 | pmap_width = window_width; |
993 | pmap_height = window_height; |
1051 | pmap_height = window_height; |
994 | pmap_depth = root_depth; |
1052 | pmap_depth = root_depth; |
995 | } |
1053 | } |
996 | |
1054 | |
997 | if (gc) |
1055 | if (gc) |
998 | XFreeGC (dpy, gc); |
1056 | XFreeGC (dpy, gc); |
999 | |
1057 | |
1000 | TIMING_TEST_PRINT_RESULT (tp); |
1058 | TIMING_TEST_PRINT_RESULT (tp); |
1001 | |
1059 | |
1002 | return result; |
1060 | return result; |
1003 | } |
1061 | } |
1004 | |
1062 | |
1005 | bool |
1063 | bool |
1006 | bgPixmap_t::set_root_pixmap () |
1064 | bgPixmap_t::set_root_pixmap () |
1007 | { |
1065 | { |
1008 | Pixmap new_root_pixmap = None; |
1066 | Pixmap new_root_pixmap = None; |
1009 | |
1067 | |
1010 | new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1068 | new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1011 | if (new_root_pixmap == None) |
1069 | if (new_root_pixmap == None) |
1012 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1070 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1013 | |
1071 | |
1014 | if (new_root_pixmap != root_pixmap) |
1072 | if (new_root_pixmap != root_pixmap) |
… | |
… | |
1094 | } |
1152 | } |
1095 | else if (background_flags && pmap_depth != target->depth) |
1153 | else if (background_flags && pmap_depth != target->depth) |
1096 | { |
1154 | { |
1097 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1155 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1098 | } |
1156 | } |
|
|
1157 | |
1099 | # else /* our own client-side tinting */ |
1158 | # elif !XFT /* our own client-side tinting */ |
|
|
1159 | |
|
|
1160 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. |
|
|
1161 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
|
|
1162 | |
1100 | if (background_flags && (flags & isInvalid)) |
1163 | if (background_flags && (flags & isInvalid)) |
1101 | { |
1164 | { |
1102 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1165 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1103 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1166 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1104 | { |
1167 | { |
… | |
… | |
1157 | |
1220 | |
1158 | apply (); |
1221 | apply (); |
1159 | |
1222 | |
1160 | TIMING_TEST_PRINT_RESULT (tp); |
1223 | TIMING_TEST_PRINT_RESULT (tp); |
1161 | |
1224 | |
1162 | return true; |
1225 | return true; |
1163 | } |
1226 | } |
1164 | |
1227 | |
1165 | bool |
1228 | bool |
1166 | bgPixmap_t::set_target (rxvt_term *new_target) |
1229 | bgPixmap_t::set_target (rxvt_term *new_target) |
1167 | { |
1230 | { |
1168 | if (new_target) |
1231 | if (new_target) |
1169 | if (target != new_target) |
1232 | if (target != new_target) |
1170 | { |
1233 | { |
… | |
… | |
1217 | # if HAVE_SCROLLBARS |
1280 | # if HAVE_SCROLLBARS |
1218 | if (target->scrollBar.win) |
1281 | if (target->scrollBar.win) |
1219 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1282 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1220 | # endif |
1283 | # endif |
1221 | } |
1284 | } |
1222 | |
1285 | /* don't want Expose on the parent or vt. It is better to use |
1223 | /* don't want Expose on the parent */ |
1286 | scr_touch or we get a great deal of flicker otherwise: */ |
1224 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
1287 | XClearWindow (target->dpy, target->parent[0]); |
1225 | /* do want Expose on the vt, so we get refreshed properly */ |
|
|
1226 | XClearArea (target->dpy, target->vt, 0, 0, 0, 0, True); |
|
|
1227 | |
1288 | |
1228 | # if HAVE_SCROLLBARS |
1289 | # if HAVE_SCROLLBARS |
1229 | if (target->scrollBar.win) |
1290 | if (target->scrollBar.win) |
1230 | { |
1291 | { |
1231 | target->scrollBar.setIdle (); |
1292 | target->scrollBar.setIdle (); |
1232 | target->scrollbar_show (0); |
1293 | target->scrollbar_show (0); |
1233 | } |
1294 | } |
1234 | # endif |
1295 | # endif |
1235 | } |
|
|
1236 | } |
|
|
1237 | |
1296 | |
|
|
1297 | target->want_refresh = 1; |
|
|
1298 | flags |= hasChanged; |
|
|
1299 | } |
|
|
1300 | } |
|
|
1301 | |
1238 | #endif /* HAVE_BG_PIXMAP */ |
1302 | #endif /* HAVE_BG_PIXMAP */ |
1239 | |
1303 | |
1240 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1304 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT |
1241 | /* taken from aterm-0.4.2 */ |
1305 | /* taken from aterm-0.4.2 */ |
1242 | |
1306 | |
1243 | typedef uint32_t RUINT32T; |
1307 | typedef uint32_t RUINT32T; |
1244 | |
1308 | |
1245 | static void |
1309 | static void |