… | |
… | |
28 | |
28 | |
29 | #if XRENDER |
29 | #if XRENDER |
30 | # include <X11/extensions/Xrender.h> |
30 | # include <X11/extensions/Xrender.h> |
31 | #endif |
31 | #endif |
32 | |
32 | |
|
|
33 | #ifndef FilterConvolution |
|
|
34 | #define FilterConvolution "convolution" |
|
|
35 | #endif |
|
|
36 | |
33 | #define DO_TIMING_TEST 0 |
37 | #define DO_TIMING_TEST 0 |
34 | |
38 | |
35 | #if DO_TIMING_TEST |
39 | #if DO_TIMING_TEST |
36 | # include <sys/time.h> |
40 | # include <sys/time.h> |
37 | #define TIMING_TEST_START(id) \ |
41 | #define TIMING_TEST_START(id) \ |
… | |
… | |
62 | * |
66 | * |
63 | * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. |
67 | * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. |
64 | * W and H are percentages of the terminal window size. |
68 | * W and H are percentages of the terminal window size. |
65 | * X and Y are also percentages; e.g., +50+50 centers |
69 | * X and Y are also percentages; e.g., +50+50 centers |
66 | * the image in the window. |
70 | * the image in the window. |
67 | * WxH+X Assumes Y == X |
|
|
68 | * WxH Assumes Y == X == 50 (centers the image) |
|
|
69 | * W+X+Y Assumes H == W |
|
|
70 | * W+X Assumes H == W and Y == X |
|
|
71 | * W Assumes H == W and Y == X == 50 |
|
|
72 | * |
|
|
73 | * Adjusting position only : |
|
|
74 | * =+X+Y Set position to X% by Y% (absolute). |
|
|
75 | * =+X Set position to X% by X%. |
|
|
76 | * +X+Y Adjust position horizontally X% and vertically Y% |
|
|
77 | * from current position (relative). |
|
|
78 | * +X Adjust position horizontally X% and vertically X% |
|
|
79 | * from current position. |
|
|
80 | * |
|
|
81 | * Adjusting scale only : |
|
|
82 | * Wx0 Multiply horizontal scaling factor by W% |
|
|
83 | * 0xH Multiply vertical scaling factor by H% |
|
|
84 | * 0x0 No scaling (show image at normal size). |
|
|
85 | * |
71 | * |
86 | * Pixmap Operations : (should be prepended by a colon) |
72 | * Pixmap Operations : (should be prepended by a colon) |
87 | * tile Tile image. Scaling/position modifiers above will affect |
73 | * tile Tile image. Scaling/position modifiers above will affect |
88 | * the tile size and origin. |
74 | * the tile size and origin. |
89 | * propscale When scaling, scale proportionally. That is, maintain the |
75 | * propscale When scaling, scale proportionally. That is, maintain the |
… | |
… | |
117 | #endif |
103 | #endif |
118 | flags = 0; |
104 | flags = 0; |
119 | pixmap = None; |
105 | pixmap = None; |
120 | valid_since = invalid_since = 0; |
106 | valid_since = invalid_since = 0; |
121 | target = 0; |
107 | target = 0; |
|
|
108 | target_x = target_y = 0; |
122 | } |
109 | } |
123 | |
110 | |
124 | void |
111 | void |
125 | bgPixmap_t::destroy () |
112 | bgPixmap_t::destroy () |
126 | { |
113 | { |
… | |
… | |
137 | if (pixmap && target) |
124 | if (pixmap && target) |
138 | XFreePixmap (target->dpy, pixmap); |
125 | XFreePixmap (target->dpy, pixmap); |
139 | } |
126 | } |
140 | |
127 | |
141 | bool |
128 | bool |
|
|
129 | bgPixmap_t::set_position (int x, int y) |
|
|
130 | { |
|
|
131 | |
|
|
132 | if (target_x != x |
|
|
133 | || target_y != y) |
|
|
134 | { |
|
|
135 | target_x = x; |
|
|
136 | target_y = y; |
|
|
137 | return true; |
|
|
138 | } |
|
|
139 | return false; |
|
|
140 | } |
|
|
141 | |
|
|
142 | bool |
142 | bgPixmap_t::window_size_sensitive () |
143 | bgPixmap_t::window_size_sensitive () |
143 | { |
144 | { |
144 | # ifdef ENABLE_TRANSPARENCY |
145 | # ifdef ENABLE_TRANSPARENCY |
145 | if (flags & isTransparent) |
146 | if (flags & isTransparent) |
146 | return true; |
147 | return true; |
… | |
… | |
172 | return true; |
173 | return true; |
173 | } |
174 | } |
174 | # endif |
175 | # endif |
175 | |
176 | |
176 | return false; |
177 | return false; |
177 | }; |
178 | } |
178 | |
179 | |
179 | bool bgPixmap_t::need_client_side_rendering () |
180 | bool bgPixmap_t::need_client_side_rendering () |
180 | { |
181 | { |
181 | # ifdef HAVE_AFTERIMAGE |
182 | # ifdef HAVE_AFTERIMAGE |
182 | if (original_asim) |
183 | if (original_asim) |
… | |
… | |
252 | dst_size = target_size - dst_pos; |
253 | dst_size = target_size - dst_pos; |
253 | return src_pos; |
254 | return src_pos; |
254 | } |
255 | } |
255 | |
256 | |
256 | bool |
257 | bool |
257 | bgPixmap_t::set_geometry (const char *geom) |
258 | bgPixmap_t::set_geometry (const char *geom, bool update) |
258 | { |
259 | { |
|
|
260 | bool changed = false; |
259 | int geom_flags = 0, changed = 0; |
261 | int geom_flags = 0; |
260 | int x = 0, y = 0; |
262 | int x = 0, y = 0; |
261 | unsigned int w = 0, h = 0; |
263 | unsigned int w = 0, h = 0; |
262 | unsigned int n; |
264 | unsigned int n; |
263 | unsigned long new_flags = (flags & (~geometryFlags)); |
265 | unsigned long new_flags = (flags & (~geometryFlags)); |
264 | const char *p; |
266 | const char *ops; |
265 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
267 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
266 | |
268 | |
267 | if (geom == NULL) |
269 | if (geom == NULL) |
268 | return false; |
270 | return false; |
269 | |
271 | |
270 | char str[MAXLEN_GEOM]; |
272 | char str[MAXLEN_GEOM]; |
271 | |
273 | |
272 | while (isspace(*geom)) ++geom; |
|
|
273 | if ((p = strchr (geom, ';')) == NULL) |
|
|
274 | p = strchr (geom, '\0'); |
274 | ops = strchr (geom, ':'); |
275 | |
275 | if (ops == NULL) |
|
|
276 | n = strlen (geom); |
|
|
277 | else |
276 | n = (p - geom); |
278 | n = ops - geom; |
|
|
279 | |
277 | if (n < MAXLEN_GEOM) |
280 | if (n >= MAXLEN_GEOM) |
278 | { |
281 | return false; |
279 | char *ops; |
|
|
280 | new_flags |= geometrySet; |
|
|
281 | |
282 | |
282 | memcpy (str, geom, n); |
283 | memcpy (str, geom, n); |
283 | str[n] = '\0'; |
284 | str[n] = '\0'; |
284 | if (str[0] == ':') |
285 | rxvt_strtrim (str); |
285 | ops = &str[0]; |
|
|
286 | else if (str[0] != 'x' && str[0] != 'X' && isalpha(str[0])) |
|
|
287 | ops = &str[0]; |
|
|
288 | else |
|
|
289 | { |
|
|
290 | char *tmp; |
|
|
291 | ops = strchr (str, ':'); |
|
|
292 | if (ops != NULL) |
|
|
293 | { |
|
|
294 | for (tmp = ops-1; tmp >= str && isspace(*tmp); --tmp); |
|
|
295 | *(++tmp) = '\0'; |
|
|
296 | if (ops == tmp) ++ops; |
|
|
297 | } |
|
|
298 | } |
|
|
299 | |
286 | |
300 | if (ops > str || ops == NULL) |
287 | if (str[0]) |
301 | { |
288 | { |
302 | /* we have geometry string - let's handle it prior to applying ops */ |
289 | /* we have geometry string - let's handle it prior to applying ops */ |
303 | geom_flags = XParseGeometry (str, &x, &y, &w, &h); |
290 | geom_flags = XParseGeometry (str, &x, &y, &w, &h); |
304 | |
|
|
305 | if ((geom_flags & XValue) && !(geom_flags & YValue)) |
|
|
306 | { |
|
|
307 | y = x; |
|
|
308 | geom_flags |= YValue; |
|
|
309 | } |
|
|
310 | |
|
|
311 | if (flags & geometrySet) |
|
|
312 | { |
|
|
313 | /* new geometry is an adjustment to the old one ! */ |
|
|
314 | if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) |
|
|
315 | { |
|
|
316 | if (w == 0 && h != 0) |
|
|
317 | { |
|
|
318 | w = h_scale; |
|
|
319 | h = (v_scale * h) / 100; |
|
|
320 | } |
|
|
321 | else if (h == 0 && w != 0) |
|
|
322 | { |
|
|
323 | w = (h_scale * w) / 100; |
|
|
324 | h = v_scale; |
|
|
325 | } |
|
|
326 | } |
|
|
327 | if (geom_flags & XValue) |
|
|
328 | { |
|
|
329 | if (str[0] != '=') |
|
|
330 | { |
|
|
331 | y += v_align; |
|
|
332 | x += h_align; |
|
|
333 | } |
|
|
334 | } |
|
|
335 | } |
|
|
336 | else /* setting up geometry from scratch */ |
|
|
337 | { |
|
|
338 | if (!(geom_flags & XValue)) |
|
|
339 | { |
|
|
340 | /* use default geometry - centered */ |
|
|
341 | x = y = defaultAlign; |
|
|
342 | } |
|
|
343 | else if (!(geom_flags & YValue)) |
|
|
344 | y = x; |
|
|
345 | |
|
|
346 | if ((geom_flags & (WidthValue|HeightValue)) == 0) |
|
|
347 | { |
|
|
348 | /* use default geometry - scaled */ |
|
|
349 | w = h = defaultScale; |
|
|
350 | } |
|
|
351 | else if (geom_flags & WidthValue) |
|
|
352 | { |
|
|
353 | if (!(geom_flags & HeightValue)) |
|
|
354 | h = w; |
|
|
355 | } |
|
|
356 | else |
|
|
357 | w = h; |
|
|
358 | } |
|
|
359 | } /* done parsing geometry string */ |
291 | } /* done parsing geometry string */ |
360 | else if (!(flags & geometrySet)) |
292 | |
361 | { |
293 | if (!update) |
362 | /* default geometry - scaled and centered */ |
294 | { |
|
|
295 | if (!(geom_flags & XValue)) |
363 | x = y = defaultAlign; |
296 | x = y = defaultAlign; |
|
|
297 | else if (!(geom_flags & YValue)) |
|
|
298 | y = x; |
|
|
299 | |
|
|
300 | if (!(geom_flags & (WidthValue|HeightValue))) |
364 | w = h = defaultScale; |
301 | w = h = defaultScale; |
365 | } |
302 | else if (!(geom_flags & HeightValue)) |
|
|
303 | h = w; |
|
|
304 | else if (!(geom_flags & WidthValue)) |
|
|
305 | w = h; |
366 | |
306 | |
367 | if (!(flags & geometrySet)) |
|
|
368 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
307 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
|
|
308 | } |
369 | |
309 | |
370 | if (ops) |
310 | if (ops) |
371 | { |
311 | { |
372 | while (*ops) |
312 | while (*ops) |
373 | { |
313 | { |
374 | while (*ops == ':' || isspace(*ops)) ++ops; |
314 | while (*ops == ':' || isspace(*ops)) ++ops; |
375 | |
315 | |
376 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof (op_str) - 1) == 0) |
316 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof (op_str) - 1) == 0) |
377 | if (CHECK_GEOM_OPS ("tile")) |
317 | if (CHECK_GEOM_OPS ("tile")) |
378 | { |
318 | { |
379 | w = h = noScale; |
319 | w = h = noScale; |
380 | geom_flags |= WidthValue|HeightValue; |
320 | geom_flags |= WidthValue|HeightValue; |
381 | } |
321 | } |
382 | else if (CHECK_GEOM_OPS ("propscale")) |
322 | else if (CHECK_GEOM_OPS ("propscale")) |
383 | { |
323 | { |
384 | new_flags |= propScale; |
324 | new_flags |= propScale; |
385 | } |
325 | } |
386 | else if (CHECK_GEOM_OPS ("hscale")) |
326 | else if (CHECK_GEOM_OPS ("hscale")) |
387 | { |
327 | { |
388 | if (w == 0) w = windowScale; |
328 | if (w == 0) w = windowScale; |
389 | |
329 | |
390 | h = noScale; |
330 | h = noScale; |
391 | geom_flags |= WidthValue|HeightValue; |
331 | geom_flags |= WidthValue|HeightValue; |
392 | } |
332 | } |
393 | else if (CHECK_GEOM_OPS ("vscale")) |
333 | else if (CHECK_GEOM_OPS ("vscale")) |
394 | { |
334 | { |
395 | if (h == 0) h = windowScale; |
335 | if (h == 0) h = windowScale; |
396 | |
336 | |
397 | w = noScale; |
337 | w = noScale; |
398 | geom_flags |= WidthValue|HeightValue; |
338 | geom_flags |= WidthValue|HeightValue; |
399 | } |
339 | } |
400 | else if (CHECK_GEOM_OPS ("scale")) |
340 | else if (CHECK_GEOM_OPS ("scale")) |
401 | { |
341 | { |
402 | if (h == 0) h = windowScale; |
342 | if (h == 0) h = windowScale; |
403 | if (w == 0) w = windowScale; |
343 | if (w == 0) w = windowScale; |
404 | |
344 | |
405 | geom_flags |= WidthValue|HeightValue; |
345 | geom_flags |= WidthValue|HeightValue; |
406 | } |
346 | } |
407 | else if (CHECK_GEOM_OPS ("auto")) |
347 | else if (CHECK_GEOM_OPS ("auto")) |
408 | { |
348 | { |
409 | w = h = windowScale; |
349 | w = h = windowScale; |
410 | x = y = centerAlign; |
350 | x = y = centerAlign; |
411 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
351 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
412 | } |
352 | } |
413 | else if (CHECK_GEOM_OPS ("root")) |
353 | else if (CHECK_GEOM_OPS ("root")) |
414 | { |
354 | { |
415 | new_flags |= rootAlign; |
355 | new_flags |= rootAlign; |
416 | w = h = noScale; |
356 | w = h = noScale; |
417 | geom_flags |= WidthValue|HeightValue; |
357 | geom_flags |= WidthValue|HeightValue; |
418 | } |
358 | } |
419 | # undef CHECK_GEOM_OPS |
359 | # undef CHECK_GEOM_OPS |
420 | |
360 | |
421 | while (*ops != ':' && *ops != '\0') ++ops; |
361 | while (*ops != ':' && *ops != '\0') ++ops; |
422 | } /* done parsing ops */ |
362 | } /* done parsing ops */ |
423 | } |
363 | } |
424 | |
364 | |
425 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) ++changed; |
365 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
426 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) ++changed; |
366 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
427 | if (check_set_align_value (geom_flags, XValue, h_align, x)) ++changed; |
367 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
428 | if (check_set_align_value (geom_flags, YValue, v_align, y)) ++changed; |
368 | if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; |
429 | } |
|
|
430 | |
369 | |
431 | if (new_flags != flags) |
370 | if (new_flags != flags) |
432 | { |
371 | { |
433 | flags = new_flags; |
372 | flags = new_flags; |
434 | changed++; |
373 | changed = true; |
435 | } |
374 | } |
436 | |
375 | |
437 | return (changed > 0); |
376 | return changed; |
438 | } |
377 | } |
439 | |
378 | |
440 | void |
379 | void |
441 | bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
380 | bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
442 | { |
381 | { |
… | |
… | |
459 | if (!w) w = image_width; |
398 | if (!w) w = image_width; |
460 | if (!h) h = image_height; |
399 | if (!h) h = image_height; |
461 | |
400 | |
462 | if (flags & rootAlign) |
401 | if (flags & rootAlign) |
463 | { |
402 | { |
464 | target->get_window_origin (x, y); |
|
|
465 | x = -x; |
403 | x = -target_x; |
466 | y = -y; |
404 | y = -target_y; |
467 | } |
405 | } |
468 | else |
406 | else |
469 | { |
407 | { |
470 | x = make_align_position (h_align, target_width, w); |
408 | x = make_align_position (h_align, target_width, w); |
471 | y = make_align_position (v_align, target_height, h); |
409 | y = make_align_position (v_align, target_height, h); |
… | |
… | |
665 | if (result) |
603 | if (result) |
666 | { |
604 | { |
667 | XGCValues gcv; |
605 | XGCValues gcv; |
668 | GC gc; |
606 | GC gc; |
669 | |
607 | |
670 | if (pixmap) |
|
|
671 | { |
|
|
672 | if (pmap_width != new_pmap_width |
|
|
673 | || pmap_height != new_pmap_height |
|
|
674 | || pmap_depth != target->depth) |
|
|
675 | { |
|
|
676 | XFreePixmap (target->dpy, pixmap); |
|
|
677 | pixmap = None; |
|
|
678 | } |
|
|
679 | } |
|
|
680 | |
|
|
681 | /* create Pixmap */ |
608 | /* create Pixmap */ |
682 | if (pixmap == None) |
609 | if (pixmap == None |
|
|
610 | || pmap_width != new_pmap_width |
|
|
611 | || pmap_height != new_pmap_height |
|
|
612 | || pmap_depth != target->depth) |
683 | { |
613 | { |
|
|
614 | if (pixmap) |
|
|
615 | XFreePixmap (target->dpy, pixmap); |
684 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
616 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
685 | pmap_width = new_pmap_width; |
617 | pmap_width = new_pmap_width; |
686 | pmap_height = new_pmap_height; |
618 | pmap_height = new_pmap_height; |
687 | pmap_depth = target->depth; |
619 | pmap_depth = target->depth; |
688 | } |
620 | } |
… | |
… | |
796 | new_pmap_width = min (image_width, target_width); |
728 | new_pmap_width = min (image_width, target_width); |
797 | new_pmap_height = min (image_height, target_height); |
729 | new_pmap_height = min (image_height, target_height); |
798 | } |
730 | } |
799 | } |
731 | } |
800 | |
732 | |
801 | if (pixmap) |
|
|
802 | { |
|
|
803 | if (pmap_width != new_pmap_width |
|
|
804 | || pmap_height != new_pmap_height |
|
|
805 | || pmap_depth != target->depth) |
|
|
806 | { |
|
|
807 | XFreePixmap (target->dpy, pixmap); |
|
|
808 | pixmap = None; |
|
|
809 | } |
|
|
810 | } |
|
|
811 | |
|
|
812 | if (pixmap == None) |
733 | if (pixmap == None |
|
|
734 | || pmap_width != new_pmap_width |
|
|
735 | || pmap_height != new_pmap_height |
|
|
736 | || pmap_depth != target->depth) |
813 | { |
737 | { |
|
|
738 | if (pixmap) |
|
|
739 | XFreePixmap (target->dpy, pixmap); |
814 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
740 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
815 | pmap_width = new_pmap_width; |
741 | pmap_width = new_pmap_width; |
816 | pmap_height = new_pmap_height; |
742 | pmap_height = new_pmap_height; |
817 | pmap_depth = target->depth; |
743 | pmap_depth = target->depth; |
818 | } |
744 | } |
… | |
… | |
971 | } |
897 | } |
972 | |
898 | |
973 | bool |
899 | bool |
974 | bgPixmap_t::set_blur_radius (const char *geom) |
900 | bgPixmap_t::set_blur_radius (const char *geom) |
975 | { |
901 | { |
976 | int changed = 0; |
902 | bool changed = false; |
977 | unsigned int hr, vr; |
903 | unsigned int hr, vr; |
978 | int junk; |
904 | int junk; |
979 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
905 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
980 | |
906 | |
981 | if (!(geom_flags & WidthValue)) |
907 | if (!(geom_flags & WidthValue)) |
… | |
… | |
986 | min_it (hr, 128); |
912 | min_it (hr, 128); |
987 | min_it (vr, 128); |
913 | min_it (vr, 128); |
988 | |
914 | |
989 | if (h_blurRadius != hr) |
915 | if (h_blurRadius != hr) |
990 | { |
916 | { |
991 | ++changed; |
917 | changed = true; |
992 | h_blurRadius = hr; |
918 | h_blurRadius = hr; |
993 | } |
919 | } |
994 | |
920 | |
995 | if (v_blurRadius != vr) |
921 | if (v_blurRadius != vr) |
996 | { |
922 | { |
997 | ++changed; |
923 | changed = true; |
998 | v_blurRadius = vr; |
924 | v_blurRadius = vr; |
999 | } |
925 | } |
1000 | |
926 | |
1001 | if (v_blurRadius == 0 && h_blurRadius == 0) |
927 | if (v_blurRadius == 0 && h_blurRadius == 0) |
1002 | flags &= ~blurNeeded; |
928 | flags &= ~blurNeeded; |
1003 | else |
929 | else |
1004 | flags |= blurNeeded; |
930 | flags |= blurNeeded; |
1005 | |
931 | |
1006 | return (changed > 0); |
932 | return changed; |
1007 | } |
933 | } |
1008 | |
934 | |
1009 | static inline unsigned long |
935 | static inline unsigned long |
1010 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
936 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
1011 | { |
937 | { |
… | |
… | |
1014 | bool has_shade = shade != 100; |
940 | bool has_shade = shade != 100; |
1015 | |
941 | |
1016 | if (tint) |
942 | if (tint) |
1017 | { |
943 | { |
1018 | tint->get (c); |
944 | tint->get (c); |
1019 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
945 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x00ff || (cmp) >= 0xff00) |
|
|
946 | if (!has_shade |
1020 | if (!has_shade && IS_COMPONENT_WHOLESOME (c.r) |
947 | && IS_COMPONENT_WHOLESOME (c.r) |
1021 | && IS_COMPONENT_WHOLESOME (c.g) |
948 | && IS_COMPONENT_WHOLESOME (c.g) |
1022 | && IS_COMPONENT_WHOLESOME (c.b)) |
949 | && IS_COMPONENT_WHOLESOME (c.b)) |
1023 | flags |= bgPixmap_t::tintWholesome; |
950 | flags |= bgPixmap_t::tintWholesome; |
1024 | # undef IS_COMPONENT_WHOLESOME |
951 | # undef IS_COMPONENT_WHOLESOME |
1025 | } |
952 | } |
1026 | |
953 | |
1027 | if (has_shade) |
954 | if (has_shade || tint) |
1028 | flags |= bgPixmap_t::tintNeeded; |
955 | flags |= bgPixmap_t::tintNeeded; |
1029 | else if (tint) |
|
|
1030 | { |
|
|
1031 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
|
|
1032 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
|
|
1033 | { |
|
|
1034 | flags |= bgPixmap_t::tintNeeded; |
|
|
1035 | } |
|
|
1036 | } |
|
|
1037 | |
956 | |
1038 | return flags; |
957 | return flags; |
1039 | } |
958 | } |
1040 | |
959 | |
1041 | bool |
960 | bool |
… | |
… | |
1238 | |
1157 | |
1239 | if (mask_pic && overlay_pic && back_pic) |
1158 | if (mask_pic && overlay_pic && back_pic) |
1240 | { |
1159 | { |
1241 | XRenderColor mask_c; |
1160 | XRenderColor mask_c; |
1242 | |
1161 | |
1243 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
1162 | mask_c.red = mask_c.green = mask_c.blue = shade > 100 ? 0xffff : 0; |
1244 | mask_c.alpha = 0xffff; |
1163 | mask_c.alpha = 0xffff; |
1245 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1164 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1246 | |
1165 | |
1247 | mask_c.alpha = 0; |
1166 | mask_c.alpha = 0; |
1248 | mask_c.red = 0xffff - c.r; |
1167 | mask_c.red = 0xffff - c.r; |
… | |
… | |
1288 | int window_height = target->szHint.height; |
1207 | int window_height = target->szHint.height; |
1289 | int sx, sy; |
1208 | int sx, sy; |
1290 | XGCValues gcv; |
1209 | XGCValues gcv; |
1291 | GC gc; |
1210 | GC gc; |
1292 | |
1211 | |
1293 | target->get_window_origin (sx, sy); |
1212 | sx = target_x; |
|
|
1213 | sy = target_y; |
1294 | |
1214 | |
1295 | /* check if we are outside of the visible part of the virtual screen : */ |
1215 | /* check if we are outside of the visible part of the virtual screen : */ |
1296 | if (sx + window_width <= 0 || sy + window_height <= 0 |
1216 | if (sx + window_width <= 0 || sy + window_height <= 0 |
1297 | || sx >= root_width || sy >= root_height) |
1217 | || sx >= root_width || sy >= root_height) |
1298 | return 0; |
1218 | return 0; |
… | |
… | |
1351 | |
1271 | |
1352 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
1272 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
1353 | return 0; |
1273 | return 0; |
1354 | |
1274 | |
1355 | /* straightforward pixmap copy */ |
1275 | /* straightforward pixmap copy */ |
|
|
1276 | while (sx < 0) sx += (int)root_width; |
|
|
1277 | while (sy < 0) sy += (int)root_height; |
|
|
1278 | |
1356 | gcv.tile = recoded_root_pmap; |
1279 | gcv.tile = recoded_root_pmap; |
1357 | gcv.fill_style = FillTiled; |
1280 | gcv.fill_style = FillTiled; |
1358 | |
|
|
1359 | while (sx < 0) sx += (int)root_width; |
|
|
1360 | while (sy < 0) sy += (int)root_height; |
|
|
1361 | |
|
|
1362 | gcv.ts_x_origin = -sx; |
1281 | gcv.ts_x_origin = -sx; |
1363 | gcv.ts_y_origin = -sy; |
1282 | gcv.ts_y_origin = -sy; |
1364 | gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1283 | gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1365 | |
1284 | |
1366 | if (gc) |
1285 | if (gc) |
1367 | { |
1286 | { |
1368 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
1287 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
1369 | result |= transpPmapTiled; |
1288 | result |= transpPmapTiled; |
1370 | XFreeGC (dpy, gc); |
1289 | XFreeGC (dpy, gc); |
1371 | } |
|
|
1372 | |
1290 | |
1373 | if (tiled_root_pmap != None) |
|
|
1374 | { |
|
|
1375 | if (!need_client_side_rendering ()) |
1291 | if (!need_client_side_rendering ()) |
1376 | { |
1292 | { |
1377 | if ((flags & blurNeeded) |
1293 | if ((flags & blurNeeded) |
1378 | && (flags & HAS_RENDER_CONV)) |
1294 | && (flags & HAS_RENDER_CONV)) |
1379 | { |
1295 | { |
… | |
… | |
1394 | pixmap = tiled_root_pmap; |
1310 | pixmap = tiled_root_pmap; |
1395 | pmap_width = window_width; |
1311 | pmap_width = window_width; |
1396 | pmap_height = window_height; |
1312 | pmap_height = window_height; |
1397 | pmap_depth = target->depth; |
1313 | pmap_depth = target->depth; |
1398 | } |
1314 | } |
|
|
1315 | else |
|
|
1316 | XFreePixmap (dpy, tiled_root_pmap); |
1399 | |
1317 | |
1400 | if (recoded_root_pmap != root_pixmap) |
1318 | if (recoded_root_pmap != root_pixmap) |
1401 | XFreePixmap (dpy, recoded_root_pmap); |
1319 | XFreePixmap (dpy, recoded_root_pmap); |
1402 | |
1320 | |
1403 | return result; |
1321 | return result; |
… | |
… | |
1412 | |
1330 | |
1413 | root_pixmap = new_root_pixmap; |
1331 | root_pixmap = new_root_pixmap; |
1414 | } |
1332 | } |
1415 | # endif /* ENABLE_TRANSPARENCY */ |
1333 | # endif /* ENABLE_TRANSPARENCY */ |
1416 | |
1334 | |
1417 | # ifndef HAVE_AFTERIMAGE |
1335 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1418 | static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); |
1336 | static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c); |
1419 | # endif |
1337 | # endif |
1420 | |
1338 | |
1421 | bool |
1339 | bool |
1422 | bgPixmap_t::render () |
1340 | bgPixmap_t::render () |
1423 | { |
1341 | { |
… | |
… | |
1433 | /* we need to re-generate transparency pixmap in that case ! */ |
1351 | /* we need to re-generate transparency pixmap in that case ! */ |
1434 | background_flags = make_transparency_pixmap (); |
1352 | background_flags = make_transparency_pixmap (); |
1435 | if (background_flags == 0) |
1353 | if (background_flags == 0) |
1436 | return false; |
1354 | return false; |
1437 | else if ((background_flags & transpTransformations) == (flags & transpTransformations)) |
1355 | else if ((background_flags & transpTransformations) == (flags & transpTransformations)) |
1438 | flags = flags & ~isInvalid; |
1356 | flags &= ~isInvalid; |
1439 | } |
1357 | } |
1440 | # endif |
1358 | # endif |
1441 | |
1359 | |
1442 | # ifdef BG_IMAGE_FROM_FILE |
1360 | # ifdef BG_IMAGE_FROM_FILE |
1443 | if (have_image |
1361 | if (have_image |
1444 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1362 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1445 | { |
1363 | { |
1446 | if (render_image (background_flags)) |
1364 | if (render_image (background_flags)) |
1447 | flags = flags & ~isInvalid; |
1365 | flags &= ~isInvalid; |
1448 | } |
1366 | } |
1449 | # endif |
1367 | # endif |
1450 | |
1368 | |
|
|
1369 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1451 | XImage *result = NULL; |
1370 | XImage *result = NULL; |
1452 | |
1371 | |
1453 | if (background_flags && (flags & isInvalid)) |
1372 | if (background_flags && (flags & isInvalid)) |
1454 | { |
1373 | { |
1455 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1374 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1456 | } |
1375 | } |
1457 | |
1376 | |
1458 | if (result) |
1377 | if (result) |
1459 | { |
1378 | { |
1460 | # if !defined(HAVE_AFTERIMAGE) && !XRENDER |
|
|
1461 | /* our own client-side tinting */ |
1379 | /* our own client-side tinting */ |
1462 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1380 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1463 | { |
1381 | { |
1464 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1382 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1465 | if (flags & tintSet) |
1383 | if (flags & tintSet) |
1466 | tint.get (c); |
1384 | tint.get (c); |
1467 | ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c.r, c.g, c.b); |
1385 | ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c); |
1468 | } |
1386 | } |
1469 | # endif |
|
|
1470 | |
1387 | |
1471 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1388 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1472 | |
1389 | |
1473 | if (gc) |
1390 | if (gc) |
1474 | { |
1391 | { |
1475 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1392 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1476 | |
1393 | |
1477 | XFreeGC (target->dpy, gc); |
1394 | XFreeGC (target->dpy, gc); |
1478 | flags = flags & ~isInvalid; |
1395 | flags &= ~isInvalid; |
1479 | } |
1396 | } |
1480 | |
1397 | |
1481 | XDestroyImage (result); |
1398 | XDestroyImage (result); |
1482 | } |
1399 | } |
|
|
1400 | # endif |
1483 | |
1401 | |
1484 | if (flags & isInvalid) |
1402 | if (flags & isInvalid) |
1485 | { |
1403 | { |
1486 | if (pixmap != None) |
1404 | if (pixmap != None) |
1487 | { |
1405 | { |
… | |
… | |
1573 | flags |= hasChanged; |
1491 | flags |= hasChanged; |
1574 | } |
1492 | } |
1575 | |
1493 | |
1576 | #endif /* HAVE_BG_PIXMAP */ |
1494 | #endif /* HAVE_BG_PIXMAP */ |
1577 | |
1495 | |
1578 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XRENDER |
1496 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1579 | /* taken from aterm-0.4.2 */ |
1497 | /* taken from aterm-0.4.2 */ |
1580 | |
1498 | |
1581 | static void |
1499 | static void |
1582 | ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) |
1500 | ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c) |
1583 | { |
1501 | { |
1584 | int sh_r, sh_g, sh_b; |
1502 | int sh_r, sh_g, sh_b; |
1585 | uint32_t mask_r, mask_g, mask_b; |
1503 | uint32_t mask_r, mask_g, mask_b; |
1586 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1504 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1587 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
1505 | rgba low; |
1588 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
1506 | rgba high; |
1589 | int i; |
1507 | int i; |
1590 | int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; |
1508 | int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; |
1591 | |
1509 | |
1592 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return; |
1510 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return; |
1593 | |
1511 | |
… | |
… | |
1658 | /* prepare limits for color transformation (each channel is handled separately) */ |
1576 | /* prepare limits for color transformation (each channel is handled separately) */ |
1659 | if (shade > 100) |
1577 | if (shade > 100) |
1660 | { |
1578 | { |
1661 | shade = 200 - shade; |
1579 | shade = 200 - shade; |
1662 | |
1580 | |
1663 | lower_lim_r = 65535-rm; |
1581 | high.r = (65535 - c.r) * shade / 100; |
1664 | lower_lim_g = 65535-gm; |
1582 | high.g = (65535 - c.g) * shade / 100; |
1665 | lower_lim_b = 65535-bm; |
1583 | high.b = (65535 - c.b) * shade / 100; |
1666 | |
1584 | |
1667 | lower_lim_r = 65535-(unsigned int)(((uint32_t)lower_lim_r)*((uint32_t)shade)/100); |
1585 | low.r = 65535 - high.r; |
1668 | lower_lim_g = 65535-(unsigned int)(((uint32_t)lower_lim_g)*((uint32_t)shade)/100); |
1586 | low.g = 65535 - high.g; |
1669 | lower_lim_b = 65535-(unsigned int)(((uint32_t)lower_lim_b)*((uint32_t)shade)/100); |
1587 | low.b = 65535 - high.b; |
1670 | |
|
|
1671 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
1672 | } |
1588 | } |
1673 | else |
1589 | else |
1674 | { |
1590 | { |
|
|
1591 | high.r = c.r * shade / 100; |
|
|
1592 | high.g = c.g * shade / 100; |
|
|
1593 | high.b = c.b * shade / 100; |
1675 | |
1594 | |
1676 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
1595 | low.r = low.g = low.b = 0; |
1677 | |
|
|
1678 | upper_lim_r = (unsigned int)((((uint32_t)rm)*((uint32_t)shade))/100); |
|
|
1679 | upper_lim_g = (unsigned int)((((uint32_t)gm)*((uint32_t)shade))/100); |
|
|
1680 | upper_lim_b = (unsigned int)((((uint32_t)bm)*((uint32_t)shade))/100); |
|
|
1681 | } |
1596 | } |
1682 | |
1597 | |
1683 | /* fill our lookup tables */ |
1598 | /* fill our lookup tables */ |
1684 | for (i = 0; i <= mask_r>>sh_r; i++) |
1599 | for (i = 0; i <= mask_r>>sh_r; i++) |
1685 | { |
1600 | { |
1686 | uint32_t tmp; |
1601 | uint32_t tmp; |
1687 | tmp = ((uint32_t)i)*((uint32_t)(upper_lim_r-lower_lim_r)); |
1602 | tmp = i * high.r; |
1688 | tmp += ((uint32_t)(mask_r>>sh_r))*((uint32_t)lower_lim_r); |
1603 | tmp += (mask_r>>sh_r) * low.r; |
1689 | lookup_r[i] = (tmp/65535)<<sh_r; |
1604 | lookup_r[i] = (tmp/65535)<<sh_r; |
1690 | } |
1605 | } |
1691 | for (i = 0; i <= mask_g>>sh_g; i++) |
1606 | for (i = 0; i <= mask_g>>sh_g; i++) |
1692 | { |
1607 | { |
1693 | uint32_t tmp; |
1608 | uint32_t tmp; |
1694 | tmp = ((uint32_t)i)*((uint32_t)(upper_lim_g-lower_lim_g)); |
1609 | tmp = i * high.g; |
1695 | tmp += ((uint32_t)(mask_g>>sh_g))*((uint32_t)lower_lim_g); |
1610 | tmp += (mask_g>>sh_g) * low.g; |
1696 | lookup_g[i] = (tmp/65535)<<sh_g; |
1611 | lookup_g[i] = (tmp/65535)<<sh_g; |
1697 | } |
1612 | } |
1698 | for (i = 0; i <= mask_b>>sh_b; i++) |
1613 | for (i = 0; i <= mask_b>>sh_b; i++) |
1699 | { |
1614 | { |
1700 | uint32_t tmp; |
1615 | uint32_t tmp; |
1701 | tmp = ((uint32_t)i)*((uint32_t)(upper_lim_b-lower_lim_b)); |
1616 | tmp = i * high.b; |
1702 | tmp += ((uint32_t)(mask_b>>sh_b))*((uint32_t)lower_lim_b); |
1617 | tmp += (mask_b>>sh_b) * low.b; |
1703 | lookup_b[i] = (tmp/65535)<<sh_b; |
1618 | lookup_b[i] = (tmp/65535)<<sh_b; |
1704 | } |
1619 | } |
1705 | |
1620 | |
1706 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1621 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1707 | if (srcImage->bits_per_pixel == 32 |
1622 | if (srcImage->bits_per_pixel == 32 |