25 |
extern BOOL encryption; |
extern BOOL encryption; |
26 |
extern Display *display; |
extern Display *display; |
27 |
extern Window wnd; |
extern Window wnd; |
28 |
extern Time last_keyrelease; |
extern Time last_gesturetime; |
29 |
|
|
30 |
|
// static Time selection_timestamp; |
31 |
static Atom clipboard_atom, primary_atom, targets_atom, timestamp_atom; |
static Atom clipboard_atom, primary_atom, targets_atom, timestamp_atom; |
32 |
static Atom rdesktop_clipboard_target_atom; |
static Atom rdesktop_clipboard_target_atom; |
33 |
static cliprdr_dataformat *server_formats = NULL; |
static cliprdr_dataformat *server_formats = NULL; |
51 |
DEBUG_CLIPBOARD(("There were %d server formats.\n", i)); |
DEBUG_CLIPBOARD(("There were %d server formats.\n", i)); |
52 |
#endif |
#endif |
53 |
} |
} |
54 |
|
/* |
55 |
|
static void |
56 |
|
cliprdr_set_selection_timestamp(void) |
57 |
|
{ |
58 |
|
XEvent xev; |
59 |
|
DEBUG_CLIPBOARD(("Changing a property in order to get a timestamp\n")); |
60 |
|
fflush(stdout); |
61 |
|
XChangeProperty(display, wnd, rdesktop_clipboard_target_atom, |
62 |
|
XA_ATOM, 32, PropModeAppend, 0, 0); |
63 |
|
DEBUG_CLIPBOARD(("Waiting for PropertyChange on wnd\n")); |
64 |
|
fflush(stdout); |
65 |
|
XWindowEvent(display, wnd, |
66 |
|
PropertyChangeMask, &xev); |
67 |
|
DEBUG_CLIPBOARD(("Setting selection_timestamp\n")); |
68 |
|
fflush(stdout); |
69 |
|
selection_timestamp = xev.xproperty.time; |
70 |
|
} |
71 |
|
*/ |
72 |
|
|
73 |
static void |
static void |
74 |
cliprdr_send_format_announce(void) |
cliprdr_send_format_announce(void) |
75 |
{ |
{ |
76 |
|
DEBUG_CLIPBOARD(("Sending format announce\n")); |
77 |
|
|
78 |
STREAM s; |
STREAM s; |
79 |
int number_of_formats = 1; |
int number_of_formats = 1; |
80 |
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); |
210 |
s_mark_end(out); |
s_mark_end(out); |
211 |
|
|
212 |
sec_send_to_channel(out, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
sec_send_to_channel(out, encryption ? SEC_ENCRYPT : 0, 1005); // FIXME: Don't hardcode channel! |
213 |
|
|
214 |
|
cliprdr_send_format_announce(); |
215 |
|
|
216 |
} |
} |
217 |
|
|
225 |
cliprdr_send_format_announce(); |
cliprdr_send_format_announce(); |
226 |
} |
} |
227 |
|
|
|
void print_X_error(int res) |
|
|
{ |
|
|
switch(res) { |
|
|
case Success: |
|
|
DEBUG_CLIPBOARD(("Success\n")); |
|
|
break; |
|
|
|
|
|
case BadAtom: |
|
|
DEBUG_CLIPBOARD(("BadAtom\n")); |
|
|
break; |
|
|
|
|
|
case BadRequest: |
|
|
DEBUG_CLIPBOARD(("BadRequest\n")); |
|
|
break; |
|
|
|
|
|
case BadAlloc: |
|
|
DEBUG_CLIPBOARD(("BadAlloc\n")); |
|
|
break; |
|
|
|
|
|
case BadMatch: |
|
|
DEBUG_CLIPBOARD(("BadMatch\n")); |
|
|
break; |
|
|
|
|
|
case BadValue: |
|
|
DEBUG_CLIPBOARD(("BadValue\n")); |
|
|
break; |
|
|
|
|
|
case BadWindow: |
|
|
DEBUG_CLIPBOARD(("BadWindow\n")); |
|
|
break; |
|
|
|
|
|
default: |
|
|
DEBUG_CLIPBOARD(("Unknown X error code %d\n", res)); |
|
|
} |
|
|
} |
|
228 |
|
|
229 |
static void |
static void |
230 |
cliprdr_request_clipboard_data(uint32 formatcode) |
cliprdr_request_clipboard_data(uint32 formatcode) |
293 |
PropModeAppend, |
PropModeAppend, |
294 |
(unsigned char *)targets, |
(unsigned char *)targets, |
295 |
3); |
3); |
|
DEBUG_CLIPBOARD(("res after XChangeProperty is ")); |
|
|
print_X_error(res); |
|
296 |
|
|
297 |
res = XSendEvent(display, |
res = XSendEvent(display, |
298 |
xevent->requestor, |
xevent->requestor, |
303 |
} else if (timestamp_atom == xevent->target) |
} else if (timestamp_atom == xevent->target) |
304 |
{ |
{ |
305 |
DEBUG_CLIPBOARD(("TIMESTAMP requested... sending 0x%x\n", |
DEBUG_CLIPBOARD(("TIMESTAMP requested... sending 0x%x\n", |
306 |
(unsigned)last_keyrelease)); |
(unsigned)last_gesturetime)); |
307 |
res = XChangeProperty(display, |
res = XChangeProperty(display, |
308 |
xevent->requestor, |
xevent->requestor, |
309 |
xevent->property, |
xevent->property, |
310 |
XA_INTEGER, |
XA_INTEGER, |
311 |
32, |
32, |
312 |
PropModeAppend, |
PropModeAppend, |
313 |
(unsigned char *)&last_keyrelease, |
(unsigned char *)&last_gesturetime, |
314 |
1); |
1); |
315 |
res = XSendEvent(display, |
res = XSendEvent(display, |
316 |
xevent->requestor, |
xevent->requestor, |
393 |
static void |
static void |
394 |
cliprdr_select_X_clipboards(void) |
cliprdr_select_X_clipboards(void) |
395 |
{ |
{ |
396 |
XSetSelectionOwner(display, primary_atom, wnd, last_keyrelease); |
XSetSelectionOwner(display, primary_atom, wnd, last_gesturetime); |
397 |
if (wnd != XGetSelectionOwner(display, primary_atom)) |
if (wnd != XGetSelectionOwner(display, primary_atom)) |
398 |
{ |
{ |
399 |
warning("Failed to aquire ownership of PRIMARY clipboard\n"); |
warning("Failed to aquire ownership of PRIMARY clipboard\n"); |
400 |
} |
} |
401 |
XSetSelectionOwner(display, clipboard_atom, wnd, CurrentTime); |
XSetSelectionOwner(display, clipboard_atom, wnd, last_gesturetime); |
402 |
if (wnd != XGetSelectionOwner(display, clipboard_atom)) |
if (wnd != XGetSelectionOwner(display, clipboard_atom)) |
403 |
{ |
{ |
404 |
warning("Failed to aquire ownership of CLIPBOARD clipboard\n"); |
warning("Failed to aquire ownership of CLIPBOARD clipboard\n"); |
425 |
{ |
{ |
426 |
uint32 remaining_length; |
uint32 remaining_length; |
427 |
char *data; |
char *data; |
|
int res; |
|
428 |
in_uint32_le(s, remaining_length); |
in_uint32_le(s, remaining_length); |
429 |
data = s->p; |
data = s->p; |
430 |
res = XChangeProperty(display, |
XChangeProperty(display, |
431 |
selection_event.requestor, |
selection_event.requestor, |
432 |
selection_event.property, |
selection_event.property, |
433 |
XInternAtom(display, "STRING", False), |
XInternAtom(display, "STRING", False), |
434 |
8, |
8, |
435 |
PropModeAppend, |
PropModeAppend, |
436 |
data, |
data, |
437 |
remaining_length); |
remaining_length); |
438 |
|
|
439 |
DEBUG_CLIPBOARD(("res after XChangeProperty is ")); |
XSendEvent(display, |
440 |
print_X_error(res); |
selection_event.requestor, |
441 |
|
False, |
442 |
res = XSendEvent(display, |
NoEventMask, |
443 |
selection_event.requestor, |
(XEvent *)&selection_event); |
|
False, |
|
|
NoEventMask, |
|
|
(XEvent *)&selection_event); |
|
444 |
|
|
|
DEBUG_CLIPBOARD(("res after XSendEvent is ")); |
|
|
print_X_error(res); |
|
445 |
|
|
446 |
} |
} |
447 |
|
|