Qt 4.8
qxlibclipboard.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qxlibclipboard.h"
43 
44 #include "qxlibscreen.h"
45 #include "qxlibmime.h"
46 #include "qxlibdisplay.h"
47 
48 #include <private/qapplication_p.h>
49 
50 #include <QtCore/QDebug>
51 
53 {
54  Q_OBJECT
55 public:
57  : QXlibMime()
58  , m_clipboard(clipboard)
59  {
60  switch (mode) {
62  modeAtom = XA_PRIMARY;
63  break;
64 
67  break;
68 
69  default:
70  qWarning("QTestLiteMime: Internal error: Unsupported clipboard mode");
71  break;
72  }
73  }
74 
75 protected:
77  {
78  if (empty())
79  return QStringList();
80 
81  if (!formatList.count()) {
82  QXlibClipboardMime *that = const_cast<QXlibClipboardMime *>(this);
83  // get the list of targets from the current clipboard owner - we do this
84  // once so that multiple calls to this function don't require multiple
85  // server round trips...
87 
88  if (format_atoms.size() > 0) {
89  Atom *targets = (Atom *) format_atoms.data();
90  int size = format_atoms.size() / sizeof(Atom);
91 
92  for (int i = 0; i < size; ++i) {
93  if (targets[i] == 0)
94  continue;
95 
96  QStringList formatsForAtom = mimeFormatsForAtom(m_clipboard->screen()->display()->nativeDisplay(),targets[i]);
97  for (int j = 0; j < formatsForAtom.size(); ++j) {
98  if (!formatList.contains(formatsForAtom.at(j)))
99  that->formatList.append(formatsForAtom.at(j));
100  }
101  }
102  }
103  }
104 
105  return formatList;
106  }
107 
108  bool hasFormat_sys(const QString &format) const
109  {
110  QStringList list = formats();
111  return list.contains(format);
112  }
113 
114  QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const
115  {
116  if (fmt.isEmpty() || empty())
117  return QByteArray();
118 
119  (void)formats(); // trigger update of format list
120 
121  QList<Atom> atoms;
122  Atom *targets = (Atom *) format_atoms.data();
123  int size = format_atoms.size() / sizeof(Atom);
124  for (int i = 0; i < size; ++i)
125  atoms.append(targets[i]);
126 
127  QByteArray encoding;
128  Atom fmtatom = mimeAtomForFormat(m_clipboard->screen()->display()->nativeDisplay(),fmt, requestedType, atoms, &encoding);
129 
130  if (fmtatom == 0)
131  return QVariant();
132 
133  return mimeConvertToFormat(m_clipboard->screen()->display()->nativeDisplay(),fmtatom, m_clipboard->getDataInFormat(modeAtom,fmtatom), fmt, requestedType, encoding);
134  }
135 private:
136  bool empty() const
137  {
138  Window win = XGetSelectionOwner(m_clipboard->screen()->display()->nativeDisplay(), modeAtom);
139 
140  return win == XNone;
141  }
142 
143 
148 };
149 
150 const int QXlibClipboard::clipboard_timeout = 5000;
151 
154  , m_screen(screen)
155  , m_xClipboard(0)
156  , m_clientClipboard(0)
157  , m_xSelection(0)
158  , m_clientSelection(0)
159  , m_requestor(XNone)
160  , m_owner(XNone)
161 {
162 }
163 
165 {
166  if (mode == QClipboard::Clipboard) {
167  if (!m_xClipboard) {
168  m_xClipboard = new QXlibClipboardMime(mode, this);
169  }
170  Window clipboardOwner = XGetSelectionOwner(screen()->display()->nativeDisplay(),QXlibStatic::atom(QXlibStatic::CLIPBOARD));
171  if (clipboardOwner == owner()) {
172  return m_clientClipboard;
173  } else {
174  return m_xClipboard;
175  }
176  } else if (mode == QClipboard::Selection) {
177  if (!m_xSelection) {
178  m_xSelection = new QXlibClipboardMime(mode, this);
179  }
180  Window clipboardOwner = XGetSelectionOwner(screen()->display()->nativeDisplay(),XA_PRIMARY);
181  if (clipboardOwner == owner()) {
182  return m_clientSelection;
183  } else {
184  return m_xSelection;
185  }
186  }
187  return 0;
188 }
189 
191 {
192  Atom modeAtom;
193  QMimeData **d;
194  switch (mode) {
196  modeAtom = XA_PRIMARY;
197  d = &m_clientSelection;
198  break;
199 
202  d = &m_clientClipboard;
203  break;
204 
205  default:
206  qWarning("QClipboard::setMimeData: unsupported mode '%d'", mode);
207  return;
208  }
209 
210  Window newOwner;
211 
212  if (! data) { // no data, clear clipboard contents
213  newOwner = XNone;
214  } else {
215  newOwner = owner();
216 
217  *d = data;
218  }
219 
220  XSetSelectionOwner(m_screen->display()->nativeDisplay(), modeAtom, newOwner, CurrentTime);
221 
222  if (XGetSelectionOwner(m_screen->display()->nativeDisplay(), modeAtom) != newOwner) {
223  qWarning("QClipboard::setData: Cannot set X11 selection owner");
224  }
225 
226 }
227 
229 {
230  if (mode == QClipboard::Clipboard || mode == QClipboard::Selection)
231  return true;
232  return false;
233 }
234 
235 
237 {
238  return m_screen;
239 }
240 
242 {
243  if (!m_requestor) {
244  int x = 0, y = 0, w = 3, h = 3;
245  QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
246  Window window = XCreateSimpleWindow(m_screen->display()->nativeDisplay(), m_screen->rootWindow(),
247  x, y, w, h, 0 /*border_width*/,
249  that->setRequestor(window);
250  }
251  return m_requestor;
252 }
253 
255 {
256  if (m_requestor != XNone) {
257  XDestroyWindow(m_screen->display()->nativeDisplay(),m_requestor);
258  }
260 }
261 
263 {
264  if (!m_owner) {
265  int x = 0, y = 0, w = 3, h = 3;
266  QXlibClipboard *that = const_cast<QXlibClipboard *>(this);
267  Window window = XCreateSimpleWindow(m_screen->display()->nativeDisplay(), m_screen->rootWindow(),
268  x, y, w, h, 0 /*border_width*/,
270  that->setOwner(window);
271  }
272  return m_owner;
273 }
274 
276 {
277  if (m_owner != XNone){
278  XDestroyWindow(m_screen->display()->nativeDisplay(),m_owner);
279  }
280  m_owner = window;
281 }
282 
284 {
287  for (int i = 0; i < formats.size(); ++i) {
289  for (int j = 0; j < atoms.size(); ++j) {
290  if (!types.contains(atoms.at(j)))
291  types.append(atoms.at(j));
292  }
293  }
298 
299  XChangeProperty(screen()->display()->nativeDisplay(), window, property, XA_ATOM, 32,
300  PropModeReplace, (uchar *) types.data(), types.size());
301  return property;
302 }
303 
305 {
306  Atom atomFormat = target;
307  int dataFormat = 0;
309 
311  if (fmt.isEmpty()) { // Not a MIME type we have
312  qDebug() << "QClipboard: send_selection(): converting to type '%s' is not supported" << fmt.data();
313  return XNone;
314  }
315  qDebug() << "QClipboard: send_selection(): converting to type '%s'" << fmt.data();
316 
317  if (QXlibMime::mimeDataForAtom(screen()->display()->nativeDisplay(),target, d, &data, &atomFormat, &dataFormat)) {
318 
319  // don't allow INCR transfers when using MULTIPLE or to
320  // Motif clients (since Motif doesn't support INCR)
321  static Atom motif_clip_temporary = QXlibStatic::atom(QXlibStatic::CLIP_TEMPORARY);
322  bool allow_incr = property != motif_clip_temporary;
323 
324  // X_ChangeProperty protocol request is 24 bytes
325  const int increment = (XMaxRequestSize(screen()->display()->nativeDisplay()) * 4) - 24;
326  if (data.size() > increment && allow_incr) {
327  long bytes = data.size();
328  XChangeProperty(screen()->display()->nativeDisplay(), window, property,
329  QXlibStatic::atom(QXlibStatic::INCR), 32, PropModeReplace, (uchar *) &bytes, 1);
330 
331 // (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
332  qDebug() << "not implemented INCRT just YET!";
333  return property;
334  }
335 
336  // make sure we can perform the XChangeProperty in a single request
337  if (data.size() > increment)
338  return XNone; // ### perhaps use several XChangeProperty calls w/ PropModeAppend?
339  int dataSize = data.size() / (dataFormat / 8);
340  // use a single request to transfer data
341  XChangeProperty(screen()->display()->nativeDisplay(), window, property, atomFormat,
342  dataFormat, PropModeReplace, (uchar *) data.data(),
343  dataSize);
344  }
345  return property;
346 }
347 
349 {
350  XSelectionRequestEvent *req = &xevent->xselectionrequest;
351 
352  if (requestor() && req->requestor == requestor()) {
353  qDebug() << "This should be caught before";
354  return;
355  }
356 
357  XEvent event;
358  event.xselection.type = SelectionNotify;
359  event.xselection.display = req->display;
360  event.xselection.requestor = req->requestor;
361  event.xselection.selection = req->selection;
362  event.xselection.target = req->target;
363  event.xselection.property = XNone;
364  event.xselection.time = req->time;
365 
366  QMimeData *d;
367  if (req->selection == XA_PRIMARY) {
368  d = m_clientSelection;
369  } else if (req->selection == QXlibStatic::atom(QXlibStatic::CLIPBOARD)) {
370  d = m_clientClipboard;
371  } else {
372  qWarning("QClipboard: Unknown selection '%lx'", req->selection);
373  XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
374  return;
375  }
376 
377  if (!d) {
378  qWarning("QClipboard: Cannot transfer data, no data available");
379  XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
380  return;
381  }
382 
386 
387  struct AtomPair { Atom target; Atom property; } *multi = 0;
388  Atom multi_type = XNone;
389  int multi_format = 0;
390  int nmulti = 0;
391  int imulti = -1;
392  bool multi_writeback = false;
393 
394  if (req->target == xa_multiple) {
395  QByteArray multi_data;
396  if (req->property == XNone
397  || !clipboardReadProperty(req->requestor, req->property, false, &multi_data,
398  0, &multi_type, &multi_format)
399  || multi_format != 32) {
400  // MULTIPLE property not formatted correctly
401  XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
402  return;
403  }
404  nmulti = multi_data.size()/sizeof(*multi);
405  multi = new AtomPair[nmulti];
406  memcpy(multi,multi_data.data(),multi_data.size());
407  imulti = 0;
408  }
409 
410  for (; imulti < nmulti; ++imulti) {
411  Atom target;
412  Atom property;
413 
414  if (multi) {
415  target = multi[imulti].target;
416  property = multi[imulti].property;
417  } else {
418  target = req->target;
419  property = req->property;
420  if (property == XNone) // obsolete client
421  property = target;
422  }
423 
424  Atom ret = XNone;
425  if (target == XNone || property == XNone) {
426  ;
427  } else if (target == xa_timestamp) {
428 // if (d->timestamp != CurrentTime) {
429 // XChangeProperty(screen()->display()->nativeDisplay(), req->requestor, property, XA_INTEGER, 32,
430 // PropModeReplace, CurrentTime, 1);
431 // ret = property;
432 // } else {
433 // qWarning("QClipboard: Invalid data timestamp");
434 // }
435  } else if (target == xa_targets) {
436  ret = sendTargetsSelection(d, req->requestor, property);
437  } else {
438  ret = sendSelection(d, target, req->requestor, property);
439  }
440 
441  if (nmulti > 0) {
442  if (ret == XNone) {
443  multi[imulti].property = XNone;
444  multi_writeback = true;
445  }
446  } else {
447  event.xselection.property = ret;
448  break;
449  }
450  }
451 
452  if (nmulti > 0) {
453  if (multi_writeback) {
454  // according to ICCCM 2.6.2 says to put None back
455  // into the original property on the requestor window
456  XChangeProperty(screen()->display()->nativeDisplay(), req->requestor, req->property, multi_type, 32,
457  PropModeReplace, (uchar *) multi, nmulti * 2);
458  }
459 
460  delete [] multi;
461  event.xselection.property = req->property;
462  }
463 
464  // send selection notify to requestor
465  XSendEvent(screen()->display()->nativeDisplay(), req->requestor, False, NoEventMask, &event);
466 }
467 
468 static inline int maxSelectionIncr(Display *dpy)
469 { return XMaxRequestSize(dpy) > 65536 ? 65536*4 : XMaxRequestSize(dpy)*4 - 100; }
470 
471 bool QXlibClipboard::clipboardReadProperty(Window win, Atom property, bool deleteProperty, QByteArray *buffer, int *size, Atom *type, int *format) const
472 {
473  int maxsize = maxSelectionIncr(screen()->display()->nativeDisplay());
474  ulong bytes_left; // bytes_after
475  ulong length; // nitems
476  uchar *data;
477  Atom dummy_type;
478  int dummy_format;
479  int r;
480 
481  if (!type) // allow null args
482  type = &dummy_type;
483  if (!format)
484  format = &dummy_format;
485 
486  // Don't read anything, just get the size of the property data
487  r = XGetWindowProperty(screen()->display()->nativeDisplay(), win, property, 0, 0, False,
488  AnyPropertyType, type, format,
489  &length, &bytes_left, &data);
490  if (r != Success || (type && *type == XNone)) {
491  buffer->resize(0);
492  return false;
493  }
494  XFree((char*)data);
495 
496  int offset = 0, buffer_offset = 0, format_inc = 1, proplen = bytes_left;
497 
498  switch (*format) {
499  case 8:
500  default:
501  format_inc = sizeof(char) / 1;
502  break;
503 
504  case 16:
505  format_inc = sizeof(short) / 2;
506  proplen *= sizeof(short) / 2;
507  break;
508 
509  case 32:
510  format_inc = sizeof(long) / 4;
511  proplen *= sizeof(long) / 4;
512  break;
513  }
514 
515  int newSize = proplen;
516  buffer->resize(newSize);
517 
518  bool ok = (buffer->size() == newSize);
519 
520  if (ok && newSize) {
521  // could allocate buffer
522 
523  while (bytes_left) {
524  // more to read...
525 
526  r = XGetWindowProperty(screen()->display()->nativeDisplay(), win, property, offset, maxsize/4,
527  False, AnyPropertyType, type, format,
528  &length, &bytes_left, &data);
529  if (r != Success || (type && *type == XNone))
530  break;
531 
532  offset += length / (32 / *format);
533  length *= format_inc * (*format) / 8;
534 
535  // Here we check if we get a buffer overflow and tries to
536  // recover -- this shouldn't normally happen, but it doesn't
537  // hurt to be defensive
538  if ((int)(buffer_offset + length) > buffer->size()) {
539  length = buffer->size() - buffer_offset;
540 
541  // escape loop
542  bytes_left = 0;
543  }
544 
545  memcpy(buffer->data() + buffer_offset, data, length);
546  buffer_offset += length;
547 
548  XFree((char*)data);
549  }
550 
551  if (*format == 8 && *type == QXlibStatic::atom(QXlibStatic::COMPOUND_TEXT)) {
552  // convert COMPOUND_TEXT to a multibyte string
553  XTextProperty textprop;
554  textprop.encoding = *type;
555  textprop.format = *format;
556  textprop.nitems = buffer_offset;
557  textprop.value = (unsigned char *) buffer->data();
558 
559  char **list_ret = 0;
560  int count;
561  if (XmbTextPropertyToTextList(screen()->display()->nativeDisplay(), &textprop, &list_ret,
562  &count) == Success && count && list_ret) {
563  offset = buffer_offset = strlen(list_ret[0]);
564  buffer->resize(offset);
565  memcpy(buffer->data(), list_ret[0], offset);
566  }
567  if (list_ret) XFreeStringList(list_ret);
568  }
569  }
570 
571  // correct size, not 0-term.
572  if (size)
573  *size = buffer_offset;
574 
575  if (deleteProperty)
576  XDeleteProperty(screen()->display()->nativeDisplay(), win, property);
577 
578  screen()->display()->flush();
579 
580  return ok;
581 }
582 
584 {
585  XEvent event;
586 
587  QByteArray buf;
588  QByteArray tmp_buf;
589  bool alloc_error = false;
590  int length;
591  int offset = 0;
592 
593  if (nbytes > 0) {
594  // Reserve buffer + zero-terminator (for text data)
595  // We want to complete the INCR transfer even if we cannot
596  // allocate more memory
597  buf.resize(nbytes+1);
598  alloc_error = buf.size() != nbytes+1;
599  }
600 
601  for (;;) {
602  screen()->display()->flush();
603  if (!screen()->waitForClipboardEvent(win,PropertyNotify,&event,clipboard_timeout))
604  break;
605  if (event.xproperty.atom != property ||
606  event.xproperty.state != PropertyNewValue)
607  continue;
608  if (clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) {
609  if (length == 0) { // no more data, we're done
610  if (nullterm) {
611  buf.resize(offset+1);
612  buf[offset] = '\0';
613  } else {
614  buf.resize(offset);
615  }
616  return buf;
617  } else if (!alloc_error) {
618  if (offset+length > (int)buf.size()) {
619  buf.resize(offset+length+65535);
620  if (buf.size() != offset+length+65535) {
621  alloc_error = true;
622  length = buf.size() - offset;
623  }
624  }
625  memcpy(buf.data()+offset, tmp_buf.constData(), length);
626  tmp_buf.resize(0);
627  offset += length;
628  }
629  } else {
630  break;
631  }
632  }
633 
634  // timed out ... create a new requestor window, otherwise the requestor
635  // could consider next request to be still part of this timed out request
636  setRequestor(0);
637 
638  return QByteArray();
639 }
640 
642 {
643  QByteArray buf;
644 
645  Window win = requestor();
646 
647  XSelectInput(screen()->display()->nativeDisplay(), win, NoEventMask); // don't listen for any events
648 
650  XConvertSelection(screen()->display()->nativeDisplay(), modeAtom, fmtatom, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), win, CurrentTime);
651  screen()->display()->sync();
652 
653  XEvent xevent;
654  if (!screen()->waitForClipboardEvent(win,SelectionNotify,&xevent,clipboard_timeout) ||
655  xevent.xselection.property == XNone) {
656  return buf;
657  }
658 
659  Atom type;
660  XSelectInput(screen()->display()->nativeDisplay(), win, PropertyChangeMask);
661 
662  if (clipboardReadProperty(win, QXlibStatic::atom(QXlibStatic::_QT_SELECTION), true, &buf, 0, &type, 0)) {
663  if (type == QXlibStatic::atom(QXlibStatic::INCR)) {
664  int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
666  }
667  }
668 
669  XSelectInput(screen()->display()->nativeDisplay(), win, NoEventMask);
670 
671 
672  return buf;
673 }
674 
675 #include "qxlibclipboard.moc"
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
unsigned long whitePixel()
Mode
This enum type is used to control which part of the system clipboard is used by QClipboard::mimeData(...
Definition: qclipboard.h:71
double d
Definition: qnumeric_p.h:62
static QWaylandClipboard * clipboard
void handleSelectionRequest(XEvent *event)
Window owner() const
int type
Definition: qmetatype.cpp:239
QXlibClipboard * m_clipboard
EventRef event
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
static QString mimeAtomToString(Display *display, Atom a)
Definition: qxlibmime.cpp:62
Window rootWindow()
QMimeData * mimeData(QClipboard::Mode mode)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QStringList formatsHelper(const QMimeData *data)
Definition: qdnd.cpp:414
Display * nativeDisplay() const
Atom sendSelection(QMimeData *d, Atom target, Window window, Atom property)
void setOwner(Window window)
bool supportsMode(QClipboard::Mode mode) const
bool hasFormat_sys(const QString &format) const
static bool mimeDataForAtom(Display *display, Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat)
Definition: qxlibmime.cpp:107
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QByteArray clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm)
QMimeData * m_clientClipboard
QMimeData * m_xClipboard
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
bool clipboardReadProperty(Window win, Atom property, bool deleteProperty, QByteArray *buffer, int *size, Atom *type, int *format) const
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
void setMimeData(QMimeData *data, QClipboard::Mode mode)
static const int clipboard_timeout
union _XEvent XEvent
Definition: qwindowdefs.h:116
QXlibClipboardMime(QClipboard::Mode mode, QXlibClipboard *clipboard)
QByteArray getDataInFormat(Atom modeAtom, Atom fmtatom)
Q_CORE_EXPORT void qDebug(const char *,...)
unsigned char uchar
Definition: qglobal.h:994
NSWindow * window
QStringList formats_sys() const
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
void setRequestor(Window window)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QStringList formats() const
Returns a list of formats supported by the object.
Definition: qdnd.cpp:351
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
Atom sendTargetsSelection(QMimeData *d, Window window, Atom property)
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
static QStringList mimeFormatsForAtom(Display *display, Atom a)
Definition: qxlibmime.cpp:82
unsigned long ulong
Definition: qglobal.h:997
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
QXlibScreen * screen() const
static int maxSelectionIncr(Display *dpy)
#define Q_OBJECT
Definition: qobjectdefs.h:157
static Atom atom(X11Atom atom)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static QVariant mimeConvertToFormat(Display *display, Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding)
Definition: qxlibmime.cpp:195
struct _XDisplay Display
Definition: qwindowdefs.h:115
static const struct @32 types[]
Q_GUI_EXPORT EGLNativeDisplayType nativeDisplay()
Definition: qegl_qpa.cpp:55
static QList< Atom > mimeAtomsForFormat(Display *display, const QString &format)
Definition: qxlibmime.cpp:168
void resize(int size)
Sets the size of the byte array to size bytes.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QXlibClipboard(QXlibScreen *screen)
const char * property
Definition: qwizard.cpp:138
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
bool contains(const T &t) const
Returns true if the vector contains an occurrence of value; otherwise returns false.
Definition: qvector.h:731
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
Window requestor() const
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
static Atom mimeAtomForFormat(Display *display, const QString &format, QVariant::Type requestedType, const QList< Atom > &atoms, QByteArray *requestedEncoding)
Definition: qxlibmime.cpp:269
QMimeData * m_clientSelection
QXlibScreen * m_screen
QXlibDisplay * display() const
void flush() const
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
void sync() const
QMimeData * m_xSelection
unsigned long blackPixel()
The QList class is a template class that provides lists.
Definition: qdatastream.h:62