--- sourceforge.net/trunk/rdesktop/xclip.c 2006/03/27 10:41:22 1208 +++ sourceforge.net/trunk/rdesktop/xclip.c 2006/03/27 12:29:29 1211 @@ -114,6 +114,8 @@ /* Denotes that an rdesktop (not this rdesktop) is owning the selection, allowing us to interchange Windows native clipboard data directly. */ static int rdesktop_is_selection_owner = 0; +/* Time when we acquired the selection. */ +static Time acquire_time = 0; /* Denotes that an INCR ("chunked") transfer is in progress. */ static int g_waiting_for_INCR = 0; @@ -614,7 +616,7 @@ } else if (event->target == timestamp_atom) { - xclip_provide_selection(event, XA_INTEGER, 32, (uint8 *) & g_last_gesturetime, 1); + xclip_provide_selection(event, XA_INTEGER, 32, (uint8 *) & acquire_time, 1); return; } else @@ -798,7 +800,9 @@ void ui_clip_format_announce(uint8 * data, uint32 length) { - XSetSelectionOwner(g_display, primary_atom, g_wnd, g_last_gesturetime); + acquire_time = g_last_gesturetime; + + XSetSelectionOwner(g_display, primary_atom, g_wnd, acquire_time); if (XGetSelectionOwner(g_display, primary_atom) != g_wnd) { warning("Failed to aquire ownership of PRIMARY clipboard\n"); @@ -810,7 +814,7 @@ rdesktop_clipboard_formats_atom, XA_STRING, 8, PropModeReplace, data, length); - XSetSelectionOwner(g_display, clipboard_atom, g_wnd, g_last_gesturetime); + XSetSelectionOwner(g_display, clipboard_atom, g_wnd, acquire_time); if (XGetSelectionOwner(g_display, clipboard_atom) != g_wnd) warning("Failed to aquire ownership of CLIPBOARD clipboard\n"); } @@ -821,6 +825,13 @@ { BOOL free_data = False; + if (length == 0) + { + xclip_refuse_selection(&selection_request); + has_selection_request = False; + return; + } + if (selection_request.target == format_string_atom || selection_request.target == XA_STRING) { /* We're expecting a CF_TEXT response */ @@ -888,6 +899,13 @@ } void +ui_clip_request_failed() +{ + xclip_refuse_selection(&selection_request); + has_selection_request = False; +} + +void ui_clip_request_data(uint32 format) { Window primary_owner, clipboard_owner;