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

Comparing rxvt-unicode/src/rxvtcolor.C (file contents):
Revision 1.17 by root, Thu Jul 29 22:34:12 2004 UTC vs.
Revision 1.22 by root, Wed Aug 4 03:29:28 2004 UTC

25#include <rxvtcolor.h> 25#include <rxvtcolor.h>
26 26
27#include <unistd.h> 27#include <unistd.h>
28#include <fcntl.h> 28#include <fcntl.h>
29 29
30#ifndef NO_SLOW_LINK_SUPPORT
31# include <sys/socket.h>
32# include <sys/un.h>
33#endif
34
30class byteorder byteorder; 35class byteorder byteorder;
31 36
32byteorder::byteorder () 37byteorder::byteorder ()
33{ 38{
34 union { 39 union {
104 109
105///////////////////////////////////////////////////////////////////////////// 110/////////////////////////////////////////////////////////////////////////////
106 111
107#ifdef USE_XIM 112#ifdef USE_XIM
108static void 113static void
114#if XIMCB_PROTO_BROKEN
115im_destroy_cb (XIC unused1, XPointer client_data, XPointer unused3)
116#else
109im_destroy_cb (XIM unused1, XPointer client_data, XPointer unused3) 117im_destroy_cb (XIM unused1, XPointer client_data, XPointer unused3)
118#endif
110{ 119{
111 rxvt_xim *xim = (rxvt_xim *)client_data; 120 rxvt_xim *xim = (rxvt_xim *)client_data;
112 rxvt_display *display = xim->display; 121 rxvt_display *display = xim->display;
113 122
114 display->xims.erase (find (display->xims.begin (), display->xims.end (), xim)); 123 display->xims.erase (find (display->xims.begin (), display->xims.end (), xim));
127 136
128 XIMCallback ximcallback; 137 XIMCallback ximcallback;
129 ximcallback.client_data = (XPointer)this; 138 ximcallback.client_data = (XPointer)this;
130 ximcallback.callback = im_destroy_cb; 139 ximcallback.callback = im_destroy_cb;
131 140
132 ((void (*)(XIM, ...)) XSetIMValues)
133 (xim, XNDestroyCallback, &ximcallback, NULL); 141 XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL);
134 142
135 return true; 143 return true;
136} 144}
137 145
138rxvt_xim::~rxvt_xim () 146rxvt_xim::~rxvt_xim ()
161 screen = DefaultScreen (display); 169 screen = DefaultScreen (display);
162 root = DefaultRootWindow (display); 170 root = DefaultRootWindow (display);
163 visual = DefaultVisual (display, screen); 171 visual = DefaultVisual (display, screen);
164 cmap = DefaultColormap (display, screen); 172 cmap = DefaultColormap (display, screen);
165 depth = DefaultDepth (display, screen); 173 depth = DefaultDepth (display, screen);
174
175 int fd = XConnectionNumber (display);
176
177#ifndef NO_SLOW_LINK_SUPPORT
178 // try to detetc wether we have a local connection.
179 // assume unix domains socket == local, everything else not
180 // TODO: might want to check for inet/127.0.0.1
181 is_local = 0;
182 sockaddr_un sa;
183 socklen_t sl = sizeof (sa);
184
185 if (!getsockname (fd, (sockaddr *)&sa, &sl))
186 is_local = sa.sun_family == AF_LOCAL;
187#endif
166 188
167#ifdef PREFER_24BIT 189#ifdef PREFER_24BIT
168 /* 190 /*
169 * If depth is not 24, look for a 24bit visual. 191 * If depth is not 24, look for a 24bit visual.
170 */ 192 */
181 visual, AllocNone); 203 visual, AllocNone);
182 } 204 }
183 } 205 }
184#endif 206#endif
185 207
186 int fd = XConnectionNumber (display);
187 x_ev.start (fd, EVENT_READ); 208 x_ev.start (fd, EVENT_READ);
188 fcntl (fd, F_SETFD, FD_CLOEXEC); 209 fcntl (fd, F_SETFD, FD_CLOEXEC);
189 210
190 XSelectInput (display, root, PropertyChangeMask); 211 XSelectInput (display, root, PropertyChangeMask);
191#ifdef USE_XIM 212#ifdef USE_XIM
244 265
245void rxvt_display::flush () 266void rxvt_display::flush ()
246{ 267{
247 for (;;) 268 for (;;)
248 { 269 {
249 XFlush (display);
250
251 if (!XPending (display)) 270 if (!XPending (display))
252 break; 271 break;
253 272
254 x_cb (x_ev, 0); 273 x_cb (x_ev, 0);
255 } 274 }
408#else 427#else
409 XFreeColors (display->display, display->cmap, &p, 1, AllPlanes); 428 XFreeColors (display->display, display->cmap, &p, 1, AllPlanes);
410#endif 429#endif
411} 430}
412 431
432rxvt_color
433rxvt_color::fade (rxvt_display *display, int percent)
434{
435 unsigned short cr, cg, cb;
436 rxvt_color faded;
437
438 get (display, cr, cg, cb);
439 faded.set (display,
440 cr * percent / 100,
441 cg * percent / 100,
442 cb * percent / 100);
443
444 return faded;
445}
446

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines