--- rxvt-unicode/src/rxvttoolkit.C 2011/05/25 08:55:52 1.126 +++ rxvt-unicode/src/rxvttoolkit.C 2012/06/04 15:18:52 1.134 @@ -68,7 +68,7 @@ "WM_LOCALE_NAME", "XIM_SERVERS", #endif -#ifdef ENABLE_TRANSPARENCY +#if ENABLE_TRANSPARENCY "_XROOTPMAP_ID", "ESETROOT_PMAP_ID", #endif @@ -155,7 +155,7 @@ ///////////////////////////////////////////////////////////////////////////// -#ifdef USE_XIM +#if USE_XIM static void #if XIMCB_PROTO_BROKEN @@ -432,10 +432,11 @@ #ifdef LOCAL_X_IS_UNIX if (id[0] == ':') { - if (!(val = rxvt_temp_buf (5 + strlen (id) + 1))) - return false; + char *val = rxvt_temp_buf (5 + strlen (id) + 1); + strcpy (val, "unix/"); strcat (val, id); + dpy = XOpenDisplay (val); } else @@ -451,7 +452,7 @@ screen = DefaultScreen (dpy); root = DefaultRootWindow (dpy); - assert (ARRAY_LENGTH(xa_names) == NUM_XA); + assert (ecb_array_length (xa_names) == NUM_XA); XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); XrmSetDatabase (dpy, get_resources (false)); @@ -467,6 +468,28 @@ XUnloadFont (dpy, f); #endif + flags = 0; +#if XRENDER + int major, minor; + if (XRenderQueryVersion (dpy, &major, &minor)) + { + flags |= DISPLAY_HAS_RENDER; + + if (major > 0 || (major == 0 && minor >= 11)) + flags |= DISPLAY_HAS_RENDER_MUL; + + XFilters *filters = XRenderQueryFilters (dpy, root); + if (filters) + { + for (int i = 0; i < filters->nfilter; i++) + if (!strcmp (filters->filter[i], FilterConvolution)) + flags |= DISPLAY_HAS_RENDER_CONV; + + XFree (filters); + } + } +#endif + int fd = XConnectionNumber (dpy); // try to detect whether we have a local connection. @@ -513,14 +536,14 @@ #endif x_ev.stop (); flush_ev.stop (); -#ifdef USE_XIM +#if USE_XIM xims.clear (); #endif XrmDestroyDatabase (XrmGetDatabase (dpy)); XCloseDisplay (dpy); } -#ifdef USE_XIM +#if USE_XIM void rxvt_display::im_change_cb () { for (im_watcher **i = imw.begin (); i != imw.end (); ++i) @@ -566,7 +589,7 @@ XEvent xev; XNextEvent (dpy, &xev); -#ifdef USE_XIM +#if USE_XIM if (!XFilterEvent (&xev, None)) { if (xev.type == PropertyNotify @@ -584,7 +607,7 @@ else if (xw[i]->window == xev.xany.window) xw[i]->call (xev); } -#ifdef USE_XIM +#if USE_XIM } #endif } @@ -625,7 +648,7 @@ cur_owner = owner; } -#ifdef USE_XIM +#if USE_XIM void rxvt_display::reg (im_watcher *w) { @@ -670,6 +693,28 @@ return XInternAtom (dpy, name, False); } +Pixmap +rxvt_display::get_pixmap_property (Atom property) +{ + Pixmap pixmap = None; + + int aformat; + unsigned long nitems, bytes_after; + Atom atype; + unsigned char *prop; + int result = XGetWindowProperty (dpy, root, property, + 0L, 1L, False, XA_PIXMAP, &atype, &aformat, + &nitems, &bytes_after, &prop); + if (result == Success) + { + if (atype == XA_PIXMAP) + pixmap = *(Pixmap *)prop; + XFree (prop); + } + + return pixmap; +} + ///////////////////////////////////////////////////////////////////////////// template class refcache; @@ -688,7 +733,7 @@ rxvt_color::alloc (rxvt_screen *screen, const rgba &color) { //TODO: only supports 24 bit - int alpha = color.a >= 0xff00 ? 0xffff : color.a; + unsigned int alpha = color.a >= 0xff00 ? 0xffff : color.a; #if XFT XRenderPictFormat *format; @@ -727,7 +772,8 @@ d.blue = color.b; d.alpha = alpha; - return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); + if (XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c)) + return true; } #else c.red = color.r; @@ -736,20 +782,20 @@ if (screen->visual->c_class == TrueColor) { - c.pixel = (color.r >> (16 - rxvt_popcount (screen->visual->red_mask )) << rxvt_ctz (screen->visual->red_mask )) - | (color.g >> (16 - rxvt_popcount (screen->visual->green_mask)) << rxvt_ctz (screen->visual->green_mask)) - | (color.b >> (16 - rxvt_popcount (screen->visual->blue_mask )) << rxvt_ctz (screen->visual->blue_mask )); + c.pixel = (color.r >> (16 - ecb_popcount32 (screen->visual->red_mask )) << ecb_ctz32 (screen->visual->red_mask )) + | (color.g >> (16 - ecb_popcount32 (screen->visual->green_mask)) << ecb_ctz32 (screen->visual->green_mask)) + | (color.b >> (16 - ecb_popcount32 (screen->visual->blue_mask )) << ecb_ctz32 (screen->visual->blue_mask )); return true; } else if (XAllocColor (screen->dpy, screen->cmap, &c)) return true; - else - c.pixel = (color.r + color.g + color.b) > 128*3 - ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy)) - : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy)); #endif + c.pixel = (color.r + color.g + color.b) > 128*3 + ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy)) + : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy)); + return false; } @@ -913,6 +959,7 @@ incr_buf_size = incr_buf_fill = 0; selection_wait = Sel_normal; selection_type = selnum; + cb_sv = 0; } void @@ -962,7 +1009,7 @@ void rxvt_selection::finish (char *data, unsigned int len) { - if (term) + if (!cb_sv) { if (data) term->paste (data, len);