last_sendevent = time(0);
static void selection_request(XEvent *ev) {	XSelectionEvent notify_event;	XSelectionRequestEvent *req_event;	XErrorHandler old_handler;	unsigned int length;	unsigned char *data;#ifndef XA_LENGTH	unsigned long XA_LENGTH = XInternAtom(dpy, "LENGTH", True);#endif	req_event = &(ev->xselectionrequest);	notify_event.type 	= SelectionNotify;	notify_event.display	= req_event->display;	notify_event.requestor	= req_event->requestor;	notify_event.selection	= req_event->selection;	notify_event.target	= req_event->target;	notify_event.time	= req_event->time;	if (req_event->property == None) {		notify_event.property = req_event->target;	} else {		notify_event.property = req_event->property;	}	if (xcut_str) {		length = strlen(xcut_str);	} else {		length = 0;	}	/* the window may have gone away, so trap errors */	trapped_xerror = 0;	old_handler = XSetErrorHandler(trap_xerror);	if (ev->xselectionrequest.target == XA_LENGTH) {		/* length request */		XChangeProperty(ev->xselectionrequest.display,		    ev->xselectionrequest.requestor,		    ev->xselectionrequest.property,		    ev->xselectionrequest.target, 32, PropModeReplace,		    (unsigned char *) &length, sizeof(unsigned int));	} else {		/* data request */		data = (unsigned char *)xcut_str;		XChangeProperty(ev->xselectionrequest.display,		    ev->xselectionrequest.requestor,		    ev->xselectionrequest.property,		    ev->xselectionrequest.target, 8, PropModeReplace,		    data, length);	}	if (! trapped_xerror) {		XSendEvent(req_event->display, req_event->requestor, False, 0,		    (XEvent *)&notify_event);		last_sendevent = time(0);	} 	if (trapped_xerror) {		rfbLog("selection_request: ignored XError while sending "		    "PRIMARY selection to 0x%x.\n", req_event->requestor);	}	XSetErrorHandler(old_handler);	trapped_xerror = 0;	XFlush(dpy);}