--- rxvt-unicode/src/rxvtcolor.C 2004/02/11 08:13:45 1.6 +++ rxvt-unicode/src/rxvtcolor.C 2004/03/14 17:33:08 1.9 @@ -104,7 +104,7 @@ 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) { } @@ -113,6 +113,9 @@ { display = XOpenDisplay (id); + if (!display) + return false; + screen = DefaultScreen (display); root = DefaultRootWindow (display); visual = DefaultVisual (display, screen); @@ -139,20 +142,23 @@ #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); + if (display) + XCloseDisplay (display); } void rxvt_display::im_change_cb () @@ -161,7 +167,7 @@ (*i)->call (); } -void rxvt_display::x_event (io_watcher &w, short revents) +void rxvt_display::x_cb (io_watcher &w, short revents) { do { @@ -184,6 +190,21 @@ } } 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) @@ -324,7 +345,7 @@ #if XFT XftColorFree (display->display, display->visual, display->cmap, &c); #else - XFreeColors (display->display, display->cmap, &c, 1, AllPlanes); + XFreeColors (display->display, display->cmap, &p, 1, AllPlanes); #endif }