--- rxvt-unicode/src/rxvttoolkit.C 2006/02/18 14:14:43 1.51 +++ rxvt-unicode/src/rxvttoolkit.C 2006/07/05 19:22:15 1.58 @@ -1,9 +1,9 @@ -/*--------------------------------*-C-*---------------------------------* +/*----------------------------------------------------------------------* * File: rxvttoolkit.C *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. - * Copyright (c) 2003-2004 Marc Lehmann + * Copyright (c) 2003-2006 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,11 +28,8 @@ #include #include - -#ifndef NO_SLOW_LINK_SUPPORT -# include -# include -#endif +#include +#include #if XFT # include @@ -350,7 +347,7 @@ XFree (dpy->xdefaults); #endif - if (XGetWindowProperty (dpy, root, XA_RESOURCE_MANAGER, + if (XGetWindowProperty (dpy, RootWindow (dpy, 0), XA_RESOURCE_MANAGER, 0L, 100000000L, False, XA_STRING, &actual_type, &actual_format, &nitems, &nremaining, @@ -465,7 +462,6 @@ int fd = XConnectionNumber (dpy); -#ifndef NO_SLOW_LINK_SUPPORT // 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 @@ -475,7 +471,6 @@ if (!getsockname (fd, (sockaddr *)&sa, &sl)) is_local = sa.sun_family == AF_LOCAL; -#endif x_ev.start (fd, EVENT_READ); fcntl (fd, F_SETFD, FD_CLOEXEC); @@ -656,6 +651,13 @@ refcache displays; ///////////////////////////////////////////////////////////////////////////// +// + +static unsigned int +insert_component (unsigned int value, unsigned int mask, unsigned int shift) +{ + return (value * (mask + 1) >> 16) << shift; +} bool rxvt_color::alloc (rxvt_screen *screen, const rgba &color) @@ -675,10 +677,10 @@ c.color.blue = color.b; c.color.alpha = color.a; - c.pixel = ((color.r * format->direct.redMask / rgba::MAX_CC) << format->direct.red ) - | ((color.g * format->direct.greenMask / rgba::MAX_CC) << format->direct.green) - | ((color.b * format->direct.blueMask / rgba::MAX_CC) << format->direct.blue ) - | ((color.a * format->direct.alphaMask / rgba::MAX_CC) << format->direct.alpha); + c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) + | insert_component (color.g, format->direct.greenMask, format->direct.green) + | insert_component (color.b, format->direct.blueMask , format->direct.blue ) + | insert_component (color.a, format->direct.alphaMask, format->direct.alpha); return true; } @@ -840,6 +842,9 @@ void rxvt_color::free (rxvt_screen *screen) { + if (screen->visual->c_class == TrueColor) + return; // nothing to do + #if XFT XftColorFree (screen->dpy, screen->visual, screen->cmap, &c); #else