static void GrRequestClientDataWrapper(void *r) { nxRequestClientDataReq *req = r; GrRequestClientData(req->wid, req->rid, req->serial, req->mimetype); }
int main(int argc, char *argv[]) { GR_CHAR *typelist, *p; GR_WINDOW_ID sid, wid; GR_EVENT event; int n = 0, mimetype = -1; if(GrOpen() < 0) { fprintf(stderr, "Couldn't connect to Nano-X server\n"); return 1; } sid = GrGetSelectionOwner(&typelist); if(!sid) { fprintf(stderr, "Clipboard is empty\n"); return 2; } if(!typelist) { fprintf(stderr, "GrGetSelectionOwner() returned an empty " "type list for window %d\n", sid); return 3; } fprintf(stderr, "Window %d owns the selection\n", sid); fprintf(stderr, "It claims to be able to supply data in the following " "types:\n%s\n", typelist); p = strtok(typelist, " "); do { if(!strncmp("text/plain", p, 10)) { mimetype = n; break; } n++; } while((p = strtok(NULL, " "))); if(mimetype == -1) { fprintf(stderr, "Type text/plain is not available\n"); return 4; } free(typelist); fprintf(stderr, "Type text/plain is available- requesting data\n"); wid = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, 1, 1, 0, 0, 0); if(!wid) { fprintf(stderr, "Couldn't get a window\n"); return 5; } GrSelectEvents(wid, GR_EVENT_MASK_CLIENT_DATA); GrRequestClientData(wid, sid, 0, mimetype); while(1) { GrGetNextEventTimeout(&event, 4000); switch(event.type) { case GR_EVENT_TYPE_CLIENT_DATA: if(got_client_data(&event)) return 0; break; case GR_EVENT_TYPE_TIMEOUT: fprintf(stderr, "Timed out waiting for data\n"); return 6; default: break; } } return 0; }