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 ? |
… | |
… | |
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 |
97 | #ifdef BG_IMAGE_FROM_FILE |
101 | #ifdef BG_IMAGE_FROM_FILE |
|
|
102 | have_image = false; |
98 | h_scale = v_scale = 0; |
103 | h_scale = v_scale = 0; |
99 | h_align = v_align = 0; |
104 | h_align = v_align = 0; |
100 | #endif |
105 | #endif |
101 | flags = 0; |
106 | flags = 0; |
102 | pixmap = None; |
107 | pixmap = None; |
… | |
… | |
123 | if (flags & isTransparent) |
128 | if (flags & isTransparent) |
124 | return true; |
129 | return true; |
125 | # endif |
130 | # endif |
126 | |
131 | |
127 | # ifdef BG_IMAGE_FROM_FILE |
132 | # ifdef BG_IMAGE_FROM_FILE |
128 | # ifdef HAVE_AFTERIMAGE |
133 | if (have_image) |
129 | if (original_asim) |
|
|
130 | # endif |
|
|
131 | { |
134 | { |
132 | if (h_scale != 0 || v_scale != 0 |
135 | if (h_scale != 0 || v_scale != 0 |
133 | || h_align != 0 || v_align != 0) |
136 | || h_align != 0 || v_align != 0) |
134 | return true; |
137 | return true; |
135 | } |
138 | } |
136 | # endif |
139 | # endif |
137 | |
140 | |
138 | return false; |
141 | return false; |
139 | } |
142 | } |
140 | |
143 | |
141 | bool |
144 | bool |
142 | bgPixmap_t::window_position_sensitive () |
145 | bgPixmap_t::window_position_sensitive () |
143 | { |
146 | { |
144 | # ifdef ENABLE_TRANSPARENCY |
147 | # ifdef ENABLE_TRANSPARENCY |
145 | if (flags & isTransparent) |
148 | if (flags & isTransparent) |
146 | return true; |
149 | return true; |
147 | # endif |
150 | # endif |
148 | |
151 | |
149 | # ifdef BG_IMAGE_FROM_FILE |
152 | # ifdef BG_IMAGE_FROM_FILE |
150 | # ifdef HAVE_AFTERIMAGE |
153 | if (have_image) |
151 | if (original_asim) |
|
|
152 | # endif |
|
|
153 | { |
154 | { |
154 | if (h_align == rootAlign || v_align == rootAlign) |
155 | if (h_align == rootAlign || v_align == rootAlign) |
155 | return true; |
156 | return true; |
156 | } |
157 | } |
157 | # endif |
158 | # endif |
… | |
… | |
259 | int geom_flags = 0, changed = 0; |
260 | int geom_flags = 0, changed = 0; |
260 | int x = 0, y = 0; |
261 | int x = 0, y = 0; |
261 | unsigned int w = 0, h = 0; |
262 | unsigned int w = 0, h = 0; |
262 | unsigned int n; |
263 | unsigned int n; |
263 | unsigned long new_flags = (flags & (~geometryFlags)); |
264 | unsigned long new_flags = (flags & (~geometryFlags)); |
264 | char *p; |
265 | const char *p; |
265 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
266 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
266 | |
267 | |
267 | if (geom == NULL) |
268 | if (geom == NULL) |
268 | return false; |
269 | return false; |
269 | |
270 | |
… | |
… | |
370 | if (ops) |
371 | if (ops) |
371 | { |
372 | { |
372 | while (*ops) |
373 | while (*ops) |
373 | { |
374 | { |
374 | while (*ops == ':' || isspace(*ops)) ++ops; |
375 | while (*ops == ':' || isspace(*ops)) ++ops; |
|
|
376 | |
375 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) |
377 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof (op_str) - 1) == 0) |
376 | if (CHECK_GEOM_OPS("tile")) |
378 | if (CHECK_GEOM_OPS ("tile")) |
377 | { |
379 | { |
378 | w = h = noScale; |
380 | w = h = noScale; |
379 | geom_flags |= WidthValue|HeightValue; |
381 | geom_flags |= WidthValue|HeightValue; |
380 | } |
382 | } |
381 | else if (CHECK_GEOM_OPS("propscale")) |
383 | else if (CHECK_GEOM_OPS ("propscale")) |
382 | { |
384 | { |
383 | if (w == 0 && h == 0) |
385 | if (w == 0 && h == 0) |
384 | { |
386 | { |
385 | w = windowScale; |
387 | w = windowScale; |
386 | geom_flags |= WidthValue; |
388 | geom_flags |= WidthValue; |
387 | } |
389 | } |
388 | new_flags |= propScale; |
390 | new_flags |= propScale; |
389 | } |
391 | } |
390 | else if (CHECK_GEOM_OPS("hscale")) |
392 | else if (CHECK_GEOM_OPS ("hscale")) |
391 | { |
393 | { |
392 | if (w == 0) |
|
|
393 | w = windowScale; |
394 | if (w == 0) w = windowScale; |
|
|
395 | |
394 | h = noScale; |
396 | h = noScale; |
395 | geom_flags |= WidthValue|HeightValue; |
397 | geom_flags |= WidthValue|HeightValue; |
396 | } |
398 | } |
397 | else if (CHECK_GEOM_OPS("vscale")) |
399 | else if (CHECK_GEOM_OPS ("vscale")) |
398 | { |
400 | { |
399 | if (h == 0) |
|
|
400 | h = windowScale; |
401 | if (h == 0) h = windowScale; |
|
|
402 | |
401 | w = noScale; |
403 | w = noScale; |
402 | geom_flags |= WidthValue|HeightValue; |
404 | geom_flags |= WidthValue|HeightValue; |
403 | } |
405 | } |
404 | else if (CHECK_GEOM_OPS("scale")) |
406 | else if (CHECK_GEOM_OPS ("scale")) |
405 | { |
407 | { |
406 | if (h == 0) |
|
|
407 | h = windowScale; |
408 | if (h == 0) h = windowScale; |
408 | if (w == 0) |
|
|
409 | w = windowScale; |
409 | if (w == 0) w = windowScale; |
|
|
410 | |
410 | geom_flags |= WidthValue|HeightValue; |
411 | geom_flags |= WidthValue|HeightValue; |
411 | } |
412 | } |
412 | else if (CHECK_GEOM_OPS("auto")) |
413 | else if (CHECK_GEOM_OPS ("auto")) |
413 | { |
414 | { |
414 | w = h = windowScale; |
415 | w = h = windowScale; |
415 | x = y = centerAlign; |
416 | x = y = centerAlign; |
416 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
417 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
417 | } |
418 | } |
418 | else if (CHECK_GEOM_OPS("root")) |
419 | else if (CHECK_GEOM_OPS ("root")) |
419 | { |
420 | { |
420 | w = h = noScale; |
421 | w = h = noScale; |
421 | x = y = rootAlign; |
422 | x = y = rootAlign; |
422 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
423 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
423 | } |
424 | } |
424 | # undef CHECK_GEOM_OPS |
425 | # undef CHECK_GEOM_OPS |
|
|
426 | |
425 | while (*ops != ':' && *ops != '\0') ++ops; |
427 | while (*ops != ':' && *ops != '\0') ++ops; |
426 | } /* done parsing ops */ |
428 | } /* done parsing ops */ |
427 | } |
429 | } |
428 | |
430 | |
429 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) |
431 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) ++changed; |
430 | ++changed; |
|
|
431 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) |
432 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) ++changed; |
432 | ++changed; |
|
|
433 | if (check_set_align_value (geom_flags, XValue, h_align, x)) |
433 | if (check_set_align_value (geom_flags, XValue, h_align, x)) ++changed; |
434 | ++changed; |
|
|
435 | if (check_set_align_value (geom_flags, YValue, v_align, y)) |
434 | if (check_set_align_value (geom_flags, YValue, v_align, y)) ++changed; |
436 | ++changed; |
|
|
437 | } |
435 | } |
438 | |
436 | |
439 | if (new_flags != flags) |
437 | if (new_flags != flags) |
440 | { |
438 | { |
441 | flags = new_flags; |
439 | flags = new_flags; |
442 | changed++; |
440 | changed++; |
443 | } |
441 | } |
|
|
442 | |
444 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
443 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
445 | // flags, h_scale, v_scale, h_align, v_align); |
444 | // flags, h_scale, v_scale, h_align, v_align); |
446 | return (changed > 0); |
445 | return (changed > 0); |
447 | } |
446 | } |
448 | |
447 | |
449 | # ifdef HAVE_AFTERIMAGE |
448 | # ifdef HAVE_AFTERIMAGE |
450 | bool |
449 | bool |
451 | bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) |
450 | bgPixmap_t::render_image (unsigned long background_flags) |
452 | { |
451 | { |
453 | if (target == NULL) |
452 | if (target == NULL) |
454 | return false; |
453 | return false; |
455 | |
454 | |
|
|
455 | target->init_asv (); |
|
|
456 | |
|
|
457 | ASImage *background = NULL; |
|
|
458 | ARGB32 background_tint = TINT_LEAVE_SAME; |
|
|
459 | |
|
|
460 | # ifdef ENABLE_TRANSPARENCY |
|
|
461 | if (background_flags) |
|
|
462 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
|
|
463 | |
|
|
464 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
|
|
465 | { |
|
|
466 | ShadingInfo as_shade; |
|
|
467 | as_shade.shading = (shade == 0) ? 100 : shade; |
|
|
468 | |
|
|
469 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
470 | if (flags & tintSet) |
|
|
471 | tint.get (c); |
|
|
472 | as_shade.tintColor.red = c.r; |
|
|
473 | as_shade.tintColor.green = c.g; |
|
|
474 | as_shade.tintColor.blue = c.b; |
|
|
475 | |
|
|
476 | background_tint = shading2tint32 (&as_shade); |
|
|
477 | } |
|
|
478 | |
|
|
479 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
480 | { |
|
|
481 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
482 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
|
|
483 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
484 | if (tmp) |
|
|
485 | { |
|
|
486 | destroy_asimage (&background); |
|
|
487 | background = tmp; |
|
|
488 | } |
|
|
489 | } |
|
|
490 | # endif |
|
|
491 | |
|
|
492 | ASImage *result = 0; |
|
|
493 | |
456 | int target_width = (int)target->szHint.width; |
494 | int target_width = target->szHint.width; |
457 | int target_height = (int)target->szHint.height; |
495 | int target_height = target->szHint.height; |
458 | int new_pmap_width = target_width, new_pmap_height = target_height; |
496 | int new_pmap_width = target_width; |
459 | ASImage *result = NULL; |
497 | int new_pmap_height = target_height; |
460 | |
498 | |
461 | int x = 0; |
499 | int x = 0; |
462 | int y = 0; |
500 | int y = 0; |
463 | int w = h_scale * target_width / 100; |
501 | int w = h_scale * target_width / 100; |
464 | int h = v_scale * target_height / 100; |
502 | int h = v_scale * target_height / 100; |
… | |
… | |
467 | |
505 | |
468 | if (original_asim) |
506 | if (original_asim) |
469 | { |
507 | { |
470 | if (h_align == rootAlign || v_align == rootAlign) |
508 | if (h_align == rootAlign || v_align == rootAlign) |
471 | { |
509 | { |
472 | target->get_window_origin(x, y); |
510 | target->get_window_origin (x, y); |
473 | x = -x; |
511 | x = -x; |
474 | y = -y; |
512 | y = -y; |
475 | } |
513 | } |
476 | |
514 | |
477 | if (h_align != rootAlign) |
515 | if (h_align != rootAlign) |
… | |
… | |
493 | new_pmap_height = background->height; |
531 | new_pmap_height = background->height; |
494 | result = background; |
532 | result = background; |
495 | |
533 | |
496 | if (background_tint != TINT_LEAVE_SAME) |
534 | if (background_tint != TINT_LEAVE_SAME) |
497 | { |
535 | { |
498 | ASImage* tmp = tile_asimage (target->asv, background, 0, 0, |
536 | ASImage *tmp = tile_asimage (target->asv, background, 0, 0, |
499 | target_width, target_height, background_tint, |
537 | target_width, target_height, background_tint, |
500 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
538 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
501 | if (tmp) |
539 | if (tmp) |
502 | result = tmp; |
540 | result = tmp; |
503 | } |
541 | } |
… | |
… | |
531 | if (h_scale == 0 || v_scale == 0) |
569 | if (h_scale == 0 || v_scale == 0) |
532 | { |
570 | { |
533 | ASImage *tmp = tile_asimage (target->asv, result, |
571 | ASImage *tmp = tile_asimage (target->asv, result, |
534 | (h_scale > 0) ? 0 : (int)result->width - x, |
572 | (h_scale > 0) ? 0 : (int)result->width - x, |
535 | (v_scale > 0) ? 0 : (int)result->height - y, |
573 | (v_scale > 0) ? 0 : (int)result->height - y, |
536 | new_pmap_width, |
574 | new_pmap_width, |
537 | new_pmap_height, |
575 | new_pmap_height, |
538 | TINT_LEAVE_SAME, ASA_XImage, |
576 | TINT_LEAVE_SAME, ASA_XImage, |
539 | 100, ASIMAGE_QUALITY_DEFAULT); |
577 | 100, ASIMAGE_QUALITY_DEFAULT); |
540 | if (tmp) |
578 | if (tmp) |
541 | { |
579 | { |
… | |
… | |
548 | } |
586 | } |
549 | else |
587 | else |
550 | { |
588 | { |
551 | /* if blending background and image - pixmap has to be sized same as target window */ |
589 | /* if blending background and image - pixmap has to be sized same as target window */ |
552 | ASImageLayer *layers = create_image_layers (2); |
590 | ASImageLayer *layers = create_image_layers (2); |
553 | ASImage *merged_im = NULL; |
|
|
554 | |
591 | |
555 | layers[0].im = background; |
592 | layers[0].im = background; |
556 | layers[0].clip_width = target_width; |
593 | layers[0].clip_width = target_width; |
557 | layers[0].clip_height = target_height; |
594 | layers[0].clip_height = target_height; |
558 | layers[0].tint = background_tint; |
595 | layers[0].tint = background_tint; |
… | |
… | |
605 | free (layers); |
642 | free (layers); |
606 | } |
643 | } |
607 | } |
644 | } |
608 | TIMING_TEST_PRINT_RESULT (asim); |
645 | TIMING_TEST_PRINT_RESULT (asim); |
609 | |
646 | |
610 | if (pixmap) |
647 | bool ret = false; |
611 | { |
|
|
612 | if (result == NULL |
|
|
613 | || pmap_width != new_pmap_width |
|
|
614 | || pmap_height != new_pmap_height |
|
|
615 | || pmap_depth != target->depth) |
|
|
616 | { |
|
|
617 | XFreePixmap (target->dpy, pixmap); |
|
|
618 | pixmap = None; |
|
|
619 | } |
|
|
620 | } |
|
|
621 | |
648 | |
622 | if (result) |
649 | if (result) |
623 | { |
650 | { |
624 | XGCValues gcv; |
651 | XGCValues gcv; |
625 | GC gc; |
652 | GC gc; |
|
|
653 | |
|
|
654 | if (pixmap) |
|
|
655 | { |
|
|
656 | if (pmap_width != new_pmap_width |
|
|
657 | || pmap_height != new_pmap_height |
|
|
658 | || pmap_depth != target->depth) |
|
|
659 | { |
|
|
660 | XFreePixmap (target->dpy, pixmap); |
|
|
661 | pixmap = None; |
|
|
662 | } |
|
|
663 | } |
626 | |
664 | |
627 | /* create Pixmap */ |
665 | /* create Pixmap */ |
628 | if (pixmap == None) |
666 | if (pixmap == None) |
629 | { |
667 | { |
630 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
668 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
631 | pmap_width = new_pmap_width; |
669 | pmap_width = new_pmap_width; |
632 | pmap_height = new_pmap_height; |
670 | pmap_height = new_pmap_height; |
633 | pmap_depth = target->depth; |
671 | pmap_depth = target->depth; |
634 | } |
672 | } |
635 | /* fill with background color ( if result's not completely overlapping it)*/ |
673 | /* fill with background color (if result's not completely overlapping it) */ |
636 | gcv.foreground = target->pix_colors[Color_bg]; |
674 | gcv.foreground = target->pix_colors[Color_bg]; |
637 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
675 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
638 | |
676 | |
639 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
677 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
640 | int dst_width = result->width, dst_height = result->height; |
678 | int dst_width = result->width, dst_height = result->height; |
641 | if (background == NULL) |
679 | if (background == NULL) |
642 | { |
680 | { |
643 | if (h_scale > 0) |
|
|
644 | src_x = make_clip_rectangle (x, result->width, new_pmap_width, dst_x, dst_width); |
681 | if (h_scale > 0) src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); |
645 | if (v_scale > 0) |
|
|
646 | src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); |
682 | if (v_scale > 0) src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); |
647 | |
683 | |
648 | if (dst_x > 0 || dst_y > 0 |
684 | if (dst_x > 0 || dst_y > 0 |
649 | || dst_x + dst_width < new_pmap_width |
685 | || dst_x + dst_width < new_pmap_width |
650 | || dst_y + dst_height < new_pmap_height) |
686 | || dst_y + dst_height < new_pmap_height) |
651 | { |
|
|
652 | XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
687 | XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
653 | } |
|
|
654 | } |
688 | } |
655 | |
689 | |
656 | /* put result on pixmap */ |
690 | /* put result on pixmap */ |
657 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
691 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
658 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
692 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
… | |
… | |
660 | if (result != background && result != original_asim) |
694 | if (result != background && result != original_asim) |
661 | destroy_asimage (&result); |
695 | destroy_asimage (&result); |
662 | |
696 | |
663 | XFreeGC (target->dpy, gc); |
697 | XFreeGC (target->dpy, gc); |
664 | TIMING_TEST_PRINT_RESULT (asim); |
698 | TIMING_TEST_PRINT_RESULT (asim); |
665 | } |
|
|
666 | |
699 | |
|
|
700 | ret = true; |
|
|
701 | } |
|
|
702 | |
|
|
703 | if (background) |
|
|
704 | destroy_asimage (&background); |
|
|
705 | |
667 | return true; |
706 | return ret; |
668 | } |
707 | } |
669 | # endif /* HAVE_AFTERIMAGE */ |
708 | # endif /* HAVE_AFTERIMAGE */ |
670 | |
709 | |
671 | bool |
710 | bool |
672 | bgPixmap_t::set_file (const char *file) |
711 | bgPixmap_t::set_file (const char *file) |
673 | { |
712 | { |
674 | char *f; |
|
|
675 | |
|
|
676 | assert (file); |
713 | assert (file); |
677 | |
714 | |
678 | if (*file) |
715 | if (*file) |
679 | { |
716 | { |
680 | # ifdef HAVE_AFTERIMAGE |
717 | if (const char *p = strchr (file, ';')) |
681 | if (target->asimman == NULL) |
|
|
682 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
|
|
683 | |
|
|
684 | if ((f = strchr (file, ';')) == NULL) |
|
|
685 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
|
|
686 | else |
|
|
687 | { |
718 | { |
688 | size_t len = f - file; |
719 | size_t len = p - file; |
689 | f = (char *)malloc (len + 1); |
720 | char *f = rxvt_temp_buf<char> (len + 1); |
690 | memcpy (f, file, len); |
721 | memcpy (f, file, len); |
691 | f[len] = '\0'; |
722 | f[len] = '\0'; |
|
|
723 | file = f; |
|
|
724 | } |
|
|
725 | |
|
|
726 | # ifdef HAVE_AFTERIMAGE |
|
|
727 | if (!target->asimman) |
|
|
728 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
692 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
729 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
693 | free (f); |
730 | if (original_asim) |
694 | } |
731 | have_image = true; |
695 | |
732 | return have_image; |
696 | return original_asim; |
|
|
697 | # endif |
733 | # endif |
698 | } |
734 | } |
699 | |
735 | |
700 | return false; |
736 | return false; |
701 | } |
737 | } |
… | |
… | |
721 | int changed = 0; |
757 | int changed = 0; |
722 | unsigned int hr, vr; |
758 | unsigned int hr, vr; |
723 | int junk; |
759 | int junk; |
724 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
760 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
725 | |
761 | |
726 | if (!(geom_flags&WidthValue)) |
762 | if (!(geom_flags & WidthValue)) |
727 | hr = 1; |
763 | hr = 1; |
728 | if (!(geom_flags&HeightValue)) |
764 | if (!(geom_flags & HeightValue)) |
729 | vr = hr; |
765 | vr = hr; |
730 | |
766 | |
731 | if (h_blurRadius != hr) |
767 | if (h_blurRadius != hr) |
732 | { |
768 | { |
733 | ++changed; |
769 | ++changed; |
… | |
… | |
743 | if (v_blurRadius == 0 && h_blurRadius == 0) |
779 | if (v_blurRadius == 0 && h_blurRadius == 0) |
744 | flags &= ~blurNeeded; |
780 | flags &= ~blurNeeded; |
745 | else |
781 | else |
746 | flags |= blurNeeded; |
782 | flags |= blurNeeded; |
747 | |
783 | |
748 | return (changed>0); |
784 | return (changed > 0); |
749 | } |
785 | } |
750 | |
786 | |
751 | static inline unsigned long |
787 | static inline unsigned long |
752 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
788 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
753 | { |
789 | { |
… | |
… | |
770 | flags |= bgPixmap_t::tintNeeded; |
806 | flags |= bgPixmap_t::tintNeeded; |
771 | else if (tint) |
807 | else if (tint) |
772 | { |
808 | { |
773 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
809 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
774 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
810 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
775 | { |
811 | { |
776 | flags |= bgPixmap_t::tintNeeded; |
812 | flags |= bgPixmap_t::tintNeeded; |
777 | } |
813 | } |
778 | } |
814 | } |
779 | |
815 | |
780 | if (flags & bgPixmap_t::tintNeeded) |
816 | if (flags & bgPixmap_t::tintNeeded) |
781 | { |
817 | { |
782 | if (flags & bgPixmap_t::tintWholesome) |
818 | if (flags & bgPixmap_t::tintWholesome) |
… | |
… | |
811 | { |
847 | { |
812 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
848 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
813 | |
849 | |
814 | if (new_flags != (flags & tintFlags)) |
850 | if (new_flags != (flags & tintFlags)) |
815 | { |
851 | { |
816 | flags = (flags&~tintFlags)|new_flags; |
852 | flags = (flags & ~tintFlags) | new_flags; |
817 | return true; |
853 | return true; |
818 | } |
854 | } |
819 | |
855 | |
820 | return false; |
856 | return false; |
821 | } |
857 | } |
822 | |
858 | |
… | |
… | |
852 | unsigned long result = 0; |
888 | unsigned long result = 0; |
853 | |
889 | |
854 | if (target == NULL) |
890 | if (target == NULL) |
855 | return 0; |
891 | return 0; |
856 | |
892 | |
857 | /* root dimentions may change from call to call - but Display structure should |
893 | /* root dimensions may change from call to call - but Display structure should |
858 | * be always up-to-date, so let's use it : |
894 | * be always up-to-date, so let's use it : |
859 | */ |
895 | */ |
860 | Window root = target->display->root; |
896 | Window root = target->display->root; |
861 | int screen = target->display->screen; |
897 | int screen = target->display->screen; |
862 | Display *dpy = target->dpy; |
898 | Display *dpy = target->dpy; |
… | |
… | |
907 | |
943 | |
908 | attr.background_pixmap = ParentRelative; |
944 | attr.background_pixmap = ParentRelative; |
909 | attr.backing_store = Always; |
945 | attr.backing_store = Always; |
910 | attr.event_mask = ExposureMask; |
946 | attr.event_mask = ExposureMask; |
911 | attr.override_redirect = True; |
947 | attr.override_redirect = True; |
912 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
948 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
913 | CopyFromParent, CopyFromParent, CopyFromParent, |
949 | CopyFromParent, CopyFromParent, CopyFromParent, |
914 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
950 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
915 | &attr); |
951 | &attr); |
916 | |
952 | |
917 | if (src != None) |
953 | if (src != None) |
… | |
… | |
941 | XDestroyWindow (dpy, src); |
977 | XDestroyWindow (dpy, src); |
942 | XUngrabServer (dpy); |
978 | XUngrabServer (dpy); |
943 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
979 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
944 | } |
980 | } |
945 | |
981 | |
946 | if (!success) |
982 | if (!success) |
947 | { |
983 | { |
948 | XFreePixmap (dpy, tiled_root_pmap); |
984 | XFreePixmap (dpy, tiled_root_pmap); |
949 | tiled_root_pmap = None; |
985 | tiled_root_pmap = None; |
950 | } |
986 | } |
951 | else |
987 | else |
952 | result |= transpPmapTiled; |
988 | result |= transpPmapTiled; |
953 | } |
989 | } |
954 | else |
990 | else |
955 | { |
991 | { |
956 | /* strightforward pixmap copy */ |
992 | /* straightforward pixmap copy */ |
957 | gcv.tile = root_pixmap; |
993 | gcv.tile = root_pixmap; |
958 | gcv.fill_style = FillTiled; |
994 | gcv.fill_style = FillTiled; |
959 | |
995 | |
960 | while (sx < 0) sx += (int)root_width; |
996 | while (sx < 0) sx += (int)root_width; |
961 | while (sy < 0) sy += (int)root_height; |
997 | while (sy < 0) sy += (int)root_height; |
… | |
… | |
1074 | # if DO_TIMING_TEST |
1110 | # if DO_TIMING_TEST |
1075 | XSync (dpy, False); |
1111 | XSync (dpy, False); |
1076 | # endif |
1112 | # endif |
1077 | # endif |
1113 | # endif |
1078 | } |
1114 | } |
1079 | } |
1115 | } |
1080 | } /* server side rendering completed */ |
1116 | } /* server side rendering completed */ |
1081 | |
1117 | |
1082 | if (pixmap) |
1118 | if (pixmap) |
1083 | XFreePixmap (dpy, pixmap); |
1119 | XFreePixmap (dpy, pixmap); |
1084 | |
1120 | |
… | |
… | |
1112 | return false; |
1148 | return false; |
1113 | } |
1149 | } |
1114 | # endif /* ENABLE_TRANSPARENCY */ |
1150 | # endif /* ENABLE_TRANSPARENCY */ |
1115 | |
1151 | |
1116 | # ifndef HAVE_AFTERIMAGE |
1152 | # ifndef HAVE_AFTERIMAGE |
1117 | static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); |
1153 | static void ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm); |
1118 | # endif |
1154 | # endif |
1119 | |
1155 | |
1120 | bool |
1156 | bool |
1121 | bgPixmap_t::render () |
1157 | bgPixmap_t::render () |
1122 | { |
1158 | { |
… | |
… | |
1125 | if (target == NULL) |
1161 | if (target == NULL) |
1126 | return false; |
1162 | return false; |
1127 | |
1163 | |
1128 | TIMING_TEST_START (tp); |
1164 | TIMING_TEST_START (tp); |
1129 | |
1165 | |
1130 | invalidate(); |
1166 | invalidate (); |
1131 | # ifdef ENABLE_TRANSPARENCY |
1167 | # ifdef ENABLE_TRANSPARENCY |
1132 | if (flags & isTransparent) |
1168 | if (flags & isTransparent) |
1133 | { |
1169 | { |
1134 | /* we need to re-generate transparency pixmap in that case ! */ |
1170 | /* we need to re-generate transparency pixmap in that case ! */ |
1135 | background_flags = make_transparency_pixmap (); |
1171 | background_flags = make_transparency_pixmap (); |
1136 | if (background_flags == 0) |
1172 | if (background_flags == 0) |
1137 | return false; |
1173 | return false; |
1138 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1174 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1139 | && pmap_depth == target->depth) |
1175 | && pmap_depth == target->depth) |
1140 | flags = flags & ~isInvalid; |
1176 | flags = flags & ~isInvalid; |
1141 | } |
1177 | } |
1142 | # endif |
1178 | # endif |
1143 | |
1179 | |
|
|
1180 | # ifdef BG_IMAGE_FROM_FILE |
|
|
1181 | if (have_image |
|
|
1182 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
|
|
1183 | { |
|
|
1184 | if (render_image (background_flags)) |
|
|
1185 | flags = flags & ~isInvalid; |
|
|
1186 | } |
|
|
1187 | # endif |
|
|
1188 | |
1144 | XImage *result = NULL; |
1189 | XImage *result = NULL; |
1145 | # ifdef HAVE_AFTERIMAGE |
1190 | |
1146 | if (original_asim |
1191 | if (background_flags && (flags & isInvalid)) |
1147 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1192 | { |
|
|
1193 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1148 | { |
1194 | } |
1149 | ASImage *background = NULL; |
|
|
1150 | ARGB32 as_tint = TINT_LEAVE_SAME; |
|
|
1151 | if (background_flags) |
|
|
1152 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
|
|
1153 | |
1195 | |
1154 | # ifdef ENABLE_TRANSPARENCY |
1196 | if (result) |
|
|
1197 | { |
|
|
1198 | # if !defined(HAVE_AFTERIMAGE) && !XFT |
|
|
1199 | /* our own client-side tinting */ |
|
|
1200 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. |
|
|
1201 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
1155 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1202 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1156 | { |
|
|
1157 | ShadingInfo as_shade; |
|
|
1158 | as_shade.shading = (shade == 0) ? 100 : shade; |
|
|
1159 | |
|
|
1160 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1161 | if (flags & tintSet) |
|
|
1162 | tint.get (c); |
|
|
1163 | as_shade.tintColor.red = c.r; |
|
|
1164 | as_shade.tintColor.green = c.g; |
|
|
1165 | as_shade.tintColor.blue = c.b; |
|
|
1166 | |
|
|
1167 | as_tint = shading2tint32 (&as_shade); |
|
|
1168 | } |
|
|
1169 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
1170 | { |
|
|
1171 | ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
1172 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
|
|
1173 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1174 | if (tmp) |
|
|
1175 | { |
|
|
1176 | destroy_asimage (&background); |
|
|
1177 | background = tmp; |
|
|
1178 | } |
|
|
1179 | } |
|
|
1180 | # endif |
|
|
1181 | |
|
|
1182 | if (render_asim (background, as_tint)) |
|
|
1183 | flags = flags & ~isInvalid; |
|
|
1184 | if (background) |
|
|
1185 | destroy_asimage (&background); |
|
|
1186 | } |
|
|
1187 | else if (background_flags && pmap_depth != target->depth) |
|
|
1188 | { |
|
|
1189 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
|
|
1190 | } |
|
|
1191 | |
|
|
1192 | # elif !XFT /* our own client-side tinting */ |
|
|
1193 | |
|
|
1194 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. |
|
|
1195 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
|
|
1196 | |
|
|
1197 | if (background_flags && (flags & isInvalid)) |
|
|
1198 | { |
|
|
1199 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
|
|
1200 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
|
|
1201 | { |
1203 | { |
1202 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1204 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1203 | if (flags & tintSet) |
1205 | if (flags & tintSet) |
1204 | tint.get (c); |
1206 | tint.get (c); |
1205 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1207 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1206 | } |
1208 | } |
1207 | } |
1209 | # endif |
1208 | # endif /* HAVE_AFTERIMAGE */ |
|
|
1209 | |
1210 | |
1210 | if (result) |
|
|
1211 | { |
|
|
1212 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1211 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1213 | |
1212 | |
1214 | if (gc) |
1213 | if (gc) |
1215 | { |
1214 | { |
1216 | if (/*pmap_depth != target->depth &&*/ pixmap != None) |
1215 | if (/*pmap_depth != target->depth &&*/ pixmap != None) |
… | |
… | |
1245 | |
1244 | |
1246 | XFreeGC (target->dpy, gc); |
1245 | XFreeGC (target->dpy, gc); |
1247 | flags = flags & ~isInvalid; |
1246 | flags = flags & ~isInvalid; |
1248 | } |
1247 | } |
1249 | |
1248 | |
1250 | XDestroyImage (result); |
1249 | XDestroyImage (result); |
1251 | } |
1250 | } |
1252 | |
1251 | |
1253 | if (flags & isInvalid) |
1252 | if (flags & isInvalid) |
1254 | { |
1253 | { |
1255 | if (pixmap != None) |
1254 | if (pixmap != None) |
… | |
… | |
1279 | # ifdef ENABLE_TRANSPARENCY |
1278 | # ifdef ENABLE_TRANSPARENCY |
1280 | root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); |
1279 | root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); |
1281 | # endif |
1280 | # endif |
1282 | return true; |
1281 | return true; |
1283 | } |
1282 | } |
|
|
1283 | |
1284 | return false; |
1284 | return false; |
1285 | } |
1285 | } |
1286 | |
1286 | |
1287 | void |
1287 | void |
1288 | bgPixmap_t::apply () |
1288 | bgPixmap_t::apply () |
1289 | { |
1289 | { |
1290 | if (target) |
1290 | if (target) |
1291 | { |
1291 | { |
1292 | flags &= ~isVtOrigin; |
1292 | flags &= ~isVtOrigin; |
|
|
1293 | |
1293 | if (pixmap != None) |
1294 | if (pixmap != None) |
1294 | { |
1295 | { |
1295 | /* set target's background to pixmap */ |
1296 | /* set target's background to pixmap */ |
1296 | # ifdef ENABLE_TRANSPARENCY |
1297 | # ifdef ENABLE_TRANSPARENCY |
1297 | if (flags & isTransparent) |
1298 | if (flags & isTransparent) |
1298 | { |
1299 | { |
1299 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
1300 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
1300 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
1301 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
1301 | # if HAVE_SCROLLBARS |
1302 | |
1302 | if (target->scrollBar.win) |
1303 | if (target->scrollBar.win) |
1303 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
1304 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
1304 | # endif |
|
|
1305 | } |
1305 | } |
1306 | else |
1306 | else |
1307 | # endif |
1307 | # endif |
1308 | { |
1308 | { |
1309 | flags |= isVtOrigin; |
1309 | flags |= isVtOrigin; |
1310 | /* force old pixmap dereference in case it was transparent before :*/ |
1310 | /* force old pixmap dereference in case it was transparent before :*/ |
1311 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1311 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1312 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
1312 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
1313 | /* do we also need to set scrollbar's background here ? */ |
1313 | /* do we also need to set scrollbar's background here ? */ |
1314 | # if HAVE_SCROLLBARS |
1314 | |
1315 | if (target->scrollBar.win) |
1315 | if (target->scrollBar.win) |
1316 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1316 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1317 | # endif |
|
|
1318 | } |
1317 | } |
1319 | } |
1318 | } |
1320 | else |
1319 | else |
1321 | { |
1320 | { |
1322 | /* set target background to a pixel */ |
1321 | /* set target background to a pixel */ |
1323 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1322 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1324 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
1323 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
1325 | /* do we also need to set scrollbar's background here ? */ |
1324 | /* do we also need to set scrollbar's background here ? */ |
1326 | # if HAVE_SCROLLBARS |
|
|
1327 | if (target->scrollBar.win) |
1325 | if (target->scrollBar.win) |
1328 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1326 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1329 | # endif |
|
|
1330 | } |
1327 | } |
|
|
1328 | |
1331 | /* don't want Expose on the parent or vt. It is better to use |
1329 | /* don't want Expose on the parent or vt. It is better to use |
1332 | scr_touch or we get a great deal of flicker otherwise: */ |
1330 | scr_touch or we get a great deal of flicker otherwise: */ |
1333 | XClearWindow (target->dpy, target->parent[0]); |
1331 | XClearWindow (target->dpy, target->parent[0]); |
1334 | |
1332 | |
1335 | # if HAVE_SCROLLBARS |
1333 | if (target->scrollBar.state && target->scrollBar.win) |
1336 | if (target->scrollBar.win) |
|
|
1337 | { |
1334 | { |
1338 | target->scrollBar.setIdle (); |
1335 | target->scrollBar.state = STATE_IDLE; |
1339 | target->scrollbar_show (0); |
1336 | target->scrollBar.show (0); |
1340 | } |
1337 | } |
1341 | # endif |
|
|
1342 | |
1338 | |
1343 | target->want_refresh = 1; |
1339 | target->want_refresh = 1; |
1344 | flags |= hasChanged; |
1340 | flags |= hasChanged; |
1345 | } |
1341 | } |
1346 | } |
1342 | } |
… | |
… | |
1351 | /* taken from aterm-0.4.2 */ |
1347 | /* taken from aterm-0.4.2 */ |
1352 | |
1348 | |
1353 | typedef uint32_t RUINT32T; |
1349 | typedef uint32_t RUINT32T; |
1354 | |
1350 | |
1355 | static void |
1351 | static void |
1356 | ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
1352 | ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm) |
1357 | { |
1353 | { |
1358 | int sh_r, sh_g, sh_b; |
1354 | int sh_r, sh_g, sh_b; |
1359 | RUINT32T mask_r, mask_g, mask_b; |
1355 | RUINT32T mask_r, mask_g, mask_b; |
1360 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
1356 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
1361 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
1357 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |