CVS: rdesktop xclip.c,1.14,1.15
Peter Åstrand <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15099
Modified Files:
xclip.c
Log Message:
Support the clipboard INCR protocol: Applied patch from Burt Holzman.
Index: xclip.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xclip.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** xclip.c 4 Jun 2004 08:42:11 -0000 1.14
--- xclip.c 27 Jun 2005 12:18:48 -0000 1.15
***************
*** 37,40 ****
--- 37,43 ----
static int rdesktop_is_selection_owner = 0;
+ static int g_waiting_for_INCR = 0;
+ static uint8 *g_clip_buffer = 0;
+ static uint32 g_clip_buflen = 0;
/* Replace CR-LF to LF (well, rather removing all CR:s) This is done
***************
*** 106,109 ****
--- 109,113 ----
{
unsigned long nitems, bytes_left;
+ XWindowAttributes wa;
Atom type, best_target, text_target;
Atom *supported_targets;
***************
*** 162,167 ****
if (type == incr_atom)
{
! warning("We don't support INCR transfers at this time. Try cutting less data.\n");
! goto fail;
}
--- 166,202 ----
if (type == incr_atom)
{
! DEBUG_CLIPBOARD(("Received INCR.\n"));
!
! XGetWindowAttributes(g_display, g_wnd, &wa);
! if ((wa.your_event_mask | PropertyChangeMask) != wa.your_event_mask)
! {
! XSelectInput(g_display, g_wnd, (wa.your_event_mask | PropertyChangeMask));
! }
! XDeleteProperty(g_display, g_wnd, type);
! XFree(data);
! g_waiting_for_INCR = 1;
!
! if ((XGetWindowProperty(g_display, g_wnd, rdesktop_clipboard_target_atom, 0,
! 4096L, True, AnyPropertyType,
! &type, &format, &nitems, &bytes_left, &data) != Success))
! {
! DEBUG_CLIPBOARD(("XGetWindowProperty failed.\n"));
! goto fail;
! }
! else
! {
! uint8 *translated_data;
! uint32 length = nitems;
!
! translated_data = lf2crlf(data, &length);
!
! g_clip_buffer = (uint8 *) xmalloc(length);
! strncpy(g_clip_buffer, translated_data, length);
! xfree(translated_data);
! g_clip_buflen = length;
!
! XFree(data);
! return;
! }
}
***************
*** 249,255 ****
--- 284,344 ----
unsigned long nitems, bytes_left;
int format, res;
+ XWindowAttributes wa;
uint8 *data;
Atom type;
+ if (event->state == PropertyNewValue && g_waiting_for_INCR)
+ {
+ DEBUG_CLIPBOARD(("x_clip_handle_PropertyNotify: g_waiting_for_INCR != 0\n"));
+ if ((XGetWindowProperty(g_display, g_wnd, rdesktop_clipboard_target_atom, 0,
+ 4096L, True, AnyPropertyType,
+ &type, &format, &nitems, &bytes_left, &data) != Success))
+ {
+ XFree(data);
+ return;
+ }
+
+ if (nitems == 0)
+ {
+ XGetWindowAttributes(g_display, g_wnd, &wa);
+ XSelectInput(g_display, g_wnd, (wa.your_event_mask ^ PropertyChangeMask));
+ XFree(data);
+ g_waiting_for_INCR = 0;
+
+ if (g_clip_buflen > 0)
+ {
+ cliprdr_send_data(g_clip_buffer, g_clip_buflen + 1);
+
+ if (!rdesktop_is_selection_owner)
+ cliprdr_send_text_format_announce();
+
+ xfree(g_clip_buffer);
+ g_clip_buffer = 0;
+ g_clip_buflen = 0;
+ }
+ }
+ else
+ {
+ uint8 *translated_data;
+ uint32 length = nitems;
+
+ DEBUG_CLIPBOARD(("Translating linebreaks before sending data\n"));
+ translated_data = lf2crlf(data, &length);
+
+ uint8 *tmp = xmalloc(length + g_clip_buflen);
+ strncpy(tmp, g_clip_buffer, g_clip_buflen);
+ xfree(g_clip_buffer);
+
+ strncpy(tmp + g_clip_buflen, translated_data, length);
+ xfree(translated_data);
+
+ g_clip_buffer = tmp;
+ g_clip_buflen += length;
+
+ XFree(data);
+ return;
+ }
+ }
+
if (event->atom != rdesktop_clipboard_formats_atom)
return;
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click