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) 1997 Carsten Haitzler <raster@zip.com.au> |
|
|
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
|
|
8 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
|
|
9 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
10 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
7 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
11 | * |
8 | * |
12 | * This program is free software; you can redistribute it and/or modify |
9 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by |
10 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
28 | #include "rxvt.h" /* NECESSARY */ |
25 | #include "rxvt.h" /* NECESSARY */ |
29 | |
26 | |
30 | #define DO_TIMING_TEST 0 |
27 | #define DO_TIMING_TEST 0 |
31 | |
28 | |
32 | #if DO_TIMING_TEST |
29 | #if DO_TIMING_TEST |
|
|
30 | # include <sys/time.h> |
33 | #define TIMING_TEST_START(id) \ |
31 | #define TIMING_TEST_START(id) \ |
34 | struct timeval timing_test_##id##_stv;\ |
32 | struct timeval timing_test_##id##_stv;\ |
35 | gettimeofday (&timing_test_##id##_stv, NULL); |
33 | gettimeofday (&timing_test_##id##_stv, NULL); |
36 | |
34 | |
37 | #define TIMING_TEST_PRINT_RESULT(id) \ |
35 | #define TIMING_TEST_PRINT_RESULT(id) \ |
… | |
… | |
87 | * scale Scale both up and down |
85 | * scale Scale both up and down |
88 | * auto Same as 100x100+50+50 |
86 | * auto Same as 100x100+50+50 |
89 | */ |
87 | */ |
90 | |
88 | |
91 | #ifdef HAVE_BG_PIXMAP |
89 | #ifdef HAVE_BG_PIXMAP |
92 | bgPixmap_t::bgPixmap_t() |
90 | bgPixmap_t::bgPixmap_t () |
93 | { |
91 | { |
94 | #ifdef HAVE_AFTERIMAGE |
92 | #ifdef HAVE_AFTERIMAGE |
95 | original_asim = NULL; |
93 | original_asim = NULL; |
96 | #endif |
94 | #endif |
97 | #ifdef BG_IMAGE_FROM_FILE |
95 | #ifdef BG_IMAGE_FROM_FILE |
… | |
… | |
100 | #endif |
98 | #endif |
101 | flags = 0; |
99 | flags = 0; |
102 | pixmap = None; |
100 | pixmap = None; |
103 | } |
101 | } |
104 | |
102 | |
105 | bgPixmap_t::~bgPixmap_t() |
103 | void |
|
|
104 | bgPixmap_t::destroy () |
106 | { |
105 | { |
107 | #ifdef HAVE_AFTERIMAGE |
106 | #ifdef HAVE_AFTERIMAGE |
108 | if (original_asim) |
107 | if (original_asim) |
109 | safe_asimage_destroy (original_asim); |
108 | safe_asimage_destroy (original_asim); |
110 | #endif |
109 | #endif |
|
|
110 | |
111 | if (pixmap && target) |
111 | if (pixmap && target) |
112 | XFreePixmap (target->dpy, pixmap); |
112 | XFreePixmap (target->dpy, pixmap); |
113 | } |
113 | } |
114 | |
114 | |
115 | bool |
115 | bool |
116 | bgPixmap_t::window_size_sensitive () |
116 | bgPixmap_t::window_size_sensitive () |
117 | { |
117 | { |
|
|
118 | # ifdef ENABLE_TRANSPARENCY |
|
|
119 | if (flags & isTransparent) |
|
|
120 | return true; |
|
|
121 | # endif |
|
|
122 | |
118 | # ifdef BG_IMAGE_FROM_FILE |
123 | # ifdef BG_IMAGE_FROM_FILE |
119 | # ifdef HAVE_AFTERIMAGE |
124 | # ifdef HAVE_AFTERIMAGE |
120 | if (original_asim != NULL) |
125 | if (original_asim != NULL) |
121 | # endif |
126 | # endif |
122 | { |
127 | { |
123 | if (h_scale != 0 || v_scale != 0 |
128 | if (h_scale != 0 || v_scale != 0 |
124 | || h_align != 0 || v_align != 0) |
129 | || h_align != 0 || v_align != 0) |
125 | return true; |
130 | return true; |
126 | } |
131 | } |
127 | # endif |
132 | # endif |
|
|
133 | |
|
|
134 | return false; |
|
|
135 | } |
|
|
136 | |
|
|
137 | bool |
|
|
138 | bgPixmap_t::window_position_sensitive () |
|
|
139 | { |
128 | # ifdef ENABLE_TRANSPARENCY |
140 | # ifdef ENABLE_TRANSPARENCY |
129 | if (flags & isTransparent) |
141 | if (flags & isTransparent) |
130 | return true; |
142 | return true; |
131 | # endif |
143 | # endif |
|
|
144 | |
|
|
145 | # ifdef BG_IMAGE_FROM_FILE |
|
|
146 | # ifdef HAVE_AFTERIMAGE |
|
|
147 | if (original_asim != NULL) |
|
|
148 | # endif |
|
|
149 | { |
|
|
150 | if (h_align == rootAlign || v_align == rootAlign) |
|
|
151 | return true; |
|
|
152 | } |
|
|
153 | # endif |
|
|
154 | |
132 | return false; |
155 | return false; |
133 | } |
156 | }; |
134 | |
157 | |
135 | bool bgPixmap_t::need_client_side_rendering () |
158 | bool bgPixmap_t::need_client_side_rendering () |
136 | { |
159 | { |
137 | # ifdef HAVE_AFTERIMAGE |
160 | # ifdef HAVE_AFTERIMAGE |
138 | if (original_asim != NULL) |
161 | if (original_asim != NULL) |
… | |
… | |
172 | static inline bool |
195 | static inline bool |
173 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
196 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
174 | { |
197 | { |
175 | if (geom_flags & flag) |
198 | if (geom_flags & flag) |
176 | { |
199 | { |
|
|
200 | if (new_value != bgPixmap_t::rootAlign) |
|
|
201 | { |
177 | if (new_value < -100) |
202 | if (new_value < -100) |
178 | new_value = -100; |
203 | new_value = -100; |
179 | else if (new_value > 200) |
204 | else if (new_value > 200) |
180 | new_value = 200; |
205 | new_value = 200; |
|
|
206 | } |
181 | if (new_value != align) |
207 | if (new_value != align) |
182 | { |
208 | { |
183 | align = new_value; |
209 | align = new_value; |
184 | return true; |
210 | return true; |
185 | } |
211 | } |
… | |
… | |
277 | y = x; |
303 | y = x; |
278 | geom_flags |= YValue; |
304 | geom_flags |= YValue; |
279 | } |
305 | } |
280 | |
306 | |
281 | if (flags & geometrySet) |
307 | if (flags & geometrySet) |
|
|
308 | { |
282 | {/* new geometry is an adjustment to the old one ! */ |
309 | /* new geometry is an adjustment to the old one ! */ |
283 | if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) |
310 | if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) |
284 | { |
311 | { |
285 | if (w == 0 && h != 0) |
312 | if (w == 0 && h != 0) |
286 | { |
313 | { |
287 | w = h_scale; |
314 | w = h_scale; |
… | |
… | |
303 | } |
330 | } |
304 | } |
331 | } |
305 | else /* setting up geometry from scratch */ |
332 | else /* setting up geometry from scratch */ |
306 | { |
333 | { |
307 | if (!(geom_flags & XValue)) |
334 | if (!(geom_flags & XValue)) |
|
|
335 | { |
308 | {/* use default geometry - centered */ |
336 | /* use default geometry - centered */ |
309 | x = y = defaultAlign; |
337 | x = y = defaultAlign; |
310 | } |
338 | } |
311 | else if (!(geom_flags & YValue)) |
339 | else if (!(geom_flags & YValue)) |
312 | y = x; |
340 | y = x; |
313 | |
341 | |
314 | if ((geom_flags & (WidthValue|HeightValue)) == 0) |
342 | if ((geom_flags & (WidthValue|HeightValue)) == 0) |
|
|
343 | { |
315 | {/* use default geometry - scaled */ |
344 | /* use default geometry - scaled */ |
316 | w = h = defaultScale; |
345 | w = h = defaultScale; |
317 | } |
346 | } |
318 | else if (geom_flags & WidthValue) |
347 | else if (geom_flags & WidthValue) |
319 | { |
348 | { |
320 | if (!(geom_flags & HeightValue)) |
349 | if (!(geom_flags & HeightValue)) |
… | |
… | |
323 | else |
352 | else |
324 | w = h; |
353 | w = h; |
325 | } |
354 | } |
326 | } /* done parsing geometry string */ |
355 | } /* done parsing geometry string */ |
327 | else if (!(flags & geometrySet)) |
356 | else if (!(flags & geometrySet)) |
|
|
357 | { |
328 | { /* default geometry - scaled and centered */ |
358 | /* default geometry - scaled and centered */ |
329 | x = y = defaultAlign; |
359 | x = y = defaultAlign; |
330 | w = h = defaultScale; |
360 | w = h = defaultScale; |
331 | } |
361 | } |
332 | |
362 | |
333 | if (!(flags & geometrySet)) |
363 | if (!(flags & geometrySet)) |
… | |
… | |
339 | { |
369 | { |
340 | while (*ops == ':' || isspace(*ops)) ++ops; |
370 | while (*ops == ':' || isspace(*ops)) ++ops; |
341 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) |
371 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) |
342 | if (CHECK_GEOM_OPS("tile")) |
372 | if (CHECK_GEOM_OPS("tile")) |
343 | { |
373 | { |
344 | w = h = 0; |
374 | w = h = noScale; |
345 | geom_flags |= WidthValue|HeightValue; |
375 | geom_flags |= WidthValue|HeightValue; |
346 | } |
376 | } |
347 | else if (CHECK_GEOM_OPS("propscale")) |
377 | else if (CHECK_GEOM_OPS("propscale")) |
348 | { |
378 | { |
349 | if (w == 0 && h == 0) |
379 | if (w == 0 && h == 0) |
350 | { |
380 | { |
351 | w = 100; |
381 | w = windowScale; |
352 | geom_flags |= WidthValue; |
382 | geom_flags |= WidthValue; |
353 | } |
383 | } |
354 | new_flags |= propScale; |
384 | new_flags |= propScale; |
355 | } |
385 | } |
356 | else if (CHECK_GEOM_OPS("hscale")) |
386 | else if (CHECK_GEOM_OPS("hscale")) |
357 | { |
387 | { |
358 | if (w == 0) |
388 | if (w == 0) |
359 | w = 100; |
389 | w = windowScale; |
360 | h = 0; |
390 | h = noScale; |
361 | geom_flags |= WidthValue|HeightValue; |
391 | geom_flags |= WidthValue|HeightValue; |
362 | } |
392 | } |
363 | else if (CHECK_GEOM_OPS("vscale")) |
393 | else if (CHECK_GEOM_OPS("vscale")) |
364 | { |
394 | { |
365 | if (h == 0) |
395 | if (h == 0) |
366 | h = 100; |
396 | h = windowScale; |
367 | w = 0; |
397 | w = noScale; |
368 | geom_flags |= WidthValue|HeightValue; |
398 | geom_flags |= WidthValue|HeightValue; |
369 | } |
399 | } |
370 | else if (CHECK_GEOM_OPS("scale")) |
400 | else if (CHECK_GEOM_OPS("scale")) |
371 | { |
401 | { |
372 | if (h == 0) |
402 | if (h == 0) |
373 | h = 100; |
403 | h = windowScale; |
374 | if (w == 0) |
404 | if (w == 0) |
375 | w = 100; |
405 | w = windowScale; |
376 | geom_flags |= WidthValue|HeightValue; |
406 | geom_flags |= WidthValue|HeightValue; |
377 | } |
407 | } |
378 | else if (CHECK_GEOM_OPS("auto")) |
408 | else if (CHECK_GEOM_OPS("auto")) |
379 | { |
409 | { |
|
|
410 | w = h = windowScale; |
|
|
411 | x = y = centerAlign; |
|
|
412 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
|
|
413 | } |
|
|
414 | else if (CHECK_GEOM_OPS("root")) |
|
|
415 | { |
380 | w = h = 100; |
416 | w = h = noScale; |
381 | x = y = 50; |
417 | x = y = rootAlign; |
382 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
418 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
383 | } |
419 | } |
384 | # undef CHECK_GEOM_OPS |
420 | # undef CHECK_GEOM_OPS |
385 | while (*ops != ':' && *ops != '\0') ++ops; |
421 | while (*ops != ':' && *ops != '\0') ++ops; |
386 | } /* done parsing ops */ |
422 | } /* done parsing ops */ |
… | |
… | |
399 | if (new_flags != flags) |
435 | if (new_flags != flags) |
400 | { |
436 | { |
401 | flags = new_flags; |
437 | flags = new_flags; |
402 | changed++; |
438 | changed++; |
403 | } |
439 | } |
404 | //fprintf( stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
440 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
405 | // flags, h_scale, v_scale, h_align, v_align); |
441 | // flags, h_scale, v_scale, h_align, v_align); |
406 | return (changed > 0); |
442 | return (changed > 0); |
407 | } |
443 | } |
408 | |
444 | |
409 | # ifdef HAVE_AFTERIMAGE |
445 | # ifdef HAVE_AFTERIMAGE |
… | |
… | |
425 | |
461 | |
426 | TIMING_TEST_START (asim); |
462 | TIMING_TEST_START (asim); |
427 | |
463 | |
428 | if (original_asim) |
464 | if (original_asim) |
429 | { |
465 | { |
|
|
466 | if (h_align == rootAlign || v_align == rootAlign) |
|
|
467 | { |
|
|
468 | target->get_window_origin(x, y); |
|
|
469 | x = -x; |
|
|
470 | y = -y; |
|
|
471 | } |
|
|
472 | if (h_align != rootAlign) |
430 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
473 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
|
|
474 | if (v_align != rootAlign) |
431 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
475 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
432 | } |
476 | } |
433 | |
477 | |
434 | if (original_asim == NULL |
478 | if (original_asim == NULL |
435 | || x >= target_width |
479 | || x >= target_width |
436 | || y >= target_height |
480 | || y >= target_height |
… | |
… | |
465 | h > 0 ? h : original_asim->height, |
509 | h > 0 ? h : original_asim->height, |
466 | background ? ASA_ASImage : ASA_XImage, |
510 | background ? ASA_ASImage : ASA_XImage, |
467 | 100, ASIMAGE_QUALITY_DEFAULT); |
511 | 100, ASIMAGE_QUALITY_DEFAULT); |
468 | } |
512 | } |
469 | if (background == NULL) |
513 | if (background == NULL) |
|
|
514 | { |
470 | {/* if tiling - pixmap has to be sized exactly as the image */ |
515 | /* if tiling - pixmap has to be sized exactly as the image, |
|
|
516 | but there is no need to make it bigger then the window! */ |
471 | if (h_scale == 0) |
517 | if (h_scale == 0) |
472 | new_pmap_width = result->width; |
518 | new_pmap_width = min (result->width, target_width); |
473 | if (v_scale == 0) |
519 | if (v_scale == 0) |
474 | new_pmap_height = result->height; |
520 | new_pmap_height = min (result->height, target_height); |
475 | /* we also need to tile our image in one or both directions */ |
521 | /* we also need to tile our image in one or both directions */ |
476 | if (h_scale == 0 || v_scale == 0) |
522 | if (h_scale == 0 || v_scale == 0) |
477 | { |
523 | { |
478 | ASImage *tmp = tile_asimage (target->asv, result, |
524 | ASImage *tmp = tile_asimage (target->asv, result, |
479 | (h_scale > 0) ? 0 : (int)result->width - x, |
525 | (h_scale > 0) ? 0 : (int)result->width - x, |
480 | (v_scale > 0) ? 0 : (int)result->height - y, |
526 | (v_scale > 0) ? 0 : (int)result->height - y, |
|
|
527 | new_pmap_width, |
481 | result->width, result->height, |
528 | new_pmap_height, |
482 | TINT_LEAVE_SAME, ASA_XImage, |
529 | TINT_LEAVE_SAME, ASA_XImage, |
483 | 100, ASIMAGE_QUALITY_DEFAULT); |
530 | 100, ASIMAGE_QUALITY_DEFAULT); |
484 | if (tmp) |
531 | if (tmp) |
485 | { |
532 | { |
486 | if (result != original_asim) |
533 | if (result != original_asim) |
… | |
… | |
488 | result = tmp; |
535 | result = tmp; |
489 | } |
536 | } |
490 | } |
537 | } |
491 | } |
538 | } |
492 | else |
539 | else |
|
|
540 | { |
493 | {/* if blending background and image - pixmap has to be sized same as target window */ |
541 | /* if blending background and image - pixmap has to be sized same as target window */ |
494 | ASImageLayer *layers = create_image_layers (2); |
542 | ASImageLayer *layers = create_image_layers (2); |
495 | ASImage *merged_im = NULL; |
543 | ASImage *merged_im = NULL; |
496 | |
544 | |
497 | layers[0].im = background; |
545 | layers[0].im = background; |
498 | layers[0].clip_width = target_width; |
546 | layers[0].clip_width = target_width; |
499 | layers[0].clip_height = target_height; |
547 | layers[0].clip_height = target_height; |
500 | layers[0].tint = background_tint; |
548 | layers[0].tint = background_tint; |
501 | layers[1].im = result; |
549 | layers[1].im = result; |
502 | if (w <= 0) |
550 | if (w <= 0) |
|
|
551 | { |
503 | {/* tile horizontally */ |
552 | /* tile horizontally */ |
504 | while (x > 0) x -= (int)result->width; |
553 | while (x > 0) x -= (int)result->width; |
505 | layers[1].dst_x = x; |
554 | layers[1].dst_x = x; |
506 | layers[1].clip_width = result->width+target_width; |
555 | layers[1].clip_width = result->width+target_width; |
507 | } |
556 | } |
508 | else |
557 | else |
|
|
558 | { |
509 | {/* clip horizontally */ |
559 | /* clip horizontally */ |
510 | layers[1].dst_x = x; |
560 | layers[1].dst_x = x; |
511 | layers[1].clip_width = result->width; |
561 | layers[1].clip_width = result->width; |
512 | } |
562 | } |
513 | if (h <= 0) |
563 | if (h <= 0) |
514 | { |
564 | { |
… | |
… | |
628 | # endif |
678 | # endif |
629 | } |
679 | } |
630 | return false; |
680 | return false; |
631 | } |
681 | } |
632 | |
682 | |
633 | # endif /* BG_IMAGE_FROM_FILE */ |
683 | # endif /* BG_IMAGE_FROM_FILE */ |
634 | |
684 | |
635 | # ifdef ENABLE_TRANSPARENCY |
685 | # ifdef ENABLE_TRANSPARENCY |
636 | bool |
686 | bool |
637 | bgPixmap_t::set_transparent () |
687 | bgPixmap_t::set_transparent () |
638 | { |
688 | { |
… | |
… | |
801 | if (sx + window_width <= 0 || sy + window_height <= 0 |
851 | if (sx + window_width <= 0 || sy + window_height <= 0 |
802 | || sx >= root_width || sy >= root_height) |
852 | || sx >= root_width || sy >= root_height) |
803 | return 0; |
853 | return 0; |
804 | |
854 | |
805 | if (root_pixmap != None) |
855 | if (root_pixmap != None) |
|
|
856 | { |
806 | {/* we want to validate the pixmap and get it's size at the same time : */ |
857 | /* we want to validate the pixmap and get it's size at the same time : */ |
807 | int junk; |
858 | int junk; |
808 | unsigned int ujunk; |
859 | unsigned int ujunk; |
809 | /* root pixmap may be bad - allow a error */ |
860 | /* root pixmap may be bad - allow a error */ |
810 | target->allowedxerror = -1; |
861 | target->allowedxerror = -1; |
811 | |
862 | |
… | |
… | |
820 | |
871 | |
821 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
872 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
822 | return 0; |
873 | return 0; |
823 | |
874 | |
824 | if (root_pixmap == None) |
875 | if (root_pixmap == None) |
|
|
876 | { |
825 | { /* use tricks to obtain the root background image :*/ |
877 | /* use tricks to obtain the root background image :*/ |
826 | /* we want to create Overrideredirect window overlapping out window |
878 | /* we want to create Overrideredirect window overlapping out window |
827 | with background type of Parent Relative and then grab it */ |
879 | with background type of Parent Relative and then grab it */ |
828 | XSetWindowAttributes attr; |
880 | XSetWindowAttributes attr; |
829 | Window src; |
881 | Window src; |
830 | bool success = false; |
882 | bool success = false; |
… | |
… | |
850 | * but to be on the safe side - let's check for the actuall event to arrive : */ |
902 | * but to be on the safe side - let's check for the actuall event to arrive : */ |
851 | while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) |
903 | while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) |
852 | ++ev_count; |
904 | ++ev_count; |
853 | |
905 | |
854 | if (ev_count > 0); |
906 | if (ev_count > 0); |
|
|
907 | { |
855 | { /* hooray! - we can grab the image! */ |
908 | /* hooray! - we can grab the image! */ |
856 | gc = XCreateGC (dpy, root, 0, NULL); |
909 | gc = XCreateGC (dpy, root, 0, NULL); |
857 | if (gc) |
910 | if (gc) |
858 | { |
911 | { |
859 | XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0); |
912 | XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0); |
860 | success = true; |
913 | success = true; |
… | |
… | |
872 | } |
925 | } |
873 | else |
926 | else |
874 | result |= transpPmapTiled; |
927 | result |= transpPmapTiled; |
875 | } |
928 | } |
876 | else |
929 | else |
|
|
930 | { |
877 | {/* strightforward pixmap copy */ |
931 | /* strightforward pixmap copy */ |
878 | gcv.tile = root_pixmap; |
932 | gcv.tile = root_pixmap; |
879 | gcv.fill_style = FillTiled; |
933 | gcv.fill_style = FillTiled; |
880 | |
934 | |
881 | while (sx < 0) sx += (int)root_width; |
935 | while (sx < 0) sx += (int)root_width; |
882 | while (sy < 0) sy += (int)root_height; |
936 | while (sy < 0) sy += (int)root_height; |
… | |
… | |
930 | { |
984 | { |
931 | c.r = (c.r * shade) / 100; |
985 | c.r = (c.r * shade) / 100; |
932 | c.g = (c.g * shade) / 100; |
986 | c.g = (c.g * shade) / 100; |
933 | c.b = (c.b * shade) / 100; |
987 | c.b = (c.b * shade) / 100; |
934 | } |
988 | } |
935 | else if( shade > 100 && shade < 200) |
989 | else if (shade > 100 && shade < 200) |
936 | { |
990 | { |
937 | c.r = (c.r * (200 - shade)) / 100; |
991 | c.r = (c.r * (200 - shade)) / 100; |
938 | c.g = (c.g * (200 - shade)) / 100; |
992 | c.g = (c.g * (200 - shade)) / 100; |
939 | c.b = (c.b * (200 - shade)) / 100; |
993 | c.b = (c.b * (200 - shade)) / 100; |
940 | } |
994 | } |
… | |
… | |
1145 | pmap_width = result->width; |
1199 | pmap_width = result->width; |
1146 | pmap_height = result->height; |
1200 | pmap_height = result->height; |
1147 | pmap_depth = target->depth; |
1201 | pmap_depth = target->depth; |
1148 | } |
1202 | } |
1149 | if (pmap_depth != result->depth) |
1203 | if (pmap_depth != result->depth) |
|
|
1204 | { |
1150 | { /* Bad Match error will ensue ! stupid X !!!! */ |
1205 | /* Bad Match error will ensue ! stupid X !!!! */ |
1151 | if( result->depth == 24 && pmap_depth == 32) |
1206 | if (result->depth == 24 && pmap_depth == 32) |
1152 | result->depth = 32; |
1207 | result->depth = 32; |
1153 | else if( result->depth == 32 && pmap_depth == 24) |
1208 | else if (result->depth == 32 && pmap_depth == 24) |
1154 | result->depth = 24; |
1209 | result->depth = 24; |
1155 | else |
1210 | else |
1156 | { |
1211 | { |
1157 | /* TODO: implement image recoding */ |
1212 | /* TODO: implement image recoding */ |
1158 | } |
1213 | } |
… | |
… | |
1201 | { |
1256 | { |
1202 | if (target) |
1257 | if (target) |
1203 | { |
1258 | { |
1204 | flags &= ~isVtOrigin; |
1259 | flags &= ~isVtOrigin; |
1205 | if (pixmap != None) |
1260 | if (pixmap != None) |
|
|
1261 | { |
1206 | { /* set target's background to pixmap */ |
1262 | /* set target's background to pixmap */ |
1207 | # ifdef ENABLE_TRANSPARENCY |
1263 | # ifdef ENABLE_TRANSPARENCY |
1208 | if (flags & isTransparent) |
1264 | if (flags & isTransparent) |
1209 | { |
1265 | { |
1210 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
1266 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
1211 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
1267 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
… | |
… | |
1227 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1283 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1228 | # endif |
1284 | # endif |
1229 | } |
1285 | } |
1230 | } |
1286 | } |
1231 | else |
1287 | else |
|
|
1288 | { |
1232 | { /* set target background to a pixel */ |
1289 | /* set target background to a pixel */ |
1233 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1290 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1234 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
1291 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
1235 | /* do we also need to set scrollbar's background here ? */ |
1292 | /* do we also need to set scrollbar's background here ? */ |
1236 | # if HAVE_SCROLLBARS |
1293 | # if HAVE_SCROLLBARS |
1237 | if (target->scrollBar.win) |
1294 | if (target->scrollBar.win) |
… | |
… | |
1253 | target->want_refresh = 1; |
1310 | target->want_refresh = 1; |
1254 | flags |= hasChanged; |
1311 | flags |= hasChanged; |
1255 | } |
1312 | } |
1256 | } |
1313 | } |
1257 | |
1314 | |
1258 | #endif /* HAVE_BG_PIXMAP */ |
1315 | #endif /* HAVE_BG_PIXMAP */ |
1259 | |
1316 | |
1260 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT |
1317 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT |
1261 | /* taken from aterm-0.4.2 */ |
1318 | /* taken from aterm-0.4.2 */ |
1262 | |
1319 | |
1263 | typedef uint32_t RUINT32T; |
1320 | typedef uint32_t RUINT32T; |