… | |
… | |
46 | * W and H are percentages of the terminal window size. |
46 | * W and H are percentages of the terminal window size. |
47 | * X and Y are also percentages; e.g., +50+50 centers |
47 | * X and Y are also percentages; e.g., +50+50 centers |
48 | * the image in the window. |
48 | * the image in the window. |
49 | * |
49 | * |
50 | * Pixmap Operations : (should be prepended by a colon) |
50 | * Pixmap Operations : (should be prepended by a colon) |
51 | * tile Tile image. Scaling/position modifiers above will affect |
|
|
52 | * the tile size and origin. |
|
|
53 | * propscale When scaling, scale proportionally. That is, maintain the |
|
|
54 | * proper aspect ratio for the image. Any portion of the |
|
|
55 | * background not covered by the image is filled with the |
|
|
56 | * current background color. |
|
|
57 | * hscale Scale horizontally, tile vertically ? |
|
|
58 | * vscale Tile horizontally, scale vertically ? |
|
|
59 | * scale Scale both up and down |
|
|
60 | * auto Same as 100x100+50+50 |
|
|
61 | */ |
51 | */ |
62 | |
52 | |
63 | #ifdef HAVE_BG_PIXMAP |
53 | #ifdef HAVE_BG_PIXMAP |
64 | void |
54 | void |
65 | rxvt_term::bg_destroy () |
55 | rxvt_term::bg_destroy () |
… | |
… | |
207 | { |
197 | { |
208 | bool changed = false; |
198 | bool changed = false; |
209 | int geom_flags = 0; |
199 | int geom_flags = 0; |
210 | int x = 0, y = 0; |
200 | int x = 0, y = 0; |
211 | unsigned int w = 0, h = 0; |
201 | unsigned int w = 0, h = 0; |
212 | unsigned int n; |
|
|
213 | unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS)); |
202 | unsigned long new_flags = (bg_flags & (~BG_GEOMETRY_FLAGS)); |
214 | const char *ops; |
|
|
215 | |
203 | |
216 | if (geom == NULL) |
204 | if (geom == NULL) |
217 | return false; |
205 | return false; |
218 | |
206 | |
219 | char str[256]; |
207 | if (geom[0]) |
220 | |
|
|
221 | ops = strchr (geom, ':'); |
|
|
222 | if (ops == NULL) |
|
|
223 | n = strlen (geom); |
|
|
224 | else |
|
|
225 | n = ops - geom; |
|
|
226 | |
|
|
227 | if (n >= sizeof (str)) |
|
|
228 | return false; |
|
|
229 | |
|
|
230 | memcpy (str, geom, n); |
|
|
231 | str[n] = '\0'; |
|
|
232 | rxvt_strtrim (str); |
|
|
233 | |
|
|
234 | if (str[0]) |
|
|
235 | { |
208 | { |
236 | /* we have geometry string - let's handle it prior to applying ops */ |
209 | char **arr = rxvt_strsplit (':', geom); |
|
|
210 | |
|
|
211 | for (int i = 0; arr[i]; i++) |
|
|
212 | { |
|
|
213 | if (!strcasecmp (arr[i], "style=tiled")) |
|
|
214 | { |
|
|
215 | new_flags = BG_TILE; |
|
|
216 | w = h = noScale; |
|
|
217 | x = y = 0; |
|
|
218 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
|
|
219 | } |
|
|
220 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
|
|
221 | { |
|
|
222 | new_flags = BG_PROP_SCALE; |
|
|
223 | w = h = windowScale; |
|
|
224 | x = y = centerAlign; |
|
|
225 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
|
|
226 | } |
|
|
227 | else if (!strcasecmp (arr[i], "style=stretched")) |
|
|
228 | { |
|
|
229 | new_flags = 0; |
|
|
230 | w = h = windowScale; |
|
|
231 | geom_flags = WidthValue|HeightValue; |
|
|
232 | } |
|
|
233 | else if (!strcasecmp (arr[i], "style=centered")) |
|
|
234 | { |
|
|
235 | new_flags = 0; |
|
|
236 | w = h = noScale; |
|
|
237 | x = y = centerAlign; |
|
|
238 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
|
|
239 | } |
|
|
240 | else if (!strcasecmp (arr[i], "style=root-tiled")) |
|
|
241 | { |
|
|
242 | new_flags = BG_TILE|BG_ROOT_ALIGN; |
|
|
243 | w = h = noScale; |
|
|
244 | geom_flags = WidthValue|HeightValue; |
|
|
245 | } |
|
|
246 | else if (!strcasecmp (arr[i], "op=tile")) |
|
|
247 | new_flags |= BG_TILE; |
|
|
248 | else if (!strcasecmp (arr[i], "op=pscale")) |
|
|
249 | new_flags |= BG_PROP_SCALE; |
|
|
250 | else if (!strcasecmp (arr[i], "op=root")) |
|
|
251 | new_flags |= BG_ROOT_ALIGN; |
|
|
252 | |
|
|
253 | // deprecated |
|
|
254 | else if (!strcasecmp (arr[i], "tile")) |
|
|
255 | { |
|
|
256 | new_flags |= BG_TILE; |
|
|
257 | w = h = noScale; |
|
|
258 | geom_flags |= WidthValue|HeightValue; |
|
|
259 | } |
|
|
260 | else if (!strcasecmp (arr[i], "propscale")) |
|
|
261 | { |
|
|
262 | new_flags |= BG_PROP_SCALE; |
|
|
263 | } |
|
|
264 | else if (!strcasecmp (arr[i], "hscale")) |
|
|
265 | { |
|
|
266 | new_flags |= BG_TILE; |
|
|
267 | w = windowScale; |
|
|
268 | h = noScale; |
|
|
269 | geom_flags |= WidthValue|HeightValue; |
|
|
270 | } |
|
|
271 | else if (!strcasecmp (arr[i], "vscale")) |
|
|
272 | { |
|
|
273 | new_flags |= BG_TILE; |
|
|
274 | h = windowScale; |
|
|
275 | w = noScale; |
|
|
276 | geom_flags |= WidthValue|HeightValue; |
|
|
277 | } |
|
|
278 | else if (!strcasecmp (arr[i], "scale")) |
|
|
279 | { |
|
|
280 | w = h = windowScale; |
|
|
281 | geom_flags |= WidthValue|HeightValue; |
|
|
282 | } |
|
|
283 | else if (!strcasecmp (arr[i], "auto")) |
|
|
284 | { |
|
|
285 | w = h = windowScale; |
|
|
286 | x = y = centerAlign; |
|
|
287 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
|
|
288 | } |
|
|
289 | else if (!strcasecmp (arr[i], "root")) |
|
|
290 | { |
|
|
291 | new_flags |= BG_TILE|BG_ROOT_ALIGN; |
|
|
292 | w = h = noScale; |
|
|
293 | geom_flags |= WidthValue|HeightValue; |
|
|
294 | } |
|
|
295 | |
|
|
296 | else |
237 | geom_flags = XParseGeometry (str, &x, &y, &w, &h); |
297 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
238 | } /* done parsing geometry string */ |
298 | } /* done parsing ops */ |
|
|
299 | |
|
|
300 | rxvt_free_strsplit (arr); |
|
|
301 | } |
239 | |
302 | |
240 | if (!update) |
303 | if (!update) |
241 | { |
304 | { |
242 | if (!(geom_flags & XValue)) |
305 | if (!(geom_flags & XValue)) |
243 | x = y = defaultAlign; |
306 | x = y = defaultAlign; |
… | |
… | |
252 | w = h; |
315 | w = h; |
253 | |
316 | |
254 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
317 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
255 | } |
318 | } |
256 | |
319 | |
257 | if (ops) |
|
|
258 | { |
|
|
259 | char **arr = rxvt_strsplit (':', ops + 1); |
|
|
260 | |
|
|
261 | for (int i = 0; arr[i]; i++) |
|
|
262 | { |
|
|
263 | if (!strcasecmp (arr[i], "tile")) |
|
|
264 | { |
|
|
265 | w = h = noScale; |
|
|
266 | geom_flags |= WidthValue|HeightValue; |
|
|
267 | } |
|
|
268 | else if (!strcasecmp (arr[i], "propscale")) |
|
|
269 | { |
|
|
270 | new_flags |= BG_PROP_SCALE; |
|
|
271 | } |
|
|
272 | else if (!strcasecmp (arr[i], "hscale")) |
|
|
273 | { |
|
|
274 | if (w == 0) w = windowScale; |
|
|
275 | |
|
|
276 | h = noScale; |
|
|
277 | geom_flags |= WidthValue|HeightValue; |
|
|
278 | } |
|
|
279 | else if (!strcasecmp (arr[i], "vscale")) |
|
|
280 | { |
|
|
281 | if (h == 0) h = windowScale; |
|
|
282 | |
|
|
283 | w = noScale; |
|
|
284 | geom_flags |= WidthValue|HeightValue; |
|
|
285 | } |
|
|
286 | else if (!strcasecmp (arr[i], "scale")) |
|
|
287 | { |
|
|
288 | if (h == 0) h = windowScale; |
|
|
289 | if (w == 0) w = windowScale; |
|
|
290 | |
|
|
291 | geom_flags |= WidthValue|HeightValue; |
|
|
292 | } |
|
|
293 | else if (!strcasecmp (arr[i], "auto")) |
|
|
294 | { |
|
|
295 | w = h = windowScale; |
|
|
296 | x = y = centerAlign; |
|
|
297 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
|
|
298 | } |
|
|
299 | else if (!strcasecmp (arr[i], "root")) |
|
|
300 | { |
|
|
301 | new_flags |= BG_ROOT_ALIGN; |
|
|
302 | w = h = noScale; |
|
|
303 | geom_flags |= WidthValue|HeightValue; |
|
|
304 | } |
|
|
305 | } /* done parsing ops */ |
|
|
306 | |
|
|
307 | rxvt_free_strsplit (arr); |
|
|
308 | } |
|
|
309 | |
|
|
310 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
320 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
311 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
321 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
312 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
322 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
313 | if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; |
323 | if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; |
314 | |
324 | |
… | |
… | |
325 | rxvt_term::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
335 | rxvt_term::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y) |
326 | { |
336 | { |
327 | int target_width = szHint.width; |
337 | int target_width = szHint.width; |
328 | int target_height = szHint.height; |
338 | int target_height = szHint.height; |
329 | |
339 | |
|
|
340 | w = h_scale * target_width / 100; |
|
|
341 | h = v_scale * target_height / 100; |
|
|
342 | |
330 | if (bg_flags & BG_PROP_SCALE) |
343 | if (bg_flags & BG_PROP_SCALE) |
331 | { |
344 | { |
332 | float scale = (float)target_width / image_width; |
345 | float scale = (float)w / image_width; |
333 | min_it (scale, (float)target_height / image_height); |
346 | min_it (scale, (float)h / image_height); |
334 | w = image_width * scale + 0.5; |
347 | w = image_width * scale + 0.5; |
335 | h = image_height * scale + 0.5; |
348 | h = image_height * scale + 0.5; |
336 | } |
349 | } |
337 | else |
|
|
338 | { |
|
|
339 | w = h_scale * target_width / 100; |
|
|
340 | h = v_scale * target_height / 100; |
|
|
341 | } |
|
|
342 | |
350 | |
343 | if (!w) w = image_width; |
351 | if (!w) w = image_width; |
344 | if (!h) h = image_height; |
352 | if (!h) h = image_height; |
345 | |
353 | |
346 | if (bg_flags & BG_ROOT_ALIGN) |
354 | if (bg_flags & BG_ROOT_ALIGN) |
… | |
… | |
353 | x = make_align_position (h_align, target_width, w); |
361 | x = make_align_position (h_align, target_width, w); |
354 | y = make_align_position (v_align, target_height, h); |
362 | y = make_align_position (v_align, target_height, h); |
355 | } |
363 | } |
356 | |
364 | |
357 | bg_flags &= ~BG_IS_SIZE_SENSITIVE; |
365 | bg_flags &= ~BG_IS_SIZE_SENSITIVE; |
358 | if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale |
366 | if (!(bg_flags & BG_TILE) |
|
|
367 | || h_scale || v_scale |
359 | || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) |
368 | || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) |
360 | || w > target_width || h > target_height) |
369 | || w > target_width || h > target_height) |
361 | bg_flags |= BG_IS_SIZE_SENSITIVE; |
370 | bg_flags |= BG_IS_SIZE_SENSITIVE; |
362 | } |
371 | } |
363 | |
372 | |
… | |
… | |
455 | 100, ASIMAGE_QUALITY_DEFAULT); |
464 | 100, ASIMAGE_QUALITY_DEFAULT); |
456 | } |
465 | } |
457 | |
466 | |
458 | if (background == NULL) |
467 | if (background == NULL) |
459 | { |
468 | { |
460 | if (h_scale == 0 || v_scale == 0) |
469 | if (bg_flags & BG_TILE) |
461 | { |
470 | { |
462 | /* if tiling - pixmap has to be sized exactly as the image, |
471 | /* if tiling - pixmap has to be sized exactly as the image, |
463 | but there is no need to make it bigger than the window! */ |
472 | but there is no need to make it bigger than the window! */ |
464 | new_pmap_width = min (result->width, target_width); |
473 | new_pmap_width = min (result->width, target_width); |
465 | new_pmap_height = min (result->height, target_height); |
474 | new_pmap_height = min (result->height, target_height); |
… | |
… | |
490 | layers[0].clip_width = target_width; |
499 | layers[0].clip_width = target_width; |
491 | layers[0].clip_height = target_height; |
500 | layers[0].clip_height = target_height; |
492 | layers[0].tint = background_tint; |
501 | layers[0].tint = background_tint; |
493 | layers[1].im = result; |
502 | layers[1].im = result; |
494 | |
503 | |
495 | if (h_scale == 0 || v_scale == 0) |
504 | if (bg_flags & BG_TILE) |
496 | { |
505 | { |
497 | /* tile horizontally */ |
506 | /* tile horizontally */ |
498 | while (x > 0) x -= (int)result->width; |
507 | while (x > 0) x -= (int)result->width; |
499 | layers[1].dst_x = x; |
508 | layers[1].dst_x = x; |
500 | layers[1].clip_width = result->width+target_width; |
509 | layers[1].clip_width = result->width+target_width; |
… | |
… | |
504 | /* clip horizontally */ |
513 | /* clip horizontally */ |
505 | layers[1].dst_x = x; |
514 | layers[1].dst_x = x; |
506 | layers[1].clip_width = result->width; |
515 | layers[1].clip_width = result->width; |
507 | } |
516 | } |
508 | |
517 | |
509 | if (h_scale == 0 || v_scale == 0) |
518 | if (bg_flags & BG_TILE) |
510 | { |
519 | { |
511 | while (y > 0) y -= (int)result->height; |
520 | while (y > 0) y -= (int)result->height; |
512 | layers[1].dst_y = y; |
521 | layers[1].dst_y = y; |
513 | layers[1].clip_height = result->height + target_height; |
522 | layers[1].clip_height = result->height + target_height; |
514 | } |
523 | } |
… | |
… | |
564 | |
573 | |
565 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
574 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
566 | int dst_width = result->width, dst_height = result->height; |
575 | int dst_width = result->width, dst_height = result->height; |
567 | if (background == NULL) |
576 | if (background == NULL) |
568 | { |
577 | { |
569 | if (!(h_scale == 0 || v_scale == 0)) |
578 | if (!(bg_flags & BG_TILE)) |
570 | { |
579 | { |
571 | src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); |
580 | src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); |
572 | src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); |
581 | src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); |
573 | } |
582 | } |
574 | |
583 | |
… | |
… | |
620 | else if (depth == 15 || depth == 16) |
629 | else if (depth == 15 || depth == 16) |
621 | bytes_per_pixel = 2; |
630 | bytes_per_pixel = 2; |
622 | else |
631 | else |
623 | return false; |
632 | return false; |
624 | |
633 | |
625 | width_r = rxvt_popcount (visual->red_mask); |
634 | width_r = ecb_popcount32 (visual->red_mask); |
626 | width_g = rxvt_popcount (visual->green_mask); |
635 | width_g = ecb_popcount32 (visual->green_mask); |
627 | width_b = rxvt_popcount (visual->blue_mask); |
636 | width_b = ecb_popcount32 (visual->blue_mask); |
628 | |
637 | |
629 | if (width_r > 8 || width_g > 8 || width_b > 8) |
638 | if (width_r > 8 || width_g > 8 || width_b > 8) |
630 | return false; |
639 | return false; |
631 | |
640 | |
632 | sh_r = rxvt_ctz (visual->red_mask); |
641 | sh_r = ecb_ctz32 (visual->red_mask); |
633 | sh_g = rxvt_ctz (visual->green_mask); |
642 | sh_g = ecb_ctz32 (visual->green_mask); |
634 | sh_b = rxvt_ctz (visual->blue_mask); |
643 | sh_b = ecb_ctz32 (visual->blue_mask); |
635 | |
644 | |
636 | if (width > INT_MAX / height / bytes_per_pixel) |
645 | if (width > INT_MAX / height / bytes_per_pixel) |
637 | return false; |
646 | return false; |
638 | |
647 | |
639 | data = (char *)malloc (width * height * bytes_per_pixel); |
648 | data = (char *)malloc (width * height * bytes_per_pixel); |
… | |
… | |
646 | { |
655 | { |
647 | free (data); |
656 | free (data); |
648 | return false; |
657 | return false; |
649 | } |
658 | } |
650 | |
659 | |
651 | ximage->byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; |
660 | ximage->byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
652 | |
661 | |
653 | rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
662 | rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
654 | channels = gdk_pixbuf_get_n_channels (pixbuf); |
663 | channels = gdk_pixbuf_get_n_channels (pixbuf); |
655 | row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; |
664 | row = gdk_pixbuf_get_pixels (pixbuf) + src_y * rowstride + src_x * channels; |
656 | line = data; |
665 | line = data; |
… | |
… | |
723 | result = gdk_pixbuf_scale_simple (pixbuf, |
732 | result = gdk_pixbuf_scale_simple (pixbuf, |
724 | w, h, |
733 | w, h, |
725 | GDK_INTERP_BILINEAR); |
734 | GDK_INTERP_BILINEAR); |
726 | } |
735 | } |
727 | |
736 | |
|
|
737 | if (!result) |
|
|
738 | return false; |
|
|
739 | |
728 | bool ret = false; |
740 | bool ret = false; |
729 | |
741 | |
730 | if (result) |
|
|
731 | { |
|
|
732 | XGCValues gcv; |
742 | XGCValues gcv; |
733 | GC gc; |
743 | GC gc; |
734 | Pixmap root_pmap; |
744 | Pixmap root_pmap; |
735 | |
745 | |
736 | image_width = gdk_pixbuf_get_width (result); |
746 | image_width = gdk_pixbuf_get_width (result); |
737 | image_height = gdk_pixbuf_get_height (result); |
747 | image_height = gdk_pixbuf_get_height (result); |
738 | |
748 | |
739 | if (tr_flags) |
749 | if (tr_flags) |
740 | { |
750 | { |
741 | root_pmap = bg_pixmap; |
751 | root_pmap = bg_pixmap; |
742 | bg_pixmap = None; |
752 | bg_pixmap = None; |
|
|
753 | } |
|
|
754 | else |
|
|
755 | { |
|
|
756 | if (bg_flags & BG_TILE) |
743 | } |
757 | { |
744 | else |
|
|
745 | { |
|
|
746 | if (h_scale == 0 || v_scale == 0) |
|
|
747 | { |
|
|
748 | new_pmap_width = min (image_width, target_width); |
758 | new_pmap_width = min (image_width, target_width); |
749 | new_pmap_height = min (image_height, target_height); |
759 | new_pmap_height = min (image_height, target_height); |
750 | } |
760 | } |
751 | } |
761 | } |
752 | |
762 | |
753 | if (bg_pixmap == None |
763 | if (bg_pixmap == None |
754 | || bg_pmap_width != new_pmap_width |
764 | || bg_pmap_width != new_pmap_width |
755 | || bg_pmap_height != new_pmap_height) |
765 | || bg_pmap_height != new_pmap_height) |
756 | { |
766 | { |
757 | if (bg_pixmap) |
767 | if (bg_pixmap) |
758 | XFreePixmap (dpy, bg_pixmap); |
768 | XFreePixmap (dpy, bg_pixmap); |
759 | bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); |
769 | bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); |
760 | bg_pmap_width = new_pmap_width; |
770 | bg_pmap_width = new_pmap_width; |
761 | bg_pmap_height = new_pmap_height; |
771 | bg_pmap_height = new_pmap_height; |
762 | } |
772 | } |
763 | |
773 | |
764 | gcv.foreground = pix_colors[Color_bg]; |
774 | gcv.foreground = pix_colors[Color_bg]; |
765 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
775 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
766 | |
776 | |
767 | if (h_scale == 0 || v_scale == 0) |
777 | if (gc) |
|
|
778 | { |
|
|
779 | if (bg_flags & BG_TILE) |
768 | { |
780 | { |
769 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
781 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
770 | pixbuf_to_pixmap (result, tile, gc, |
782 | pixbuf_to_pixmap (result, tile, gc, |
771 | 0, 0, |
783 | 0, 0, |
772 | 0, 0, |
784 | 0, 0, |
… | |
… | |
816 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
828 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
817 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
829 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
818 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
830 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
819 | XFreePixmap (dpy, mask_pmap); |
831 | XFreePixmap (dpy, mask_pmap); |
820 | |
832 | |
821 | if (src && dst && mask) |
|
|
822 | { |
|
|
823 | XRenderColor mask_c; |
833 | XRenderColor mask_c; |
824 | |
834 | |
825 | mask_c.alpha = 0x8000; |
835 | mask_c.alpha = 0x8000; |
826 | mask_c.red = 0; |
836 | mask_c.red = 0; |
827 | mask_c.green = 0; |
837 | mask_c.green = 0; |
828 | mask_c.blue = 0; |
838 | mask_c.blue = 0; |
829 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
839 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
830 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
840 | XRenderComposite (dpy, PictOpOver, src, mask, dst, 0, 0, 0, 0, 0, 0, target_width, target_height); |
831 | } |
|
|
832 | |
841 | |
833 | XRenderFreePicture (dpy, src); |
842 | XRenderFreePicture (dpy, src); |
834 | XRenderFreePicture (dpy, dst); |
843 | XRenderFreePicture (dpy, dst); |
835 | XRenderFreePicture (dpy, mask); |
844 | XRenderFreePicture (dpy, mask); |
836 | |
|
|
837 | XFreePixmap (dpy, root_pmap); |
|
|
838 | } |
845 | } |
839 | #endif |
846 | #endif |
840 | |
847 | |
841 | if (result != pixbuf) |
|
|
842 | g_object_unref (result); |
|
|
843 | |
|
|
844 | XFreeGC (dpy, gc); |
848 | XFreeGC (dpy, gc); |
845 | |
849 | |
846 | ret = true; |
850 | ret = true; |
847 | } |
851 | } |
|
|
852 | |
|
|
853 | if (result != pixbuf) |
|
|
854 | g_object_unref (result); |
|
|
855 | |
|
|
856 | if (tr_flags) |
|
|
857 | XFreePixmap (dpy, root_pmap); |
848 | |
858 | |
849 | return ret; |
859 | return ret; |
850 | } |
860 | } |
851 | # endif /* HAVE_PIXBUF */ |
861 | # endif /* HAVE_PIXBUF */ |
852 | |
862 | |
… | |
… | |
1036 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1046 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1037 | |
1047 | |
1038 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1048 | Picture src = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1039 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1049 | Picture dst = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1040 | |
1050 | |
1041 | if (kernel && params && src && dst) |
1051 | if (kernel && params) |
1042 | { |
1052 | { |
1043 | if (h_blurRadius) |
1053 | if (h_blurRadius) |
1044 | { |
1054 | { |
1045 | size = h_blurRadius * 2 + 1; |
1055 | size = h_blurRadius * 2 + 1; |
1046 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
1056 | get_gaussian_kernel (h_blurRadius, size, kernel, params); |
… | |
… | |
1111 | } |
1121 | } |
1112 | } |
1122 | } |
1113 | else |
1123 | else |
1114 | { |
1124 | { |
1115 | # if XRENDER |
1125 | # if XRENDER |
1116 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1126 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1117 | |
1127 | |
1118 | if (bg_flags & BG_TINT_SET) |
1128 | if (bg_flags & BG_TINT_SET) |
1119 | tint.get (c); |
1129 | tint.get (c); |
1120 | |
1130 | |
1121 | if (shade <= 100) |
1131 | if (shade <= 100) |
1122 | { |
1132 | { |
1123 | c.r = (c.r * shade) / 100; |
1133 | c.r = c.r * shade / 100; |
1124 | c.g = (c.g * shade) / 100; |
1134 | c.g = c.g * shade / 100; |
1125 | c.b = (c.b * shade) / 100; |
1135 | c.b = c.b * shade / 100; |
1126 | } |
1136 | } |
1127 | else |
1137 | else |
1128 | { |
1138 | { |
1129 | c.r = (c.r * (200 - shade)) / 100; |
1139 | c.r = c.r * (200 - shade) / 100; |
1130 | c.g = (c.g * (200 - shade)) / 100; |
1140 | c.g = c.g * (200 - shade) / 100; |
1131 | c.b = (c.b * (200 - shade)) / 100; |
1141 | c.b = c.b * (200 - shade) / 100; |
1132 | } |
1142 | } |
1133 | |
1143 | |
1134 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
1144 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
1135 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1145 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1136 | XRenderPictureAttributes pa; |
1146 | XRenderPictureAttributes pa; |
… | |
… | |
1143 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
1153 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
1144 | XFreePixmap (dpy, overlay_pmap); |
1154 | XFreePixmap (dpy, overlay_pmap); |
1145 | |
1155 | |
1146 | pa.component_alpha = True; |
1156 | pa.component_alpha = True; |
1147 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1157 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1148 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
1158 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa); |
1149 | XFreePixmap (dpy, mask_pmap); |
1159 | XFreePixmap (dpy, mask_pmap); |
1150 | |
1160 | |
1151 | if (mask_pic && overlay_pic && back_pic) |
|
|
1152 | { |
|
|
1153 | XRenderColor mask_c; |
1161 | XRenderColor mask_c; |
1154 | |
1162 | |
1155 | mask_c.red = mask_c.green = mask_c.blue = 0; |
|
|
1156 | mask_c.alpha = 0xffff; |
1163 | mask_c.alpha = 0xffff; |
|
|
1164 | mask_c.red = |
|
|
1165 | mask_c.green = |
|
|
1166 | mask_c.blue = 0; |
|
|
1167 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1168 | |
|
|
1169 | mask_c.alpha = 0; |
|
|
1170 | mask_c.red = 0xffff - c.r; |
|
|
1171 | mask_c.green = 0xffff - c.g; |
|
|
1172 | mask_c.blue = 0xffff - c.b; |
|
|
1173 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1174 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
|
|
1175 | |
|
|
1176 | if (shade > 100) |
|
|
1177 | { |
|
|
1178 | mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; |
|
|
1179 | mask_c.alpha = 0; |
1157 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1180 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1158 | |
1181 | |
1159 | mask_c.alpha = 0; |
|
|
1160 | mask_c.red = 0xffff - c.r; |
|
|
1161 | mask_c.green = 0xffff - c.g; |
|
|
1162 | mask_c.blue = 0xffff - c.b; |
|
|
1163 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
1164 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
|
|
1165 | |
|
|
1166 | if (shade > 100) |
|
|
1167 | { |
|
|
1168 | mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; |
|
|
1169 | mask_c.alpha = 0; |
|
|
1170 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1171 | |
|
|
1172 | XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1182 | XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1173 | } |
1183 | } |
1174 | |
1184 | |
1175 | ret = true; |
1185 | ret = true; |
1176 | } |
|
|
1177 | |
1186 | |
1178 | XRenderFreePicture (dpy, mask_pic); |
1187 | XRenderFreePicture (dpy, mask_pic); |
1179 | XRenderFreePicture (dpy, overlay_pic); |
1188 | XRenderFreePicture (dpy, overlay_pic); |
1180 | XRenderFreePicture (dpy, back_pic); |
1189 | XRenderFreePicture (dpy, back_pic); |
1181 | # endif |
1190 | # endif |
1182 | } |
1191 | } |
1183 | |
1192 | |
1184 | return ret; |
1193 | return ret; |
1185 | } |
1194 | } |
1186 | |
1195 | |
1187 | /* make_transparency_pixmap() |
1196 | /* |
1188 | * Builds a pixmap of the same size as the terminal window that contains |
1197 | * Builds a pixmap of the same size as the terminal window that contains |
1189 | * the tiled portion of the root pixmap that is supposed to be covered by |
1198 | * the tiled portion of the root pixmap that is supposed to be covered by |
1190 | * our window. |
1199 | * our window. |
1191 | */ |
1200 | */ |
1192 | unsigned long |
1201 | unsigned long |
… | |
… | |
1236 | if (root_pixmap != None && root_depth != depth) |
1245 | if (root_pixmap != None && root_depth != depth) |
1237 | { |
1246 | { |
1238 | #if XRENDER |
1247 | #if XRENDER |
1239 | if (bg_flags & BG_HAS_RENDER) |
1248 | if (bg_flags & BG_HAS_RENDER) |
1240 | { |
1249 | { |
|
|
1250 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
|
|
1251 | |
1241 | XRenderPictureAttributes pa; |
1252 | XRenderPictureAttributes pa; |
1242 | |
1253 | |
1243 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1254 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1244 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1255 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, &pa); |
1245 | |
1256 | |
1246 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
|
|
1247 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1257 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
1248 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1258 | Picture dst = XRenderCreatePicture (dpy, recoded_root_pmap, dst_format, 0, &pa); |
1249 | |
1259 | |
1250 | if (src && dst) |
|
|
1251 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1260 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, root_pmap_width, root_pmap_height); |
1252 | else |
|
|
1253 | { |
|
|
1254 | XFreePixmap (dpy, recoded_root_pmap); |
|
|
1255 | root_pixmap = None; |
|
|
1256 | } |
|
|
1257 | |
1261 | |
1258 | XRenderFreePicture (dpy, src); |
1262 | XRenderFreePicture (dpy, src); |
1259 | XRenderFreePicture (dpy, dst); |
1263 | XRenderFreePicture (dpy, dst); |
1260 | } |
1264 | } |
1261 | else |
1265 | else |
1262 | #endif |
1266 | #endif |
1263 | root_pixmap = None; |
1267 | recoded_root_pmap = None; |
1264 | } |
1268 | } |
1265 | |
1269 | |
1266 | if (root_pixmap == None) |
1270 | if (recoded_root_pmap == None) |
1267 | return 0; |
1271 | return 0; |
1268 | |
1272 | |
1269 | if (bg_pixmap == None |
1273 | if (bg_pixmap == None |
1270 | || bg_pmap_width != window_width |
1274 | || bg_pmap_width != window_width |
1271 | || bg_pmap_height != window_height) |
1275 | || bg_pmap_height != window_height) |
… | |
… | |
1275 | bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); |
1279 | bg_pixmap = XCreatePixmap (dpy, vt, window_width, window_height, depth); |
1276 | bg_pmap_width = window_width; |
1280 | bg_pmap_width = window_width; |
1277 | bg_pmap_height = window_height; |
1281 | bg_pmap_height = window_height; |
1278 | } |
1282 | } |
1279 | |
1283 | |
1280 | if (bg_pixmap == None) |
|
|
1281 | return 0; |
|
|
1282 | |
|
|
1283 | /* straightforward pixmap copy */ |
1284 | /* straightforward pixmap copy */ |
1284 | while (sx < 0) sx += (int)root_width; |
1285 | while (sx < 0) sx += root_width; |
1285 | while (sy < 0) sy += (int)root_height; |
1286 | while (sy < 0) sy += root_height; |
1286 | |
1287 | |
1287 | gcv.tile = recoded_root_pmap; |
1288 | gcv.tile = recoded_root_pmap; |
1288 | gcv.fill_style = FillTiled; |
1289 | gcv.fill_style = FillTiled; |
1289 | gcv.ts_x_origin = -sx; |
1290 | gcv.ts_x_origin = -sx; |
1290 | gcv.ts_y_origin = -sy; |
1291 | gcv.ts_y_origin = -sy; |
… | |
… | |
1447 | uint32_t mask_r, mask_g, mask_b; |
1448 | uint32_t mask_r, mask_g, mask_b; |
1448 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1449 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1449 | rgba low; |
1450 | rgba low; |
1450 | rgba high; |
1451 | rgba high; |
1451 | int i; |
1452 | int i; |
1452 | int host_byte_order = byteorder::big_endian () ? MSBFirst : LSBFirst; |
1453 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1453 | |
1454 | |
1454 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1455 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1455 | |
1456 | |
1456 | /* for convenience */ |
1457 | /* for convenience */ |
1457 | mask_r = visual->red_mask; |
1458 | mask_r = visual->red_mask; |