--- sourceforge.net/trunk/rdesktop/cliprdr.c 2003/06/06 09:28:21 390 +++ sourceforge.net/trunk/rdesktop/cliprdr.c 2003/06/06 09:29:01 391 @@ -29,11 +29,12 @@ // static Time selection_timestamp; static Atom clipboard_atom, primary_atom, targets_atom, timestamp_atom; -static Atom rdesktop_clipboard_target_atom; +static Atom rdesktop_clipboard_target_atom, incr_atom; static cliprdr_dataformat *server_formats = NULL; static uint16 num_server_formats = 0; static XSelectionEvent selection_event; static uint16 clipboard_channelno; +static Atom targets[NUM_TARGETS]; static void cliprdr_print_server_formats(void) @@ -125,13 +126,16 @@ cliprdr_handle_SelectionNotify(XSelectionEvent *event) { - unsigned char *data; + unsigned char *data, *datap; unsigned long nitems, bytes_left; - int res; + + unsigned long bytes_left_to_transfer; + int res, i; int format; Atom type_return; Atom best_target; + Atom *supported_targets; STREAM out; @@ -171,6 +175,13 @@ { /* FIXME: We should choose format here based on what the server wanted */ + supported_targets = (Atom *)data; + for (i=0;i MAX_CLIPRDR_STANDALONE_DATASIZE) + { + DEBUG_CLIPBOARD(("Sending %d bytes of data\n", + 16+MAX_CLIPRDR_CONTINUATION_DATASIZE)); + out = sec_init(encryption ? SEC_ENCRYPT : 0, + 8+MAX_CLIPRDR_CONTINUATION_DATASIZE); + out_uint32_le(out, nitems); + out_uint32_le(out, 0x10); + out_uint8p(out, datap, + MAX_CLIPRDR_CONTINUATION_DATASIZE); + s_mark_end(out); + + sec_send_to_channel(out, + encryption ? SEC_ENCRYPT : 0, + clipboard_channelno); + bytes_left_to_transfer-= MAX_CLIPRDR_CONTINUATION_DATASIZE; + datap+=MAX_CLIPRDR_CONTINUATION_DATASIZE; + + } + DEBUG_CLIPBOARD(("Sending %d bytes of data\n", + 12+bytes_left_to_transfer)); + out = sec_init(encryption ? SEC_ENCRYPT : 0, + 12+bytes_left_to_transfer); + out_uint32_le(out, nitems); + out_uint32_le(out, 0x12); + out_uint8p(out, datap, + bytes_left_to_transfer); + out_uint32_le(out, 0x0); + s_mark_end(out); + + sec_send_to_channel(out, encryption ? SEC_ENCRYPT : 0, + clipboard_channelno); + + } + + + XFree(data); cliprdr_send_format_announce(); } @@ -254,9 +342,6 @@ cliprdr_handle_SelectionRequest(XSelectionRequestEvent *xevent) { - Atom *targets; - int res; - XSelectionEvent xev; DEBUG_CLIPBOARD(("cliprdr_handle_SelectionRequest\n")); DEBUG_CLIPBOARD(("Requestor window id 0x%x ", @@ -285,43 +370,36 @@ if (targets_atom == xevent->target) { DEBUG_CLIPBOARD(("TARGETS requested, sending list..\n")); - targets = xmalloc(4*sizeof(Atom)); - targets[0] = xevent->target; - targets[1] = XInternAtom(display, "TEXT", True); - targets[2] = XInternAtom(display, "UTF8_STRING", True); - targets[3] = XInternAtom(display, "TIMESTAMP", True); - res = XChangeProperty(display, - xevent->requestor, - xevent->property, - XA_ATOM, - 32, - PropModeAppend, - (unsigned char *)targets, - 3); - - res = XSendEvent(display, - xevent->requestor, - False, - NoEventMask, - (XEvent *)&xev); + XChangeProperty(display, + xevent->requestor, + xevent->property, + XA_ATOM, + 32, + PropModeAppend, + (unsigned char *)&targets, + NUM_TARGETS); + + XSendEvent(display, + xevent->requestor, + False, + NoEventMask, + (XEvent *)&xev); return; } else if (timestamp_atom == xevent->target) { - DEBUG_CLIPBOARD(("TIMESTAMP requested... sending 0x%x\n", - (unsigned)last_gesturetime)); - res = XChangeProperty(display, - xevent->requestor, - xevent->property, - XA_INTEGER, - 32, - PropModeAppend, - (unsigned char *)&last_gesturetime, - 1); - res = XSendEvent(display, - xevent->requestor, - False, - NoEventMask, - (XEvent *)&xev); + XChangeProperty(display, + xevent->requestor, + xevent->property, + XA_INTEGER, + 32, + PropModeAppend, + (unsigned char *)&last_gesturetime, + 1); + XSendEvent(display, + xevent->requestor, + False, + NoEventMask, + (XEvent *)&xev); } else /* Some other target */ { cliprdr_request_clipboard_data(CF_TEXT); @@ -571,4 +649,12 @@ targets_atom = XInternAtom(display, "TARGETS", False); timestamp_atom = XInternAtom(display, "TIMESTAMP", False); rdesktop_clipboard_target_atom = XInternAtom(display, "_RDESKTOP_CLIPBOARD_TARGET", False); + incr_atom = XInternAtom(display, "INCR", False); + targets[0] = targets_atom; + targets[1] = XInternAtom(display, "TEXT", False); + targets[2] = XInternAtom(display, "UTF8_STRING", False); + targets[3] = XInternAtom(display, "text/unicode", False); + targets[4] = XInternAtom(display, "TIMESTAMP", False); + targets[5] = XInternAtom(display, "STRING", False); + }