ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.C
(Generate patch)

Comparing rxvt-unicode/src/rxvttoolkit.C (file contents):
Revision 1.53 by root, Sun Feb 19 16:25:13 2006 UTC vs.
Revision 1.59 by root, Wed Jul 5 20:31:48 2006 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvttoolkit.C 2 * File: rxvttoolkit.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
262 visual = DefaultVisualOfScreen (screen); 262 visual = DefaultVisualOfScreen (screen);
263 cmap = DefaultColormapOfScreen (screen); 263 cmap = DefaultColormapOfScreen (screen);
264} 264}
265 265
266void 266void
267rxvt_screen::set (rxvt_display *disp, int bitdepth) 267rxvt_screen::select_visual (int bitdepth)
268{ 268{
269 set (disp);
270
271#if XFT 269#if XFT
272 XVisualInfo vinfo; 270 XVisualInfo vinfo;
273 271
274 if (XMatchVisualInfo (dpy, display->screen, bitdepth, TrueColor, &vinfo)) 272 if (XMatchVisualInfo (dpy, display->screen, bitdepth, TrueColor, &vinfo))
275 { 273 {
276 depth = bitdepth; 274 depth = bitdepth;
277 visual = vinfo.visual; 275 visual = vinfo.visual;
278 cmap = XCreateColormap (dpy, disp->root, visual, AllocNone); 276 cmap = XCreateColormap (dpy, display->root, visual, AllocNone);
279 } 277 }
280#endif 278#endif
281} 279}
282 280
283void 281void
345#if XLIB_ILLEGAL_ACCESS 343#if XLIB_ILLEGAL_ACCESS
346 if (dpy->xdefaults) 344 if (dpy->xdefaults)
347 XFree (dpy->xdefaults); 345 XFree (dpy->xdefaults);
348#endif 346#endif
349 347
350 if (XGetWindowProperty (dpy, root, XA_RESOURCE_MANAGER, 348 if (XGetWindowProperty (dpy, RootWindow (dpy, 0), XA_RESOURCE_MANAGER,
351 0L, 100000000L, False, 349 0L, 100000000L, False,
352 XA_STRING, &actual_type, &actual_format, 350 XA_STRING, &actual_type, &actual_format,
353 &nitems, &nremaining, 351 &nitems, &nremaining,
354 (unsigned char **)&val) == Success 352 (unsigned char **)&val) == Success
355 && actual_type == XA_STRING 353 && actual_type == XA_STRING
649 647
650template class refcache<rxvt_display>; 648template class refcache<rxvt_display>;
651refcache<rxvt_display> displays; 649refcache<rxvt_display> displays;
652 650
653///////////////////////////////////////////////////////////////////////////// 651/////////////////////////////////////////////////////////////////////////////
652//
653
654static unsigned int
655insert_component (unsigned int value, unsigned int mask, unsigned int shift)
656{
657 return (value * (mask + 1) >> 16) << shift;
658}
654 659
655bool 660bool
656rxvt_color::alloc (rxvt_screen *screen, const rgba &color) 661rxvt_color::alloc (rxvt_screen *screen, const rgba &color)
657{ 662{
658#if XFT 663#if XFT
668 c.color.red = color.r; 673 c.color.red = color.r;
669 c.color.green = color.g; 674 c.color.green = color.g;
670 c.color.blue = color.b; 675 c.color.blue = color.b;
671 c.color.alpha = color.a; 676 c.color.alpha = color.a;
672 677
673 c.pixel = ((color.r * format->direct.redMask / rgba::MAX_CC) << format->direct.red ) 678 c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red )
674 | ((color.g * format->direct.greenMask / rgba::MAX_CC) << format->direct.green) 679 | insert_component (color.g, format->direct.greenMask, format->direct.green)
675 | ((color.b * format->direct.blueMask / rgba::MAX_CC) << format->direct.blue ) 680 | insert_component (color.b, format->direct.blueMask , format->direct.blue )
676 | ((color.a * format->direct.alphaMask / rgba::MAX_CC) << format->direct.alpha); 681 | insert_component (color.a, format->direct.alphaMask, format->direct.alpha);
677 682
678 return true; 683 return true;
679 } 684 }
680 else 685 else
681 { 686 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines