1 | /*----------------------------------------------------------------------* |
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-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2007 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. |
… | |
… | |
297 | |
297 | |
298 | rxvt_display::rxvt_display (const char *id) |
298 | rxvt_display::rxvt_display (const char *id) |
299 | : refcounted (id) |
299 | : refcounted (id) |
300 | , selection_owner (0) |
300 | , selection_owner (0) |
301 | { |
301 | { |
302 | x_ev.set<rxvt_display, &rxvt_display::x_cb> (this); |
302 | x_ev .set<rxvt_display, &rxvt_display::x_cb > (this); |
|
|
303 | flush_ev.set<rxvt_display, &rxvt_display::flush_cb> (this); |
303 | } |
304 | } |
304 | |
305 | |
305 | XrmDatabase |
306 | XrmDatabase |
306 | rxvt_display::get_resources (bool refresh) |
307 | rxvt_display::get_resources (bool refresh) |
307 | { |
308 | { |
… | |
… | |
471 | socklen_t sl = sizeof (sa); |
472 | socklen_t sl = sizeof (sa); |
472 | |
473 | |
473 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
474 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
474 | is_local = sa.sun_family == AF_UNIX; |
475 | is_local = sa.sun_family == AF_UNIX; |
475 | |
476 | |
|
|
477 | flush_ev.start (); |
476 | x_ev.start (fd, ev::READ); |
478 | x_ev.start (fd, ev::READ); |
477 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
479 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
478 | |
480 | |
479 | XSelectInput (dpy, root, PropertyChangeMask); |
481 | XSelectInput (dpy, root, PropertyChangeMask); |
480 | |
482 | |
… | |
… | |
499 | |
501 | |
500 | #ifdef POINTER_BLANK |
502 | #ifdef POINTER_BLANK |
501 | XFreeCursor (dpy, blank_cursor); |
503 | XFreeCursor (dpy, blank_cursor); |
502 | #endif |
504 | #endif |
503 | x_ev.stop (); |
505 | x_ev.stop (); |
|
|
506 | flush_ev.stop (); |
504 | #ifdef USE_XIM |
507 | #ifdef USE_XIM |
505 | xims.clear (); |
508 | xims.clear (); |
506 | #endif |
509 | #endif |
507 | XCloseDisplay (dpy); |
510 | XCloseDisplay (dpy); |
508 | } |
511 | } |
… | |
… | |
567 | } |
570 | } |
568 | #ifdef USE_XIM |
571 | #ifdef USE_XIM |
569 | } |
572 | } |
570 | #endif |
573 | #endif |
571 | } |
574 | } |
|
|
575 | } |
572 | |
576 | |
|
|
577 | void rxvt_display::flush_cb (ev::prepare &w, int revents) |
|
|
578 | { |
|
|
579 | w.stop (); |
573 | XFlush (dpy); |
580 | XFlush (dpy); |
574 | } |
|
|
575 | |
|
|
576 | void rxvt_display::flush () |
|
|
577 | { |
|
|
578 | x_cb (x_ev, ev::READ); |
|
|
579 | } |
581 | } |
580 | |
582 | |
581 | void rxvt_display::reg (xevent_watcher *w) |
583 | void rxvt_display::reg (xevent_watcher *w) |
582 | { |
584 | { |
583 | if (!w->active) |
585 | if (!w->active) |
… | |
… | |
597 | } |
599 | } |
598 | |
600 | |
599 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
601 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
600 | { |
602 | { |
601 | if (selection_owner && selection_owner != owner) |
603 | if (selection_owner && selection_owner != owner) |
|
|
604 | { |
|
|
605 | rxvt_term *owner = selection_owner; |
|
|
606 | |
602 | selection_owner->selection_clear (); |
607 | owner->selection_clear (); |
|
|
608 | owner->flush (); |
|
|
609 | } |
603 | |
610 | |
604 | selection_owner = owner; |
611 | selection_owner = owner; |
605 | } |
612 | } |
606 | |
613 | |
607 | #ifdef USE_XIM |
614 | #ifdef USE_XIM |