--- rxvt-unicode/src/rxvtperl.xs 2011/03/24 17:34:29 1.139 +++ rxvt-unicode/src/rxvtperl.xs 2012/06/04 21:33:47 1.165 @@ -25,11 +25,12 @@ #include #include #undef line_t +#undef bool // perl defines it's own bool type, except with g++... what a trap #include "../config.h" -#include -#include +#include +#include #include "unistd.h" @@ -50,6 +51,23 @@ ///////////////////////////////////////////////////////////////////////////// +typedef char * octet_string; +typedef char * utf8_string; + +typedef GdkPixbuf * urxvt__pixbuf; +typedef rxvt_img * urxvt__img; + +///////////////////////////////////////////////////////////////////////////// + +static void +parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) +{ + //TODO: support component stuff + c.set (s, SvPVbyte_nolen (sv)); +} + +///////////////////////////////////////////////////////////////////////////// + static wchar_t * sv2wcs (SV *sv) { @@ -343,7 +361,7 @@ "" "use urxvt;" }; - int argc = ARRAY_LENGTH(args); + int argc = ecb_array_length (args); char **argv = args; PERL_SYS_INIT3 (&argc, &argv, &environ); @@ -369,6 +387,7 @@ // runs outside of perls ENV term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); + hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); } } @@ -399,6 +418,16 @@ for (int i = 0; i <= AvFILL (av); i++) ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); } + else if (htype == HOOK_DESTROY) + { + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); + + for (int i = AvFILL (av); i >= 0; i--) + { + rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); + delete req; + } + } bool event_consumed; @@ -773,6 +802,17 @@ const_iv (XIMVisibleToForward), const_iv (XIMVisibleToBackword), const_iv (XIMVisibleToCenter), +#if XRENDER + const_iv (PictStandardARGB32), + const_iv (PictStandardRGB24), + const_iv (PictStandardA8), + const_iv (PictStandardA4), + const_iv (PictStandardA1), + const_iv (RepeatNone), + const_iv (RepeatNormal), + const_iv (RepeatPad), + const_iv (RepeatReflect), +#endif # if 0 const_iv (XIMForwardChar), const_iv (XIMBackwardChar), @@ -790,8 +830,8 @@ # endif }; - for (civ = const_iv + ARRAY_LENGTH(const_iv); civ-- > const_iv; ) - newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); + for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) + newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); } void @@ -878,6 +918,8 @@ CODE: rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); req->cb_sv = newSVsv (cb); + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); + av_push (av, newSViv ((IV)req)); RETVAL = (IV)req; OUTPUT: RETVAL @@ -886,6 +928,18 @@ _delete_selection_request (IV req_) CODE: rxvt_selection *req = (rxvt_selection *)req_; + AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); + int i; + + for (i = AvFILL (av); i >= 0; i--) + if (SvIV (*av_fetch (av, i, 1)) == req_) + break; + + for (; i < AvFILL (av); i++) + av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); + + av_pop (av); + delete req; MODULE = urxvt PACKAGE = urxvt::term @@ -897,16 +951,13 @@ rxvt_term *term = new rxvt_term; stringvec *argv = new stringvec; - stringvec *envv = new stringvec; - for (int i = 0; i <= AvFILL (arg); i++) argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); + stringvec *envv = new stringvec; for (int i = AvFILL (env) + 1; i--; ) envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); - envv->push_back (0); - try { term->init (argv, envv); @@ -956,11 +1007,6 @@ CODE: XUngrabKey (THIS->dpy, keycode, modifiers, window); -void -rxvt_term::XUngrabKeyboard (Time eventtime) - CODE: - XUngrabKeyboard (THIS->dpy, eventtime); - bool rxvt_term::grab (Time eventtime, int sync = 0) CODE: @@ -1084,13 +1130,6 @@ OUTPUT: RETVAL -char * -rxvt_term::locale () - CODE: - RETVAL = THIS->locale; - OUTPUT: - RETVAL - #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) #define TERM_OFFSET_width TERM_OFFSET(width) @@ -1204,7 +1243,7 @@ Window rxvt_term::parent () CODE: - RETVAL = THIS->parent [0]; + RETVAL = THIS->parent; OUTPUT: RETVAL @@ -1243,6 +1282,9 @@ RETVAL void +rxvt_term::set_urgency (bool enable) + +void rxvt_term::focus_in () void @@ -1483,7 +1525,7 @@ # undef reserve }; - rs = rslist + ARRAY_LENGTH(rslist); + rs = rslist + ecb_array_length (rslist); if (*name) { @@ -1532,7 +1574,7 @@ { THIS->set_option (optval, set); - if (THIS->env_colorfgbg [0]) // avoid doing this before START + if (THIS->init_done) // avoid doing this before START switch (optval) { case Opt_skipBuiltinGlyphs: @@ -1542,6 +1584,11 @@ THIS->want_refresh = 1; THIS->refresh_check (); break; +#ifdef CURSOR_BLINK + case Opt_cursorBlink: + THIS->cursor_blink_reset (); + break; +#endif case Opt_cursorUnderline: THIS->want_refresh = 1; @@ -1567,6 +1614,13 @@ RETVAL void +rxvt_term::register_command (int keysym, unsigned int state, SV *str) + CODE: + wchar_t *wstr = sv2wcs (str); + THIS->keyboard->register_user_translation (keysym, state, wstr); + free (wstr); + +void rxvt_term::screen_cur (...) PROTOTYPE: $;$$ ALIAS: @@ -1682,6 +1736,9 @@ rxvt_term::scr_bell () void +rxvt_term::scr_recolour (bool refresh = true); + +void rxvt_term::scr_change_screen (int screen) void @@ -1804,7 +1861,7 @@ } Atom -XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) +XInternAtom (rxvt_term *term, octet_string atom_name, int only_if_exists = FALSE) C_ARGS: term->dpy, atom_name, only_if_exists char * @@ -1815,7 +1872,7 @@ void XDeleteProperty (rxvt_term *term, Window window, Atom property) - C_ARGS: term->dpy, window, property + C_ARGS: term->dpy, window, property Window rxvt_term::DefaultRootWindow () @@ -1877,6 +1934,92 @@ } ############################################################################# +# fancy bg bloatstuff (TODO: should be moved up somewhere) + +# TODO: ugly +void +rxvt_term::get_geometry () + PPCODE: + Window wdummy; + int x, y; + XWindowAttributes wattr; + XGetWindowAttributes (THIS->dpy, THIS->parent, &wattr); + XTranslateCoordinates (THIS->dpy, THIS->parent, wattr.root, + -wattr.border_width, -wattr.border_width, + &x, &y, &wdummy); + EXTEND (SP, 4); + PUSHs (sv_2mortal (newSViv (x))); + PUSHs (sv_2mortal (newSViv (y))); + PUSHs (sv_2mortal (newSViv (wattr.width))); + PUSHs (sv_2mortal (newSViv (wattr.height))); + +#if HAVE_IMG + +rxvt_img * +rxvt_term::new_img (SV *format, int width, int height) + CODE: + XRenderPictFormat *f = SvOK (format) + ? XRenderFindVisualFormat (THIS->dpy, THIS->visual) + : XRenderFindStandardFormat (THIS->dpy, SvIV (format)); + RETVAL = new rxvt_img (THIS, f, width, height); + OUTPUT: + RETVAL + +#if ENABLE_TRANSPARENCY + +#if 0 + +rxvt_img * +rxvt_term::new_img_from_root () + CODE: + RETVAL = rxvt_img::new_from_root (THIS); + OUTPUT: + RETVAL + +#endif + +#endif + +#if HAVE_PIXBUF + +rxvt_img * +rxvt_term::new_img_from_file (octet_string filename) + CODE: + try + { + RETVAL = rxvt_img::new_from_file (THIS, filename); + } + catch (const class rxvt_failure_exception &e) + { + croak ("new_img_from_file failed"); + } + OUTPUT: + RETVAL + +#endif + +#if HAVE_BG_PIXMAP + +void +rxvt_term::set_background (rxvt_img *img) + CODE: + THIS->bg_destroy (); + THIS->bg_pixmap = None; + THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH; + + if (img) // TODO: cannot be false + { + img->unshare (); + THIS->bg_pixmap = img->steal (); + THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH; + THIS->bg_valid_since = ev::now (); // TODO: extra bloat + } + +#endif + +#endif + +############################################################################# # urxvt::overlay ############################################################################# @@ -1896,3 +2039,97 @@ INCLUDE: $PERL w; + OUTPUT: + RETVAL + +int +rxvt_img::h () + CODE: + RETVAL = THIS->h; + OUTPUT: + RETVAL + +bool +rxvt_img::shared () + CODE: + RETVAL = THIS->shared; + OUTPUT: + RETVAL + +Pixmap +rxvt_img::pm () + CODE: + RETVAL = THIS->pm; + OUTPUT: + RETVAL + +void +rxvt_img::fill (SV *c) + INIT: + rxvt_color rc; + parse_color (THIS->s, rc, c); + C_ARGS: rc + +void +rxvt_img::DESTROY () + CODE: + delete THIS; + +void +rxvt_img::blur (int rh, int rv) + +void +rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) + +void +rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) + +void +rxvt_img::unshare () + +rxvt_img * +rxvt_img::clone () + +rxvt_img * +rxvt_img::transform (int new_width, int new_height, int repeat, 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 + }; + C_ARGS: new_width, new_height, repeat, matrix + +rxvt_img * +rxvt_img::scale (int new_width, int new_height) + +rxvt_img * +rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, NV phi) + +#endif +