… | |
… | |
171 | depth = DefaultDepth (display, screen); |
171 | depth = DefaultDepth (display, screen); |
172 | |
172 | |
173 | int fd = XConnectionNumber (display); |
173 | int fd = XConnectionNumber (display); |
174 | |
174 | |
175 | #ifndef NO_SLOW_LINK_SUPPORT |
175 | #ifndef NO_SLOW_LINK_SUPPORT |
176 | // try to detetc wether we have a local connection. |
176 | // try to detect wether we have a local connection. |
177 | // assume unix domains socket == local, everything else not |
177 | // assume unix domains socket == local, everything else not |
178 | // TODO: might want to check for inet/127.0.0.1 |
178 | // TODO: might want to check for inet/127.0.0.1 |
179 | is_local = 0; |
179 | is_local = 0; |
180 | sockaddr_un sa; |
180 | sockaddr_un sa; |
181 | socklen_t sl = sizeof (sa); |
181 | socklen_t sl = sizeof (sa); |
… | |
… | |
227 | return true; |
227 | return true; |
228 | } |
228 | } |
229 | |
229 | |
230 | rxvt_display::~rxvt_display () |
230 | rxvt_display::~rxvt_display () |
231 | { |
231 | { |
|
|
232 | if (!display) |
|
|
233 | return; |
|
|
234 | |
|
|
235 | #ifdef POINTER_BLANK |
|
|
236 | XFreeCursor (display, blank_cursor); |
|
|
237 | #endif |
232 | x_ev.stop (); |
238 | x_ev.stop (); |
233 | #ifdef USE_XIM |
239 | #ifdef USE_XIM |
234 | xims.clear (); |
240 | xims.clear (); |
235 | #endif |
241 | #endif |
236 | |
|
|
237 | if (display) |
|
|
238 | XCloseDisplay (display); |
242 | XCloseDisplay (display); |
239 | } |
243 | } |
240 | |
244 | |
241 | #ifdef USE_XIM |
245 | #ifdef USE_XIM |
242 | void rxvt_display::im_change_cb () |
246 | void rxvt_display::im_change_cb () |
243 | { |
247 | { |
… | |
… | |
279 | XNextEvent (display, &xev); |
283 | XNextEvent (display, &xev); |
280 | |
284 | |
281 | #ifdef USE_XIM |
285 | #ifdef USE_XIM |
282 | if (!XFilterEvent (&xev, None)) |
286 | if (!XFilterEvent (&xev, None)) |
283 | { |
287 | { |
284 | |
|
|
285 | if (xev.type == PropertyNotify |
288 | if (xev.type == PropertyNotify |
286 | && xev.xany.window == root |
289 | && xev.xany.window == root |
287 | && xev.xproperty.atom == xa_xim_servers) |
290 | && xev.xproperty.atom == xa_xim_servers) |
288 | im_change_check (); |
291 | im_change_check (); |
289 | #endif |
292 | #endif |
… | |
… | |
474 | } |
477 | } |
475 | |
478 | |
476 | rxvt_color |
479 | rxvt_color |
477 | rxvt_color::fade (rxvt_display *display, int percent) |
480 | rxvt_color::fade (rxvt_display *display, int percent) |
478 | { |
481 | { |
|
|
482 | percent = 100 - percent; |
|
|
483 | |
479 | unsigned short cr, cg, cb; |
484 | unsigned short cr, cg, cb; |
480 | rxvt_color faded; |
485 | rxvt_color faded; |
481 | |
486 | |
482 | get (display, cr, cg, cb); |
487 | get (display, cr, cg, cb); |
|
|
488 | |
483 | faded.set (display, |
489 | faded.set ( |
|
|
490 | display, |
484 | cr * percent / 100, |
491 | cr * percent / 100, |
485 | cg * percent / 100, |
492 | cg * percent / 100, |
486 | cb * percent / 100); |
493 | cb * percent / 100 |
|
|
494 | ); |
487 | |
495 | |
488 | return faded; |
496 | return faded; |
489 | } |
497 | } |
490 | |
498 | |
|
|
499 | #define LERP(a,b,p) (a * p + b * (100 - p)) / 100 |
|
|
500 | |
|
|
501 | rxvt_color |
|
|
502 | rxvt_color::fade (rxvt_display *display, int percent, rxvt_color &fadeto) |
|
|
503 | { |
|
|
504 | percent = 100 - percent; |
|
|
505 | |
|
|
506 | unsigned short cr, cg, cb; |
|
|
507 | unsigned short fcr, fcg, fcb; |
|
|
508 | rxvt_color faded; |
|
|
509 | |
|
|
510 | get (display, cr, cg, cb); |
|
|
511 | fadeto.get(display, fcr, fcg, fcb); |
|
|
512 | |
|
|
513 | faded.set ( |
|
|
514 | display, |
|
|
515 | LERP (cr, fcr, percent), |
|
|
516 | LERP (cg, fcg, percent), |
|
|
517 | LERP (cb, fcb, percent) |
|
|
518 | ); |
|
|
519 | |
|
|
520 | return faded; |
|
|
521 | } |
|
|
522 | |