--- rxvt-unicode/src/rxvtimg.C 2012/06/05 12:30:37 1.18 +++ rxvt-unicode/src/rxvtimg.C 2012/06/05 14:59:44 1.21 @@ -18,6 +18,38 @@ } rxvt_img * +rxvt_img::new_from_root (rxvt_screen *s) +{ + Display *dpy = s->display->dpy; + unsigned int root_pm_w, root_pm_h; + Pixmap root_pixmap = s->display->get_pixmap_property (s->display->xa[XA_XROOTPMAP_ID]); + if (root_pixmap == None) + root_pixmap = s->display->get_pixmap_property (s->display->xa[XA_ESETROOT_PMAP_ID]); + + if (root_pixmap == None) + return 0; + + Window wdummy; + int idummy; + unsigned int udummy; + + if (!XGetGeometry (dpy, root_pixmap, &wdummy, &idummy, &idummy, &root_pm_w, &root_pm_h, &udummy, &udummy)) + return 0; + + rxvt_img *img = new rxvt_img ( + s, + XRenderFindVisualFormat (dpy, DefaultVisual (dpy, s->display->screen)), + root_pm_w, + root_pm_h, + root_pixmap + ); + + img->shared = true; + + return img; +} + +rxvt_img * rxvt_img::new_from_file (rxvt_screen *s, const char *filename) { GError *err = 0; @@ -312,15 +344,36 @@ rxvt_img * rxvt_img::clone () { + rxvt_img *img = new rxvt_img (s, format, w, h); + GC gc = XCreateGC (s->display->dpy, pm, 0, 0); - Pixmap pm2 = XCreatePixmap (s->display->dpy, pm, w, h, format->depth); - XCopyArea (s->display->dpy, pm, pm2, gc, 0, 0, w, h, 0, 0); + XCopyArea (s->display->dpy, pm, img->pm, gc, 0, 0, w, h, 0, 0); XFreeGC (s->display->dpy, gc); - return new rxvt_img (s, format, w, h, pm2); + + return img; +} + +rxvt_img * +rxvt_img::sub_rect (int x, int y, int width, int height, int repeat) +{ + rxvt_img *img = new rxvt_img (s, format, width, height); + + Display *dpy = s->display->dpy; + XRenderPictureAttributes pa; + pa.repeat = repeat; + Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); + Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); + + XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, width, height); + + XRenderFreePicture (dpy, src); + XRenderFreePicture (dpy, dst); + + return img; } rxvt_img * -rxvt_img::transform (int new_width, int new_height, int repeat, double matrix[9]) +rxvt_img::transform (int new_width, int new_height, double matrix[9], int repeat) { rxvt_img *img = new rxvt_img (s, format, new_width, new_height); @@ -355,11 +408,11 @@ 0, 0, 1 }; - return transform (new_width, new_height, RepeatNormal, matrix); + return transform (new_width, new_height, matrix); } rxvt_img * -rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, double phi) +rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi, int repeat) { double s = sin (phi); double c = cos (phi); @@ -370,7 +423,7 @@ 0, 0, 1 }; - return transform (new_width, new_height, repeat, matrix); + return transform (new_width, new_height, matrix, repeat); } rxvt_img *