419 unsigned long nitems, bytes_left;
420 XWindowAttributes wa;
422 Atom *supported_targets;
429 DEBUG_CLIPBOARD((
"xclip_handle_SelectionNotify: selection=%s, target=%s, property=%s\n",
430 XGetAtomName(
This->display,
event->selection),
431 XGetAtomName(
This->display,
event->target),
432 XGetAtomName(
This->display,
event->property)));
434 if (
event->target ==
This->xclip.timestamp_atom)
436 if (
event->selection ==
This->xclip.primary_atom)
439 This->xclip.rdesktop_primary_timestamp_target_atom, 0,
440 XMaxRequestSize(
This->display),
False, AnyPropertyType,
446 This->xclip.rdesktop_clipboard_timestamp_target_atom, 0,
447 XMaxRequestSize(
This->display),
False, AnyPropertyType,
458 if (
event->selection ==
This->xclip.primary_atom)
461 if (
This->xclip.primary_timestamp == 0)
462 This->xclip.primary_timestamp++;
463 XDeleteProperty(
This->display,
This->wnd,
This->xclip.rdesktop_primary_timestamp_target_atom);
465 (
unsigned)
This->xclip.primary_timestamp));
470 if (
This->xclip.clipboard_timestamp == 0)
471 This->xclip.clipboard_timestamp++;
472 XDeleteProperty(
This->display,
This->wnd,
This->xclip.rdesktop_clipboard_timestamp_target_atom);
474 (
unsigned)
This->xclip.clipboard_timestamp));
479 if (
This->xclip.primary_timestamp &&
This->xclip.clipboard_timestamp)
481 if (
This->xclip.primary_timestamp >
This->xclip.clipboard_timestamp)
484 XConvertSelection(
This->display,
This->xclip.primary_atom,
This->xclip.targets_atom,
485 This->xclip.rdesktop_clipboard_target_atom,
This->wnd,
491 XConvertSelection(
This->display,
This->xclip.clipboard_atom,
This->xclip.targets_atom,
492 This->xclip.rdesktop_clipboard_target_atom,
This->wnd,
500 if (
This->xclip.probing_selections &&
This->xclip.reprobe_selections)
507 res = XGetWindowProperty(
This->display,
This->wnd,
This->xclip.rdesktop_clipboard_target_atom,
508 0, XMaxRequestSize(
This->display),
False, AnyPropertyType,
523 XGetWindowAttributes(
This->display,
This->wnd, &wa);
524 if ((wa.your_event_mask | PropertyChangeMask) != wa.your_event_mask)
526 XSelectInput(
This->display,
This->wnd, (wa.your_event_mask | PropertyChangeMask));
529 This->xclip.incr_target =
event->target;
530 This->xclip.waiting_for_INCR = 1;
535 if (
event->target ==
This->xclip.targets_atom)
541 int text_target_satisfaction = 0;
542 Atom best_text_target = 0;
546 for (
i = 0;
i < nitems;
i++)
549 XGetAtomName(
This->display, supported_targets[
i])));
550 if (supported_targets[
i] ==
This->xclip.format_string_atom)
552 if (text_target_satisfaction < 1)
554 DEBUG_CLIPBOARD((
"Other party supports STRING, choosing that as best_target\n"));
555 best_text_target = supported_targets[
i];
556 text_target_satisfaction = 1;
559 #ifdef USE_UNICODE_CLIPBOARD 560 else if (supported_targets[
i] ==
This->xclip.format_unicode_atom)
562 if (text_target_satisfaction < 2)
564 DEBUG_CLIPBOARD((
"Other party supports text/unicode, choosing that as best_target\n"));
565 best_text_target = supported_targets[
i];
566 text_target_satisfaction = 2;
569 else if (supported_targets[
i] ==
This->xclip.format_utf8_string_atom)
571 if (text_target_satisfaction < 3)
573 DEBUG_CLIPBOARD((
"Other party supports UTF8_STRING, choosing that as best_target\n"));
574 best_text_target = supported_targets[
i];
575 text_target_satisfaction = 3;
579 else if (supported_targets[
i] ==
This->xclip.rdesktop_clipboard_formats_atom)
581 if (
This->xclip.probing_selections && (text_target_satisfaction < 4))
583 DEBUG_CLIPBOARD((
"Other party supports native formats, choosing that as best_target\n"));
584 best_text_target = supported_targets[
i];
585 text_target_satisfaction = 4;
594 if ((best_text_target != 0)
595 && (!
This->xclip.probing_selections
596 || (best_text_target ==
This->xclip.rdesktop_clipboard_formats_atom)))
598 XConvertSelection(
This->display,
event->selection, best_text_target,
599 This->xclip.rdesktop_clipboard_target_atom,
This->wnd,
event->time);
604 DEBUG_CLIPBOARD((
"Unable to find a textual target to satisfy RDP clipboard text request\n"));
610 if (
This->xclip.probing_selections)
612 Window primary_owner, clipboard_owner;
620 clipboard_owner = XGetSelectionOwner(
This->display,
This->xclip.clipboard_atom);
622 if (
This->xclip.auto_mode)
623 primary_owner = XGetSelectionOwner(
This->display,
This->xclip.primary_atom);
625 primary_owner = clipboard_owner;
627 if (primary_owner != clipboard_owner)
632 This->xclip.rdesktop_is_selection_owner =
True;
649 if (
This->xclip.probing_selections)
651 DEBUG_CLIPBOARD((
"Unable to find suitable target. Using default text format.\n"));
653 This->xclip.rdesktop_is_selection_owner =
False;
static void xclip_probe_selections(RDPCLIENT *This)
static void xclip_clear_target_props(RDPCLIENT *This)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
static void helper_cliprdr_send_empty_response(RDPCLIENT *This)
void cliprdr_send_native_format_announce(uint8 *formats_data, uint32 formats_data_length)
#define DEBUG_CLIPBOARD(args)
static Bool xclip_send_data_with_convert(RDPCLIENT *This, uint8 *source, size_t source_size, Atom target)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
void cliprdr_send_simple_native_format_announce(uint32 format)
GLuint GLuint GLsizei GLenum type
static PLARGE_INTEGER Time