--- rxvt-unicode/src/rxvttoolkit.C 2007/12/14 02:22:24 1.81 +++ rxvt-unicode/src/rxvttoolkit.C 2007/12/24 08:21:39 1.87 @@ -299,7 +299,8 @@ : refcounted (id) , selection_owner (0) { - x_ev.set (this); + x_ev .set (this); + flush_ev.set (this); } XrmDatabase @@ -473,6 +474,7 @@ if (!getsockname (fd, (sockaddr *)&sa, &sl)) is_local = sa.sun_family == AF_UNIX; + flush_ev.start (); x_ev.start (fd, ev::READ); fcntl (fd, F_SETFD, FD_CLOEXEC); @@ -501,6 +503,7 @@ XFreeCursor (dpy, blank_cursor); #endif x_ev.stop (); + flush_ev.stop (); #ifdef USE_XIM xims.clear (); #endif @@ -569,13 +572,12 @@ } #endif } - - XFlush (dpy); } -void rxvt_display::flush () +void rxvt_display::flush_cb (ev::prepare &w, int revents) { - x_cb (x_ev, ev::READ); + w.stop (); + XFlush (dpy); } void rxvt_display::reg (xevent_watcher *w) @@ -599,7 +601,12 @@ void rxvt_display::set_selection_owner (rxvt_term *owner) { if (selection_owner && selection_owner != owner) - selection_owner->selection_clear (); + { + rxvt_term *owner = selection_owner; + + owner->selection_clear (); + owner->flush (); + } selection_owner = owner; }