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.12 by root, Mon Jan 17 00:59:24 2005 UTC vs.
Revision 1.19 by root, Mon Nov 28 19:04:39 2005 UTC

143{ 143{
144} 144}
145 145
146bool rxvt_display::init () 146bool rxvt_display::init ()
147{ 147{
148#ifdef LOCAL_X_IS_UNIX
149 if (id[0] == ':')
150 {
151 val = rxvt_malloc (5 + strlen (id) + 1);
152 strcpy (val, "unix/");
153 strcat (val, id);
154 display = XOpenDisplay (val);
155 free (val);
156 }
157 else
158#endif
159 display = 0;
160
161 if (!display)
148 display = XOpenDisplay (id); 162 display = XOpenDisplay (id);
149 163
150 if (!display) 164 if (!display)
151 return false; 165 return false;
152 166
153 screen = DefaultScreen (display); 167 screen = DefaultScreen (display);
157 depth = DefaultDepth (display, screen); 171 depth = DefaultDepth (display, screen);
158 172
159 int fd = XConnectionNumber (display); 173 int fd = XConnectionNumber (display);
160 174
161#ifndef NO_SLOW_LINK_SUPPORT 175#ifndef NO_SLOW_LINK_SUPPORT
162 // try to detetc wether we have a local connection. 176 // try to detect wether we have a local connection.
163 // assume unix domains socket == local, everything else not 177 // assume unix domains socket == local, everything else not
164 // TODO: might want to check for inet/127.0.0.1 178 // TODO: might want to check for inet/127.0.0.1
165 is_local = 0; 179 is_local = 0;
166 sockaddr_un sa; 180 sockaddr_un sa;
167 socklen_t sl = sizeof (sa); 181 socklen_t sl = sizeof (sa);
231 (*i)->call (); 245 (*i)->call ();
232} 246}
233 247
234void rxvt_display::im_change_check () 248void rxvt_display::im_change_check ()
235{ 249{
236 // make sure we only call im_change_cb when a new input method 250 // try to only call im_change_cb when a new input method
237 // registers, as xlib crashes due to a race otherwise. 251 // registers, as xlib crashes due to a race otherwise.
238 Atom actual_type, *atoms; 252 Atom actual_type, *atoms;
239 int actual_format; 253 int actual_format;
240 unsigned long nitems, bytes_after; 254 unsigned long nitems, bytes_after;
241 255
460} 474}
461 475
462rxvt_color 476rxvt_color
463rxvt_color::fade (rxvt_display *display, int percent) 477rxvt_color::fade (rxvt_display *display, int percent)
464{ 478{
479 percent = 100 - percent;
480
465 unsigned short cr, cg, cb; 481 unsigned short cr, cg, cb;
466 rxvt_color faded; 482 rxvt_color faded;
467 483
468 get (display, cr, cg, cb); 484 get (display, cr, cg, cb);
485
469 faded.set (display, 486 faded.set (
487 display,
470 cr * percent / 100, 488 cr * percent / 100,
471 cg * percent / 100, 489 cg * percent / 100,
472 cb * percent / 100); 490 cb * percent / 100
491 );
473 492
474 return faded; 493 return faded;
475} 494}
476 495
496#define LERP(a,b,p) (a * p + b * (100 - p)) / 100
497
498rxvt_color
499rxvt_color::fade (rxvt_display *display, int percent, rxvt_color &fadeto)
500{
501 percent = 100 - percent;
502
503 unsigned short cr, cg, cb;
504 unsigned short fcr, fcg, fcb;
505 rxvt_color faded;
506
507 get (display, cr, cg, cb);
508 fadeto.get(display, fcr, fcg, fcb);
509
510 faded.set (
511 display,
512 LERP (cr, fcr, percent),
513 LERP (cg, fcg, percent),
514 LERP (cb, fcb, percent)
515 );
516
517 return faded;
518}
519

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines