--- rxvt-unicode/src/rxvtperl.xs 2012/06/09 10:21:19 1.187 +++ rxvt-unicode/src/rxvtperl.xs 2012/06/14 18:13:19 1.196 @@ -56,16 +56,51 @@ typedef int render_repeat_mode; +#if HAVE_PIXBUF typedef GdkPixbuf * urxvt__pixbuf; +#endif typedef rxvt_img * urxvt__img; ///////////////////////////////////////////////////////////////////////////// -static void -parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) +static rgba +parse_rgba (SV *sv, rxvt_screen *s = 0) { - //TODO: support component stuff - c.set (s, SvPVbyte_nolen (sv)); + rgba c; + + if (AV *av = (AV *)SvRV (sv)) + { + if (SvTYPE ((SV *)av) != SVt_PVAV) + croak ("colour must be either a colour string, or an array,"); + + int len = av_len (av) + 1; + + if (len != 1 && len != 3 && len != 4) + croak ("component colour array must have 1, 3 or 4 components,"); + + c.a = rgba::MAX_CC; + + c.r = c.g = c.b = float_to_component (SvIV (*av_fetch (av, 0, 0))); + + if (len >= 3) + { + c.g = float_to_component (SvIV (*av_fetch (av, 1, 0))); + c.b = float_to_component (SvIV (*av_fetch (av, 2, 0))); + + if (len >= 4) + c.a = float_to_component (SvIV (*av_fetch (av, 3, 0))); + } + } + else if (s) + { + rxvt_color rc; + rc.set (s, SvPVbyte_nolen (sv)); + rc.get (c); + } + else + croak ("unable to parse colour,"); + + return c; } ///////////////////////////////////////////////////////////////////////////// @@ -343,7 +378,7 @@ } void -rxvt_perl_interp::init (rxvt_term *term) +rxvt_perl_interp::init () { if (!perl) { @@ -383,6 +418,12 @@ rxvt_pop_locale (); } +} + +void +rxvt_perl_interp::init (rxvt_term *term) +{ + init (); if (perl && !term->perl.self) { @@ -394,6 +435,12 @@ } void +rxvt_perl_interp::eval (const char *str) +{ + eval_pv (str, 1); +} + +void rxvt_perl_interp::usage (rxvt_term *term, int type) { localise_env set_environ (perl_environ); @@ -2032,7 +2079,13 @@ ############################################################################# # fancy bg bloatstuff (TODO: should be moved up somewhere) -# TODO: ugly +bool +rxvt_term::has_render () + CODE: + RETVAL = THIS->display->flags & DISPLAY_HAS_RENDER; + OUTPUT: + RETVAL + void rxvt_term::background_geometry (bool border = false) PPCODE: @@ -2044,20 +2097,17 @@ #if HAVE_IMG -#if 0 - rxvt_img * -rxvt_term::new_img (SV *format, int width, int height) +rxvt_term::new_img (SV *format, int x = 0, int y = 0, int width = 1, int height = 1) CODE: XRenderPictFormat *f = SvOK (format) ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) : XRenderFindVisualFormat (THIS->dpy, THIS->visual); - RETVAL = new rxvt_img (THIS, f, width, height); + RETVAL = new rxvt_img (THIS, f, x, y, width, height); + RETVAL->alloc (); OUTPUT: RETVAL -#endif - #if ENABLE_TRANSPARENCY rxvt_img * @@ -2093,7 +2143,6 @@ rxvt_term::set_background (rxvt_img *img, bool border = false) CODE: THIS->bg_destroy (); - THIS->bg_pixmap = None; THIS->bg_flags &= ~(rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER | rxvt_term::BG_IS_TRANSPARENT); if (img) // TODO: cannot be false @@ -2113,13 +2162,11 @@ img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg]) ->replace (img); - THIS->bg_pixmap = img->steal (); + THIS->bg_img = img; THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER; if (!border) THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT; - - delete img; } #endif @@ -2167,6 +2214,29 @@ # rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) # rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); +void +rxvt_img::geometry () + PPCODE: + EXTEND (SP, 4); + PUSHs (sv_2mortal (newSViv (THIS->x))); + PUSHs (sv_2mortal (newSViv (THIS->y))); + PUSHs (sv_2mortal (newSViv (THIS->w))); + PUSHs (sv_2mortal (newSViv (THIS->h))); + +int +rxvt_img::x () + CODE: + RETVAL = THIS->x; + OUTPUT: + RETVAL + +int +rxvt_img::y () + CODE: + RETVAL = THIS->y; + OUTPUT: + RETVAL + int rxvt_img::w () CODE: @@ -2191,9 +2261,8 @@ void rxvt_img::fill (SV *c) INIT: - rxvt_color rc; - parse_color (THIS->s, rc, c); - C_ARGS: rc + rgba cc = parse_rgba (c, THIS->s); + C_ARGS: cc void rxvt_img::DESTROY () @@ -2233,20 +2302,20 @@ rxvt_img::blur (int rh, int rv) rxvt_img * -rxvt_img::transform (int new_width, int new_height, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) +rxvt_img::transform (NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) INIT: - double matrix[9] = { - p11, p12, p13, - p21, p22, p23, - p31, p32, p33 + double matrix[3][3] = { + { p11, p12, p13 }, + { p21, p22, p23 }, + { p31, p32, p33 } }; - C_ARGS: new_width, new_height, matrix + C_ARGS: matrix rxvt_img * rxvt_img::scale (int new_width, int new_height) rxvt_img * -rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi) +rxvt_img::rotate (int x, int y, NV phi) #endif