… | |
… | |
25 | |
25 | |
26 | #include "../config.h" /* NECESSARY */ |
26 | #include "../config.h" /* NECESSARY */ |
27 | #include "rxvt.h" /* NECESSARY */ |
27 | #include "rxvt.h" /* NECESSARY */ |
28 | |
28 | |
29 | #ifdef XPM_BACKGROUND |
29 | #ifdef XPM_BACKGROUND |
30 | |
|
|
31 | /* |
|
|
32 | * Calculate tiling sizes and increments |
|
|
33 | * At start, p == 0, incr == xpmwidthheight |
|
|
34 | */ |
|
|
35 | static void |
|
|
36 | rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight) |
|
|
37 | { |
|
|
38 | unsigned int cwh, cxy; |
|
|
39 | float cincr, cp; |
|
|
40 | |
|
|
41 | cp = 0; |
|
|
42 | cincr = (float)xpmwidthheight; |
|
|
43 | cxy = *xy; |
|
|
44 | cwh = *wh; |
|
|
45 | if (cwh == 1) |
|
|
46 | { /* display one image, no horizontal/vertical scaling */ |
|
|
47 | cincr = (float)widthheight; |
|
|
48 | if (xpmwidthheight <= widthheight) |
|
|
49 | { |
|
|
50 | cwh = xpmwidthheight; |
|
|
51 | cxy = (cxy * (widthheight - cwh)) / 100; /* beware! order */ |
|
|
52 | cwh += cxy; |
|
|
53 | } |
|
|
54 | else |
|
|
55 | { |
|
|
56 | cxy = 0; |
|
|
57 | cwh = widthheight; |
|
|
58 | } |
|
|
59 | } |
|
|
60 | else if (cwh < 10) |
|
|
61 | { /* fit WH images across/down screen */ |
|
|
62 | cincr *= cwh; |
|
|
63 | cxy = 0; |
|
|
64 | cwh = widthheight; |
|
|
65 | } |
|
|
66 | else |
|
|
67 | { |
|
|
68 | cincr *= 100.0 / cwh; |
|
|
69 | if (cwh < 100) |
|
|
70 | { /* contract */ |
|
|
71 | float pos; |
|
|
72 | |
|
|
73 | cwh = (cwh * widthheight) / 100; |
|
|
74 | pos = (float)cxy / 100 * widthheight - (cwh / 2); |
|
|
75 | |
|
|
76 | cxy = (widthheight - cwh); |
|
|
77 | if (pos <= 0) |
|
|
78 | cxy = 0; |
|
|
79 | else if (pos < cxy) |
|
|
80 | cxy = (int) pos; |
|
|
81 | cwh += cxy; |
|
|
82 | } |
|
|
83 | else |
|
|
84 | { /* expand */ |
|
|
85 | if (cxy > 0) |
|
|
86 | { /* position */ |
|
|
87 | float pos; |
|
|
88 | |
|
|
89 | pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2); |
|
|
90 | cp = xpmwidthheight - cincr; |
|
|
91 | if (pos <= 0) |
|
|
92 | cp = 0; |
|
|
93 | else if (pos < cp) |
|
|
94 | cp = pos; |
|
|
95 | } |
|
|
96 | cxy = 0; |
|
|
97 | cwh = widthheight; |
|
|
98 | } |
|
|
99 | } |
|
|
100 | cincr /= widthheight; |
|
|
101 | *wh = cwh; |
|
|
102 | *xy = cxy; |
|
|
103 | *incr = cincr; |
|
|
104 | *p = cp; |
|
|
105 | } |
|
|
106 | |
30 | |
107 | /* |
31 | /* |
108 | * These GEOM strings indicate absolute size/position: |
32 | * These GEOM strings indicate absolute size/position: |
109 | * @ `WxH+X+Y' |
33 | * @ `WxH+X+Y' |
110 | * @ `WxH+X' -> Y = X |
34 | * @ `WxH+X' -> Y = X |
… | |
… | |
157 | if (n < MAXLEN_GEOM) |
81 | if (n < MAXLEN_GEOM) |
158 | { |
82 | { |
159 | strncpy (str, geom, n); |
83 | strncpy (str, geom, n); |
160 | str[n] = '\0'; |
84 | str[n] = '\0'; |
161 | |
85 | |
162 | if (strcmp(str, "auto") == 0) |
86 | if (strcmp(str, "auto") == 0) |
163 | { |
87 | { |
164 | if (!bgpixmap->auto_resize) |
88 | if (!bgpixmap->auto_resize) |
165 | changed++; |
89 | changed++; |
166 | bgpixmap->auto_resize = True ; |
90 | bgpixmap->auto_resize = True ; |
167 | w = szHint.width ; |
91 | w = szHint.width ; |
168 | h = szHint.height ; |
92 | h = szHint.height ; |
169 | flags = WidthValue|HeightValue ; |
93 | flags = WidthValue|HeightValue ; |
170 | } |
94 | } |
171 | else |
95 | else |
172 | { |
96 | { |
173 | bgpixmap->auto_resize = False ; |
97 | bgpixmap->auto_resize = False ; |
174 | flags = XParseGeometry (str, &x, &y, &w, &h); |
98 | flags = XParseGeometry (str, &x, &y, &w, &h); |
175 | } |
99 | } |
176 | |
100 | |
177 | if (!flags) |
101 | if (!flags) |
178 | { |
102 | { |
… | |
… | |
283 | unsigned int w = bgPixmap.w, h = bgPixmap.h, |
207 | unsigned int w = bgPixmap.w, h = bgPixmap.h, |
284 | x = bgPixmap.x, y = bgPixmap.y; |
208 | x = bgPixmap.x, y = bgPixmap.y; |
285 | unsigned int xpmh = xpmAttr.height, |
209 | unsigned int xpmh = xpmAttr.height, |
286 | xpmw = xpmAttr.width; |
210 | xpmw = xpmAttr.width; |
287 | |
211 | |
288 | if (bgPixmap.auto_resize) |
212 | if (bgPixmap.auto_resize) |
289 | { |
213 | { |
290 | w = szHint.width ; |
214 | w = szHint.width ; |
291 | h = szHint.height ; |
215 | h = szHint.height ; |
292 | } |
216 | } |
293 | /* |
217 | /* |
294 | * don't zoom pixmap too much nor expand really small pixmaps |
218 | * don't zoom pixmap too much nor expand really small pixmaps |
295 | */ |
219 | */ |
296 | if (w > 32767 || h > 32767) |
220 | if (w > 32767 || h > 32767) |
297 | w = 1; |
221 | w = 1; |
… | |
… | |
308 | XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y); |
232 | XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y); |
309 | XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0); |
233 | XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0); |
310 | XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y); |
234 | XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y); |
311 | } |
235 | } |
312 | else |
236 | else |
313 | #ifdef HAVE_AFTERIMAGE |
|
|
314 | #ifdef ENABLE_TRANSPARENCY |
237 | #ifdef ENABLE_TRANSPARENCY |
315 | if (!option(Opt_transparent) || !am_transparent) |
238 | if (!option(Opt_transparent) || !am_transparent) |
316 | /* will do that in check_our_parents otherwise */ |
239 | /* will do that in check_our_parents otherwise */ |
317 | #endif |
240 | #endif |
318 | { |
241 | { |
319 | ASImage *scaled_im = scale_asimage( display->asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT ); |
242 | ASImage *scaled_im = scale_asimage (asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
320 | if (scaled_im) |
243 | if (scaled_im) |
321 | { |
244 | { |
322 | pixmap = asimage2pixmap( display->asv, display->root, scaled_im, gc, True ); |
245 | pixmap = asimage2pixmap(asv, display->root, scaled_im, gc, True); |
323 | destroy_asimage( &scaled_im ); |
246 | destroy_asimage (&scaled_im); |
324 | } |
247 | } |
325 | } |
248 | } |
326 | #else /* HAVE_AFTERIMAGE */ |
|
|
327 | { |
|
|
328 | float incr, p; |
|
|
329 | Pixmap tmp; |
|
|
330 | |
|
|
331 | pixmap = XCreatePixmap (dpy, vt, width, height, depth); |
|
|
332 | /* |
|
|
333 | * horizontal scaling |
|
|
334 | */ |
|
|
335 | rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); |
|
|
336 | |
|
|
337 | tmp = XCreatePixmap (dpy, vt, width, xpmh, depth); |
|
|
338 | XFillRectangle (dpy, tmp, gc, 0, 0, width, xpmh); |
|
|
339 | |
|
|
340 | for ( /*nil */ ; x < w; x++, p += incr) |
|
|
341 | { |
|
|
342 | if (p >= xpmw) |
|
|
343 | p = 0; |
|
|
344 | |
|
|
345 | /* copy one column from the original pixmap to the tmp pixmap */ |
|
|
346 | XCopyArea (dpy, bgPixmap.pixmap, tmp, gc, (int)p, 0, 1, xpmh, (int)x, 0); |
|
|
347 | } |
|
|
348 | |
|
|
349 | /* |
|
|
350 | * vertical scaling |
|
|
351 | */ |
|
|
352 | rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); |
|
|
353 | |
|
|
354 | if (y > 0) |
|
|
355 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, y); |
|
|
356 | |
|
|
357 | if (h < height) |
|
|
358 | XFillRectangle (dpy, pixmap, gc, 0, (int)h, width, height - h + 1); |
|
|
359 | |
|
|
360 | for ( /*nil */ ; y < h; y++, p += incr) |
|
|
361 | { |
|
|
362 | if (p >= xpmh) |
|
|
363 | p = 0; |
|
|
364 | |
|
|
365 | /* copy one row from the tmp pixmap to the main pixmap */ |
|
|
366 | XCopyArea (dpy, tmp, pixmap, gc, 0, (int)p, width, 1, 0, (int)y); |
|
|
367 | } |
|
|
368 | |
|
|
369 | XFreePixmap (dpy, tmp); |
|
|
370 | } |
|
|
371 | #endif /* HAVE_AFTERIMAGE */ |
|
|
372 | } |
249 | } |
373 | |
250 | |
374 | XSetWindowBackgroundPixmap (dpy, vt, pixmap); |
251 | XSetWindowBackgroundPixmap (dpy, vt, pixmap); |
375 | |
252 | |
376 | XFreeGC (dpy, gc); |
253 | XFreeGC (dpy, gc); |
… | |
… | |
401 | /* |
278 | /* |
402 | * we already have the required attributes |
279 | * we already have the required attributes |
403 | */ |
280 | */ |
404 | /* XGetWindowAttributes (dpy, vt, &attr); */ |
281 | /* XGetWindowAttributes (dpy, vt, &attr); */ |
405 | |
282 | |
406 | #ifdef HAVE_AFTERIMAGE |
|
|
407 | if (asimman == NULL) |
283 | if (asimman == NULL) |
408 | asimman = create_generic_imageman(rs[Rs_path]); |
284 | asimman = create_generic_imageman(rs[Rs_path]); |
409 | if ((f = strchr (file, ';')) == NULL) |
285 | if ((f = strchr (file, ';')) == NULL) |
410 | original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 ); |
286 | original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 ); |
411 | else |
287 | else |
412 | { |
288 | { |
413 | size_t len = f - file; |
289 | size_t len = f - file; |
414 | f = (char *)malloc (len + 1); |
290 | f = (char *)malloc (len + 1); |
415 | strncpy (f, file, len); |
291 | strncpy (f, file, len); |
416 | f[len] = '\0'; |
292 | f[len] = '\0'; |
417 | original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); |
293 | original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); |
418 | free( f ); |
294 | free( f ); |
419 | } |
295 | } |
420 | if (original_asim) |
296 | if (original_asim) |
421 | { |
297 | { |
422 | bgPixmap.pixmap = asimage2pixmap( display->asv, display->root, original_asim, NULL, True ); |
298 | bgPixmap.pixmap = asimage2pixmap (asv, display->root, original_asim, NULL, True); |
423 | xpmAttr.width = original_asim->width ; |
299 | xpmAttr.width = original_asim->width ; |
424 | xpmAttr.height = original_asim->height ; |
300 | xpmAttr.height = original_asim->height ; |
425 | } |
|
|
426 | #else /* HAVE_AFTERIMAGE */ |
|
|
427 | xpmAttr.closeness = 30000; |
|
|
428 | xpmAttr.colormap = cmap; |
|
|
429 | xpmAttr.visual = visual; |
|
|
430 | xpmAttr.depth = depth; |
|
|
431 | xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual |
|
|
432 | | XpmDepth | XpmSize | XpmReturnPixels); |
|
|
433 | |
|
|
434 | /* search environment variables here too */ |
|
|
435 | f = (char *)rxvt_File_find (file, ".xpm", rs[Rs_path]); |
|
|
436 | if (f == NULL |
|
|
437 | || XpmReadFileToPixmap (dpy, display->root, f, |
|
|
438 | &bgPixmap.pixmap, NULL, |
|
|
439 | &xpmAttr)) |
|
|
440 | { |
301 | } |
441 | char *p; |
|
|
442 | |
|
|
443 | /* semi-colon delimited */ |
|
|
444 | if ((p = strchr (file, ';')) == NULL) |
|
|
445 | p = strchr (file, '\0'); |
|
|
446 | |
|
|
447 | rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.\n", (p - file), file); |
|
|
448 | } |
|
|
449 | free (f); |
|
|
450 | #endif /* HAVE_AFTERIMAGE */ |
|
|
451 | } |
302 | } |
452 | |
303 | |
453 | resize_pixmap (); |
304 | resize_pixmap (); |
454 | return bgPixmap.pixmap; |
305 | return bgPixmap.pixmap; |
455 | } |
306 | } |
… | |
… | |
702 | } |
553 | } |
703 | |
554 | |
704 | void |
555 | void |
705 | rxvt_term::check_our_parents_cb (time_watcher &w) |
556 | rxvt_term::check_our_parents_cb (time_watcher &w) |
706 | { |
557 | { |
707 | int i, pchanged, aformat, have_pixmap, rootdepth; |
558 | int i, pchanged, aformat, rootdepth; |
708 | unsigned long nitems, bytes_after; |
559 | unsigned long nitems, bytes_after; |
709 | Atom atype; |
560 | Atom atype; |
710 | unsigned char *prop = NULL; |
561 | unsigned char *prop = NULL; |
711 | Window root, oldp, *list; |
562 | Window root, oldp, *list; |
712 | Pixmap rootpixmap = None; |
563 | Pixmap rootpixmap = None; |
713 | XWindowAttributes wattr, wrootattr; |
564 | XWindowAttributes wattr, wrootattr; |
714 | int sx, sy; |
565 | int sx, sy; |
715 | Window cr; |
566 | Window cr; |
|
|
567 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
716 | |
568 | |
717 | pchanged = 0; |
569 | pchanged = 0; |
718 | |
570 | |
719 | if (!option (Opt_transparent)) |
571 | if (!option (Opt_transparent)) |
720 | return /*pchanged*/; /* Don't try any more */ |
572 | return /*pchanged*/; /* Don't try any more */ |
|
|
573 | |
|
|
574 | #if 0 |
|
|
575 | struct timeval stv; |
|
|
576 | gettimeofday (&stv,NULL); |
|
|
577 | #define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
|
|
578 | fprintf (stderr,"%d: elapsed %ld usec\n",__LINE__,\ |
|
|
579 | tv.tv_sec*1000000+tv.tv_usec-stv.tv_usec );}while(0) |
|
|
580 | #else |
|
|
581 | #define PRINT_BACKGROUND_OP_TIME do{}while(0) |
|
|
582 | #endif |
|
|
583 | |
721 | |
584 | |
722 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
585 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
723 | rootdepth = wrootattr.depth; |
586 | rootdepth = wrootattr.depth; |
724 | |
587 | |
725 | XGetWindowAttributes (dpy, parent[0], &wattr); |
588 | XGetWindowAttributes (dpy, parent[0], &wattr); |
… | |
… | |
739 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
602 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
740 | XSync (dpy, False); |
603 | XSync (dpy, False); |
741 | |
604 | |
742 | XTranslateCoordinates (dpy, parent[0], display->root, |
605 | XTranslateCoordinates (dpy, parent[0], display->root, |
743 | 0, 0, &sx, &sy, &cr); |
606 | 0, 0, &sx, &sy, &cr); |
744 | |
|
|
745 | /* check if we are outside of the visible part of the virtual screen : */ |
607 | /* check if we are outside of the visible part of the virtual screen : */ |
746 | if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0 |
608 | if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0 |
747 | || sx >= wrootattr.width || sy >= wrootattr.height ) |
609 | || sx >= wrootattr.width || sy >= wrootattr.height ) |
748 | return /* 0 */ ; |
610 | return /* 0 */ ; |
749 | /* |
611 | /* |
750 | * Make the frame window set by the window manager have |
612 | * Make the frame window set by the window manager have |
751 | * the root background. Some window managers put multiple nested frame |
613 | * the root background. Some window managers put multiple nested frame |
752 | * windows for each client, so we have to take care about that. |
614 | * windows for each client, so we have to take care about that. |
… | |
… | |
760 | i = (xa[XA_ESETROOT_PMAP_ID] |
622 | i = (xa[XA_ESETROOT_PMAP_ID] |
761 | && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
623 | && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
762 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
624 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
763 | &nitems, &bytes_after, &prop) == Success); |
625 | &nitems, &bytes_after, &prop) == Success); |
764 | |
626 | |
|
|
627 | /* TODO: the below logic needs to be cleaned up */ |
765 | if (!i || prop == NULL |
628 | if (!i || prop == NULL |
766 | #if TINTING |
629 | #if TINTING |
767 | || (!ISSET_PIXCOLOR (Color_tint) && rs[Rs_shade] == NULL |
630 | || (!ISSET_PIXCOLOR (Color_tint) && rs[Rs_shade] == NULL |
768 | #ifdef HAVE_AFTERIMAGE |
631 | #ifdef HAVE_AFTERIMAGE |
769 | && original_asim == NULL && rs[Rs_blurradius] == NULL |
632 | && original_asim == NULL && rs[Rs_blurradius] == NULL |
770 | #endif |
633 | #endif |
771 | ) |
634 | ) |
772 | #endif |
635 | #endif |
773 | ) |
636 | ) |
774 | have_pixmap = 0; |
637 | rootpixmap = None; |
775 | else |
638 | else |
776 | { |
639 | { |
777 | have_pixmap = 1; |
640 | int junk; |
|
|
641 | unsigned int ujunk; |
|
|
642 | /* root pixmap may be bad - allow a error */ |
|
|
643 | allowedxerror = -1; |
778 | rootpixmap = *(Pixmap *)prop; |
644 | if ((rootpixmap = *(Pixmap *)prop) != None) |
|
|
645 | if (!XGetGeometry (dpy, rootpixmap, &root, &junk, &junk, &rootpixmap_w, &rootpixmap_h, &ujunk, &ujunk)) |
|
|
646 | rootpixmap = None; |
|
|
647 | allowedxerror = 0; |
|
|
648 | } |
|
|
649 | |
|
|
650 | if (prop != NULL) |
779 | XFree (prop); |
651 | XFree (prop); |
|
|
652 | |
|
|
653 | if (rootpixmap != None) |
780 | } |
654 | { |
781 | |
|
|
782 | if (have_pixmap) |
|
|
783 | { |
|
|
784 | Bool success = False ; |
655 | Bool success = False; |
785 | GC gc = NULL; |
656 | GC gc = NULL; |
786 | XGCValues gcvalue; |
657 | XGCValues gcvalue; |
|
|
658 | int shade = 100; |
|
|
659 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
660 | Bool whole_tint = False, no_tint = True; |
|
|
661 | |
|
|
662 | while (sx < 0) sx += (int)wrootattr.width; |
|
|
663 | while (sy < 0) sy += (int)wrootattr.height; |
|
|
664 | |
|
|
665 | #if TINTING |
|
|
666 | if (rs[Rs_shade]) |
|
|
667 | shade = atoi (rs[Rs_shade]); |
|
|
668 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
669 | pix_colors_focused [Color_tint].get (c); |
|
|
670 | #define IS_COMPONENT_WHOLESOME(c) ((c) <=0x000700 || (c)>=0x00f700) |
|
|
671 | if (shade >= 100) |
|
|
672 | whole_tint = (IS_COMPONENT_WHOLESOME(c.r) |
|
|
673 | && IS_COMPONENT_WHOLESOME(c.g) |
|
|
674 | && IS_COMPONENT_WHOLESOME(c.b)); |
|
|
675 | no_tint = (c.r >= 0x00f700 && c.g >= 0x00f700 && c.b >= 0x00f700); |
|
|
676 | #undef IS_COMPONENT_WHOLESOME |
|
|
677 | #endif /* TINTING */ |
|
|
678 | /* theer are no performance advantages to reusing same pixmap */ |
|
|
679 | if (pixmap != None) |
|
|
680 | XFreePixmap (dpy, pixmap); |
|
|
681 | pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, rootdepth); |
|
|
682 | |
|
|
683 | #if 0 /* TODO : identify cases where this will be detrimental to performance : */ |
|
|
684 | /* we want to tile root pixmap into our own pixmap in this cases : |
|
|
685 | * 1) rootpixmap does not cover our window entirely |
|
|
686 | * 2) whole_tint - we can use server-side tinting or tinting disabled |
|
|
687 | */ |
|
|
688 | if ( whole_tint || no_tint || pmap_w < sx + szHint.width || pmap_h < sy + szHint.height) |
|
|
689 | { |
|
|
690 | } |
|
|
691 | #endif |
|
|
692 | gcvalue.tile = rootpixmap; |
|
|
693 | gcvalue.fill_style = FillTiled; |
|
|
694 | gcvalue.ts_x_origin = -sx; |
|
|
695 | gcvalue.ts_y_origin = -sy; |
|
|
696 | gc = XCreateGC (dpy, rootpixmap, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcvalue); |
|
|
697 | XFillRectangle (dpy, pixmap, gc, 0, 0, szHint.width, szHint.height); |
|
|
698 | |
|
|
699 | #if TINTING |
|
|
700 | if (whole_tint && !no_tint) |
|
|
701 | { |
|
|
702 | /* In this case we can tint image server-side getting significant |
|
|
703 | * performance improvements, as we eliminate XImage transfer |
|
|
704 | */ |
|
|
705 | gcvalue.foreground = Pixel (pix_colors_focused [Color_tint]); |
|
|
706 | gcvalue.function = GXand; |
|
|
707 | gcvalue.fill_style = FillSolid; |
|
|
708 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcvalue); |
|
|
709 | XFillRectangle (dpy, pixmap, gc, 0, 0, szHint.width, szHint.height); |
|
|
710 | } |
|
|
711 | #endif |
|
|
712 | success = True; |
787 | #ifdef HAVE_AFTERIMAGE |
713 | #ifdef HAVE_AFTERIMAGE |
|
|
714 | if (rs[Rs_blurradius] || original_asim != NULL || (!whole_tint && (!no_tint || shade !=100))) |
788 | { |
715 | { |
789 | Pixmap tmp_pmap = None ; |
716 | ARGB32 tint = TINT_LEAVE_SAME; |
790 | ShadingInfo shade; |
717 | ASImage *back_im = NULL; |
791 | ARGB32 tint ; |
|
|
792 | unsigned int pmap_w = 0, pmap_h = 0; |
|
|
793 | |
718 | |
794 | if (get_drawable_size( rootpixmap, &pmap_w, &pmap_h )) |
719 | back_im = pixmap2ximage (asv, pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, 100); |
|
|
720 | if (back_im != NULL) |
795 | { |
721 | { |
796 | int root_x = 0, root_y = 0; |
722 | if (!whole_tint && (!no_tint || shade !=100)) |
797 | |
|
|
798 | shade.shading = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
799 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
800 | { |
723 | { |
801 | rgba c; |
724 | ShadingInfo as_shade; |
802 | pix_colors_focused [Color_tint].get (c); |
725 | as_shade.shading = shade; |
803 | shade.tintColor.red = c.r; |
726 | as_shade.tintColor.red = c.r; |
804 | shade.tintColor.green = c.g; |
727 | as_shade.tintColor.green = c.g; |
805 | shade.tintColor.blue = c.b; |
728 | as_shade.tintColor.blue = c.b; |
|
|
729 | tint = shading2tint32 (&as_shade); |
806 | } |
730 | } |
807 | else |
731 | |
808 | shade.tintColor.red = shade.tintColor.green = shade.tintColor.blue = 0xFFFF; |
732 | if (rs[Rs_blurradius] && back_im) |
809 | tint = shading2tint32( &shade ); |
|
|
810 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
|
|
811 | if (GetWinPosition (parent[0], &root_x, &root_y) ) |
|
|
812 | { |
733 | { |
|
|
734 | ASImage* tmp; |
|
|
735 | int junk; |
|
|
736 | unsigned int hr = 1, vr = 1; |
|
|
737 | int flags = XParseGeometry (rs[Rs_blurradius], &junk, &junk, &hr, &vr); |
|
|
738 | if (!(flags&WidthValue)) |
|
|
739 | hr = 1; |
|
|
740 | if (!(flags&HeightValue)) |
|
|
741 | vr = hr; |
|
|
742 | tmp = blur_asimage_gauss (asv, back_im, hr, vr, 0xFFFFFFFF, |
|
|
743 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
|
|
744 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
745 | if (tmp) |
|
|
746 | { |
|
|
747 | destroy_asimage (&back_im); |
|
|
748 | back_im = tmp; |
|
|
749 | } |
|
|
750 | } |
|
|
751 | |
|
|
752 | if (original_asim != NULL) |
|
|
753 | { |
813 | ASImageLayer *layers = create_image_layers( 2 ); |
754 | ASImageLayer *layers = create_image_layers (2); |
814 | ASImage *merged_im = NULL; |
755 | ASImage *merged_im = NULL; |
815 | int back_x, back_y, back_w, back_h; |
756 | int fore_w, fore_h; |
816 | /* merge_layers does good job at tiling background appropriately, |
|
|
817 | so all we need is to cut out smallest possible piece : */ |
|
|
818 | #define MAKE_ROOTPMAP_GEOM(xy,wh,widthheight) \ |
|
|
819 | do{ while( root_##xy < 0 ) root_##xy += (int)wrootattr.widthheight; \ |
|
|
820 | back_##xy = root_##xy % pmap_##wh; /* that gives us left side of the closest tile : */ \ |
|
|
821 | if( pmap_##wh >= back_##xy + szHint.widthheight ) \ |
|
|
822 | back_##wh = szHint.widthheight;/* background is large - limit it by our size */ \ |
|
|
823 | else \ |
|
|
824 | { /* small background - need the whole of it for successfull tiling :*/ \ |
|
|
825 | back_##xy = 0; \ |
|
|
826 | back_##wh = pmap_##wh; \ |
|
|
827 | }}while(0) |
|
|
828 | |
|
|
829 | MAKE_ROOTPMAP_GEOM(x,w,width); |
|
|
830 | MAKE_ROOTPMAP_GEOM(y,h,height); |
|
|
831 | |
757 | |
832 | layers[0].im = pixmap2asimage (display->asv, rootpixmap, back_x, back_y, back_w, back_h, AllPlanes, ASA_ASImage, 100); |
758 | layers[0].im = back_im; |
833 | layers[0].clip_x = (back_w == pmap_w)?root_x:0; |
|
|
834 | layers[0].clip_y = (back_h == pmap_h)?root_y:0; |
|
|
835 | layers[0].clip_width = szHint.width; |
759 | layers[0].clip_width = szHint.width; |
836 | layers[0].clip_height = szHint.height; |
760 | layers[0].clip_height = szHint.height; |
837 | layers[0].tint = tint; |
761 | layers[0].tint = tint; |
838 | if (rs[Rs_blurradius] && layers[0].im) |
|
|
839 | { |
|
|
840 | double r = atof(rs[Rs_blurradius]); |
|
|
841 | ASImage* tmp = blur_asimage_gauss(display->asv, layers[0].im, r, r, 0xFFFFFFFF, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT ); |
|
|
842 | if( tmp ) |
|
|
843 | { |
|
|
844 | destroy_asimage( &layers[0].im ); |
|
|
845 | layers[0].im = tmp; |
|
|
846 | } |
|
|
847 | } |
|
|
848 | if (original_asim != NULL) |
|
|
849 | { |
|
|
850 | int fore_w, fore_h; |
|
|
851 | layers[1].im = original_asim; |
762 | layers[1].im = original_asim; |
852 | if( bgPixmap.auto_resize ) |
763 | if (bgPixmap.auto_resize) |
853 | { |
764 | { |
854 | fore_w = szHint.width; |
765 | fore_w = szHint.width; |
855 | fore_h = szHint.height; |
766 | fore_h = szHint.height; |
856 | } |
767 | } |
857 | else |
768 | else |
858 | { |
769 | { |
859 | fore_w = bgPixmap.w; |
770 | fore_w = bgPixmap.w; |
860 | fore_h = bgPixmap.h; |
771 | fore_h = bgPixmap.h; |
861 | } |
772 | } |
862 | if (fore_w != original_asim->width |
773 | if (fore_w != original_asim->width |
863 | || fore_h != original_asim->height) |
774 | || fore_h != original_asim->height) |
864 | { |
775 | { |
865 | layers[1].im = scale_asimage( display->asv, |
776 | layers[1].im = scale_asimage (asv, |
866 | original_asim, |
777 | original_asim, |
867 | fore_w, fore_h, |
778 | fore_w, fore_h, |
868 | ASA_ASImage, 100, |
779 | ASA_ASImage, 100, |
869 | ASIMAGE_QUALITY_DEFAULT ); |
780 | ASIMAGE_QUALITY_DEFAULT); |
870 | } |
781 | } |
871 | |
|
|
872 | layers[1].clip_width = szHint.width; |
782 | layers[1].clip_width = szHint.width; |
873 | layers[1].clip_height = szHint.height; |
783 | layers[1].clip_height = szHint.height; |
874 | |
784 | |
875 | if (rs[Rs_blendtype]) |
785 | if (rs[Rs_blendtype]) |
876 | { |
786 | { |
877 | layers[1].merge_scanlines = blend_scanlines_name2func(rs[Rs_blendtype]); |
787 | layers[1].merge_scanlines = blend_scanlines_name2func (rs[Rs_blendtype]); |
878 | if( layers[1].merge_scanlines == NULL ) |
788 | if (layers[1].merge_scanlines == NULL) |
879 | layers[1].merge_scanlines = alphablend_scanlines; |
789 | layers[1].merge_scanlines = alphablend_scanlines; |
880 | } |
790 | } |
881 | } |
791 | PRINT_BACKGROUND_OP_TIME; |
882 | merged_im = merge_layers( display->asv, layers, layers[1].im?2:1, |
792 | merged_im = merge_layers (asv, layers, 2, szHint.width, szHint.height, |
883 | szHint.width, szHint.height, |
|
|
884 | ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT ); |
793 | ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
885 | if (layers[1].im != original_asim) |
794 | if (layers[1].im != original_asim) |
886 | destroy_asimage( &(layers[1].im) ); |
795 | destroy_asimage (&(layers[1].im)); |
887 | destroy_asimage( &(layers[0].im) ); |
796 | free (layers); |
|
|
797 | |
888 | if (merged_im != NULL) |
798 | if (merged_im != NULL) |
889 | { |
799 | { |
890 | tmp_pmap = asimage2pixmap( display->asv, DefaultRootWindow(dpy), merged_im, gc, True ); |
|
|
891 | destroy_asimage( &merged_im ); |
800 | destroy_asimage (&back_im); |
|
|
801 | back_im = merged_im; |
892 | } |
802 | } |
893 | free( layers ); |
803 | PRINT_BACKGROUND_OP_TIME; |
894 | } |
804 | } |
|
|
805 | else if (tint != TINT_LEAVE_SAME) |
|
|
806 | { |
|
|
807 | ASImage* tmp = tile_asimage (asv, back_im, 0, 0, szHint.width, szHint.height, tint, ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
808 | if (tmp) |
|
|
809 | { |
|
|
810 | destroy_asimage (&back_im); |
|
|
811 | back_im = tmp; |
|
|
812 | } |
|
|
813 | PRINT_BACKGROUND_OP_TIME; |
|
|
814 | } |
|
|
815 | asimage2drawable (asv, pixmap, back_im, gc, 0, 0, 0, 0, szHint.width, szHint.height, True); |
|
|
816 | destroy_asimage (&back_im); |
|
|
817 | } /* back_im != NULL */ |
|
|
818 | else |
|
|
819 | success = False; |
895 | } |
820 | } |
896 | if (tmp_pmap != None) |
|
|
897 | { |
|
|
898 | success = True; |
|
|
899 | if (pixmap != None) |
|
|
900 | XFreePixmap (dpy, pixmap); |
|
|
901 | pixmap = tmp_pmap; |
|
|
902 | } |
|
|
903 | } |
|
|
904 | #else /* HAVE_AFTERIMAGE */ |
821 | #else /* HAVE_AFTERIMAGE */ |
905 | { |
|
|
906 | /* |
|
|
907 | * Copy display->root pixmap transparency |
|
|
908 | */ |
|
|
909 | int nx, ny; |
|
|
910 | unsigned int nw, nh; |
|
|
911 | XImage *image; |
|
|
912 | |
|
|
913 | nw = (unsigned int)szHint.width; |
|
|
914 | nh = (unsigned int)szHint.height; |
|
|
915 | nx = ny = 0; |
|
|
916 | |
|
|
917 | if (sx < 0) |
|
|
918 | { |
|
|
919 | nw += sx; |
|
|
920 | nx = -sx; |
|
|
921 | sx = 0; |
|
|
922 | } |
|
|
923 | |
|
|
924 | if (sy < 0) |
|
|
925 | { |
|
|
926 | nh += sy; |
|
|
927 | ny = -sy; |
|
|
928 | sy = 0; |
|
|
929 | } |
|
|
930 | |
|
|
931 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
932 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
933 | |
|
|
934 | XSync (dpy, False); |
|
|
935 | allowedxerror = -1; |
|
|
936 | image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
937 | |
|
|
938 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
939 | /* XXX: may need a delay here? */ |
|
|
940 | allowedxerror = 0; |
|
|
941 | if (image != NULL) |
|
|
942 | { |
|
|
943 | if (pixmap != None) |
|
|
944 | XFreePixmap (dpy, pixmap); |
|
|
945 | |
|
|
946 | #if TINTING |
822 | #if TINTING |
947 | if (ISSET_PIXCOLOR (Color_tint)) |
823 | if (!whole_tint && (!no_tint || shade !=100)) |
|
|
824 | { |
|
|
825 | XImage *image = XGetImage (dpy, pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); |
|
|
826 | success = False; |
|
|
827 | if (image != NULL) |
948 | { |
828 | { |
949 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
829 | PRINT_BACKGROUND_OP_TIME; |
950 | |
830 | if (gc == NULL) |
951 | rgba c; |
831 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
952 | pix_colors_focused [Color_tint].get (c); |
832 | if (ISSET_PIXCOLOR (Color_tint) || shade != 100) |
953 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
833 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
954 | } |
834 | XPutImage (dpy, pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); |
955 | #endif |
|
|
956 | |
|
|
957 | pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth); |
|
|
958 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
|
|
959 | XPutImage (dpy, pixmap, gc, image, 0, 0, |
|
|
960 | nx, ny, image->width, image->height); |
|
|
961 | XDestroyImage (image); |
835 | XDestroyImage (image); |
962 | success = True ; |
836 | success = True; |
963 | } |
837 | } |
964 | } |
838 | } |
|
|
839 | #endif |
965 | #endif /* HAVE_AFTERIMAGE */ |
840 | #endif /* HAVE_AFTERIMAGE */ |
|
|
841 | PRINT_BACKGROUND_OP_TIME; |
|
|
842 | |
966 | if (gc != NULL) |
843 | if (gc != NULL) |
967 | XFreeGC (dpy, gc); |
844 | XFreeGC (dpy, gc); |
968 | |
845 | |
969 | if (!success) |
846 | if (!success) |
970 | { |
847 | { |
971 | if (am_transparent && am_pixmap_trans) |
848 | if (am_transparent && am_pixmap_trans) |
… | |
… | |
988 | if (!am_transparent || !am_pixmap_trans) |
865 | if (!am_transparent || !am_pixmap_trans) |
989 | pchanged = 1; |
866 | pchanged = 1; |
990 | |
867 | |
991 | am_transparent = am_pixmap_trans = 1; |
868 | am_transparent = am_pixmap_trans = 1; |
992 | } |
869 | } |
993 | } |
870 | } /* rootpixmap != None */ |
994 | |
871 | |
995 | if (am_pixmap_trans) |
872 | if (am_pixmap_trans) |
996 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
873 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
997 | else |
874 | else |
998 | { |
875 | { |