20 |
|
|
21 |
#include <X11/Xlib.h> |
#include <X11/Xlib.h> |
22 |
#include <X11/Xatom.h> |
#include <X11/Xatom.h> |
23 |
|
#include <sys/time.h> |
24 |
|
#include <sys/types.h> |
25 |
|
#include <unistd.h> |
26 |
#include "rdesktop.h" |
#include "rdesktop.h" |
27 |
|
|
28 |
extern BOOL encryption; |
extern BOOL encryption; |
83 |
cliprdr_send_format_announce(void) |
cliprdr_send_format_announce(void) |
84 |
{ |
{ |
85 |
STREAM s; |
STREAM s; |
|
|
|
|
DEBUG_CLIPBOARD(("Sending (empty) format announce\n")); |
|
86 |
int number_of_formats = 1; |
int number_of_formats = 1; |
87 |
|
DEBUG_CLIPBOARD(("Sending (empty) format announce\n")); |
88 |
s = sec_init(encryption ? SEC_ENCRYPT : 0, number_of_formats * 36 + 12 + 4 + 4); |
s = sec_init(encryption ? SEC_ENCRYPT : 0, number_of_formats * 36 + 12 + 4 + 4); |
89 |
out_uint32_le(s, number_of_formats * 36 + 12); |
out_uint32_le(s, number_of_formats * 36 + 12); |
90 |
out_uint32_le(s, 0x13); |
out_uint32_le(s, 0x13); |
159 |
|
|
160 |
int format; |
int format; |
161 |
Atom type_return; |
Atom type_return; |
162 |
Atom best_target; |
Atom best_target, text_target; |
163 |
Atom *supported_targets; |
Atom *supported_targets; |
164 |
|
|
165 |
STREAM out; |
STREAM out; |
202 |
/* FIXME: We should choose format here based |
/* FIXME: We should choose format here based |
203 |
on what the server wanted */ |
on what the server wanted */ |
204 |
supported_targets = (Atom *) data; |
supported_targets = (Atom *) data; |
205 |
|
best_target = XInternAtom(display, "STRING", False); |
206 |
|
text_target = XInternAtom(display, "TEXT", False); |
207 |
for (i = 0; i < nitems; i++) |
for (i = 0; i < nitems; i++) |
208 |
{ |
{ |
209 |
DEBUG_CLIPBOARD(("Target %d: %s\n", |
DEBUG_CLIPBOARD(("Target %d: %s\n", |
210 |
i, XGetAtomName(display, supported_targets[i]))); |
i, XGetAtomName(display, supported_targets[i]))); |
211 |
|
if (text_target == supported_targets[i]) |
212 |
|
{ |
213 |
|
DEBUG_CLIPBOARD(("Other party supports TEXT, choosing that as best_target\n")); |
214 |
|
best_target = supported_targets[i]; |
215 |
|
} |
216 |
} |
} |
217 |
best_target = XInternAtom(display, "TEXT", False); |
|
218 |
|
|
219 |
|
|
220 |
} |
} |
320 |
|
|
321 |
|
|
322 |
XFree(data); |
XFree(data); |
323 |
if (!rdesktop_clipboard_target_atom) |
if (!rdesktop_is_selection_owner) |
324 |
cliprdr_send_format_announce(); |
cliprdr_send_format_announce(); |
325 |
|
|
326 |
} |
} |
643 |
} |
} |
644 |
else |
else |
645 |
{ |
{ |
|
DEBUG_CLIPBOARD(("There were no owner for PRIMARY, sending empty string\n")); // FIXME: Should we always send an empty string? |
|
646 |
|
|
647 |
cliprdr_send_empty_datapacket(); |
selectionowner = XGetSelectionOwner(display, clipboard_atom); |
648 |
|
if (None != selectionowner) |
649 |
|
{ |
650 |
|
XConvertSelection(display, clipboard_atom, |
651 |
|
targets_atom, |
652 |
|
rdesktop_clipboard_target_atom, wnd, CurrentTime); |
653 |
|
|
654 |
|
/* The rest of the transfer is handled in |
655 |
|
cliprdr_handle_SelectionNotify */ |
656 |
|
|
657 |
|
} |
658 |
|
else |
659 |
|
{ |
660 |
|
|
661 |
|
DEBUG_CLIPBOARD(("There were no owner for PRIMARY nor CLIPBOARD, sending empty string\n")); // FIXME: Should we always send an empty string? |
662 |
|
|
663 |
|
cliprdr_send_empty_datapacket(); |
664 |
|
} |
665 |
} |
} |
666 |
|
|
667 |
|
|