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.137 by root, Thu Jun 7 16:04:31 2012 UTC vs.
Revision 1.145 by root, Sat Dec 13 10:47:32 2014 UTC

6 * Copyright (c) 2003-2011 Marc Lehmann <schmorp@schmorp.de> 6 * Copyright (c) 2003-2011 Marc Lehmann <schmorp@schmorp.de>
7 * Copyright (c) 2011 Emanuele Giaquinta <e.giaquinta@glauco.it> 7 * Copyright (c) 2011 Emanuele Giaquinta <e.giaquinta@glauco.it>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version. 12 * (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66#endif 66#endif
67#if USE_XIM 67#if USE_XIM
68 "WM_LOCALE_NAME", 68 "WM_LOCALE_NAME",
69 "XIM_SERVERS", 69 "XIM_SERVERS",
70#endif 70#endif
71#if ENABLE_TRANSPARENCY 71#if HAVE_IMG || ENABLE_PERL
72 "_XROOTPMAP_ID", 72 "_XROOTPMAP_ID",
73 "ESETROOT_PMAP_ID", 73 "ESETROOT_PMAP_ID",
74#endif 74#endif
75#if ENABLE_XEMBED 75#if ENABLE_XEMBED
76 "_XEMBED", 76 "_XEMBED",
279 XFree (vi); 279 XFree (vi);
280 280
281 cmap = XCreateColormap (dpy, display->root, visual, AllocNone); 281 cmap = XCreateColormap (dpy, display->root, visual, AllocNone);
282 } 282 }
283 else 283 else
284 rxvt_warn ("cannot requested visual id 0x%02x, using default visual.\n", id); 284 rxvt_warn ("no visual found for requested id 0x%02x, using default visual.\n", id);
285} 285}
286 286
287void 287void
288rxvt_screen::select_depth (int bitdepth) 288rxvt_screen::select_depth (int bitdepth)
289{ 289{
490 490
491 flags = 0; 491 flags = 0;
492#if XRENDER 492#if XRENDER
493 int major, minor; 493 int major, minor;
494 if (XRenderQueryVersion (dpy, &major, &minor)) 494 if (XRenderQueryVersion (dpy, &major, &minor))
495 {
496 flags |= DISPLAY_HAS_RENDER;
497
498 if (major > 0 || (major == 0 && minor >= 10))
499 flags |= DISPLAY_HAS_RENDER_10;
500
501 if (major > 0 || (major == 0 && minor >= 11)) 495 if (major > 0 || (major == 0 && minor >= 11))
496 {
502 flags |= DISPLAY_HAS_RENDER_MUL; 497 flags |= DISPLAY_HAS_RENDER;
503 498
504 XFilters *filters = XRenderQueryFilters (dpy, root); 499 if (XFilters *filters = XRenderQueryFilters (dpy, root))
505 if (filters)
506 { 500 {
507 for (int i = 0; i < filters->nfilter; i++) 501 for (int i = 0; i < filters->nfilter; i++)
508 if (!strcmp (filters->filter[i], FilterConvolution)) 502 if (!strcmp (filters->filter [i], FilterConvolution))
509 flags |= DISPLAY_HAS_RENDER_CONV; 503 flags |= DISPLAY_HAS_RENDER_CONV;
510 504
511 XFree (filters); 505 XFree (filters);
512 } 506 }
513 } 507 }
514#endif 508#endif
515 509
516 int fd = XConnectionNumber (dpy); 510 int fd = XConnectionNumber (dpy);
517 511
518 // try to detect whether we have a local connection. 512 // try to detect whether we have a local connection.
881 875
882 // many kilobytes transfer per colour, but pseudocolor isn't worth 876 // many kilobytes transfer per colour, but pseudocolor isn't worth
883 // many extra optimisations. 877 // many extra optimisations.
884 XQueryColors (screen->dpy, screen->cmap, colors, cmap_size); 878 XQueryColors (screen->dpy, screen->cmap, colors, cmap_size);
885 879
880 while (cmap_size)
881 {
886 int diff = 0x7fffffffUL; 882 int diff = 0x7fffffffUL;
887 XColor *best = colors; 883 XColor *best = colors;
888 884
889 for (int i = 0; i < cmap_size; i++) 885 for (int i = 0; i < cmap_size; i++)
890 {
891 int d = (squared_diff<int> (color.r >> 2, colors [i].red >> 2))
892 + (squared_diff<int> (color.g >> 2, colors [i].green >> 2))
893 + (squared_diff<int> (color.b >> 2, colors [i].blue >> 2));
894
895 if (d < diff)
896 { 886 {
887 int d = (squared_diff<int> (color.r >> 2, colors [i].red >> 2))
888 + (squared_diff<int> (color.g >> 2, colors [i].green >> 2))
889 + (squared_diff<int> (color.b >> 2, colors [i].blue >> 2));
890
891 if (d < diff)
892 {
897 diff = d; 893 diff = d;
898 best = colors + i; 894 best = colors + i;
895 }
899 } 896 }
900 }
901 897
902 //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d)\n", 898 //rxvt_warn ("could not allocate %04x %04x %04x, getting %04x %04x %04x instead (%d,%d)\n",
903 // color.r, color.g, color.b, best->red, best->green, best->blue, diff); 899 // color.r, color.g, color.b, best->red, best->green, best->blue, diff, best - colors);
904 900
905 got = alloc (screen, rgba (best->red, best->green, best->blue)); 901 got = alloc (screen, rgba (best->red, best->green, best->blue));
902
903 if (got)
904 break;
905
906 *best = colors [--cmap_size];
907 }
906 908
907 delete [] colors; 909 delete [] colors;
908 } 910 }
909#endif 911#endif
910 912

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines