--- rxvt-unicode/src/rxvttoolkit.C 2004/12/29 19:59:46 1.10 +++ rxvt-unicode/src/rxvttoolkit.C 2006/01/06 02:11:15 1.20 @@ -84,7 +84,7 @@ } template -refcache::~refcache () +void refcache::clear () { while (this->size ()) put (*this->begin ()); @@ -145,7 +145,21 @@ bool rxvt_display::init () { - display = XOpenDisplay (id); +#ifdef LOCAL_X_IS_UNIX + if (id[0] == ':') + { + val = rxvt_malloc (5 + strlen (id) + 1); + strcpy (val, "unix/"); + strcat (val, id); + display = XOpenDisplay (val); + free (val); + } + else +#endif + display = 0; + + if (!display) + display = XOpenDisplay (id); if (!display) return false; @@ -159,7 +173,7 @@ int fd = XConnectionNumber (display); #ifndef NO_SLOW_LINK_SUPPORT - // try to detetc wether we have a local connection. + // try to detect wether we have a local connection. // assume unix domains socket == local, everything else not // TODO: might want to check for inet/127.0.0.1 is_local = 0; @@ -170,6 +184,17 @@ is_local = sa.sun_family == AF_LOCAL; #endif +#ifdef POINTER_BLANK + XColor blackcolour; + blackcolour.red = 0; + blackcolour.green = 0; + blackcolour.blue = 0; + Font f = XLoadFont (display, "fixed"); + blank_cursor = XCreateGlyphCursor (display, f, f, ' ', ' ', + &blackcolour, &blackcolour); + XUnloadFont (display, f); +#endif + #ifdef PREFER_24BIT /* * If depth is not 24, look for a 24bit visual. @@ -205,6 +230,9 @@ rxvt_display::~rxvt_display () { x_ev.stop (); +#ifdef USE_XIM + xims.clear (); +#endif if (display) XCloseDisplay (display); @@ -219,7 +247,7 @@ void rxvt_display::im_change_check () { - // make sure we only call im_change_cb when a new input method + // try to only call im_change_cb when a new input method // registers, as xlib crashes due to a race otherwise. Atom actual_type, *atoms; int actual_format; @@ -253,7 +281,6 @@ #ifdef USE_XIM if (!XFilterEvent (&xev, None)) { - if (xev.type == PropertyNotify && xev.xany.window == root && xev.xproperty.atom == xa_xim_servers) @@ -448,14 +475,43 @@ rxvt_color rxvt_color::fade (rxvt_display *display, int percent) { + percent = 100 - percent; + unsigned short cr, cg, cb; rxvt_color faded; get (display, cr, cg, cb); - faded.set (display, - cr * percent / 100, - cg * percent / 100, - cb * percent / 100); + + faded.set ( + display, + cr * percent / 100, + cg * percent / 100, + cb * percent / 100 + ); + + return faded; +} + +#define LERP(a,b,p) (a * p + b * (100 - p)) / 100 + +rxvt_color +rxvt_color::fade (rxvt_display *display, int percent, rxvt_color &fadeto) +{ + percent = 100 - percent; + + unsigned short cr, cg, cb; + unsigned short fcr, fcg, fcb; + rxvt_color faded; + + get (display, cr, cg, cb); + fadeto.get(display, fcr, fcg, fcb); + + faded.set ( + display, + LERP (cr, fcr, percent), + LERP (cg, fcg, percent), + LERP (cb, fcb, percent) + ); return faded; }