rxvt_display::rxvt_display (const char *id)
: refcounted (id)
-, x_watcher (this, &rxvt_display::x_event)
+, x_ev (this, &rxvt_display::x_cb)
, selection_owner (0)
{
}
#endif
int fd = XConnectionNumber (display);
- x_watcher.start (fd, EVENT_READ);
+ x_ev.start (fd, EVENT_READ);
fcntl (fd, F_SETFL, FD_CLOEXEC);
XSelectInput (display, root, PropertyChangeMask);
xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0);
+ flush ();
+
return true;
}
rxvt_display::~rxvt_display ()
{
- x_watcher.stop ();
+ x_ev.stop ();
XCloseDisplay (display);
}
(*i)->call ();
}
-void rxvt_display::x_event (io_watcher &w, short revents)
+void rxvt_display::x_cb (io_watcher &w, short revents)
{
do
{
}
}
while (XPending (display));
+
+ flush ();
+}
+
+void rxvt_display::flush ()
+{
+ for (;;)
+ {
+ XFlush (display);
+
+ if (!XPending (display))
+ break;
+
+ x_cb (x_ev, 0);
+ }
}
void rxvt_display::reg (xevent_watcher *w)
io_manager_vec<xevent_watcher> xw;
- io_watcher x_watcher; void x_event (io_watcher &w, short revents);
+ io_watcher x_ev; void x_cb (io_watcher &w, short revents);
refcache<rxvt_xim> xims;
vector<im_watcher *> imw;
bool init ();
~rxvt_display ();
+ void flush ();
+
void reg (xevent_watcher *w);
void unreg (xevent_watcher *w);
void reg (im_watcher *w);