48 #include <private/qapplication_p.h> 50 #include <QtCore/QDebug> 70 qWarning(
"QTestLiteMime: Internal error: Unsupported clipboard mode");
92 for (
int i = 0; i < size; ++i) {
97 for (
int j = 0; j < formatsForAtom.
size(); ++j) {
124 for (
int i = 0; i < size; ++i)
156 , m_clientClipboard(0)
158 , m_clientSelection(0)
171 if (clipboardOwner ==
owner()) {
181 if (clipboardOwner ==
owner()) {
196 modeAtom = XA_PRIMARY;
206 qWarning(
"QClipboard::setMimeData: unsupported mode '%d'", mode);
223 qWarning(
"QClipboard::setData: Cannot set X11 selection owner");
244 int x = 0, y = 0, w = 3, h = 3;
265 int x = 0, y = 0, w = 3, h = 3;
287 for (
int i = 0; i < formats.
size(); ++i) {
289 for (
int j = 0; j < atoms.
size(); ++j) {
306 Atom atomFormat = target;
312 qDebug() <<
"QClipboard: send_selection(): converting to type '%s' is not supported" << fmt.
data();
315 qDebug() <<
"QClipboard: send_selection(): converting to type '%s'" << fmt.
data();
322 bool allow_incr =
property != motif_clip_temporary;
326 if (data.
size() > increment && allow_incr) {
327 long bytes = data.
size();
332 qDebug() <<
"not implemented INCRT just YET!";
337 if (data.
size() > increment)
339 int dataSize = data.
size() / (dataFormat / 8);
342 dataFormat, PropModeReplace, (
uchar *) data.
data(),
350 XSelectionRequestEvent *req = &xevent->xselectionrequest;
353 qDebug() <<
"This should be caught before";
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;
367 if (req->selection == XA_PRIMARY) {
372 qWarning(
"QClipboard: Unknown selection '%lx'", req->selection);
378 qWarning(
"QClipboard: Cannot transfer data, no data available");
389 int multi_format = 0;
392 bool multi_writeback =
false;
394 if (req->target == xa_multiple) {
396 if (req->property ==
XNone 398 0, &multi_type, &multi_format)
399 || multi_format != 32) {
404 nmulti = multi_data.
size()/
sizeof(*multi);
405 multi =
new AtomPair[nmulti];
406 memcpy(multi,multi_data.
data(),multi_data.
size());
410 for (; imulti < nmulti; ++imulti) {
415 target = multi[imulti].target;
416 property = multi[imulti].property;
418 target = req->target;
419 property = req->property;
420 if (property ==
XNone)
427 }
else if (target == xa_timestamp) {
435 }
else if (target == xa_targets) {
443 multi[imulti].property =
XNone;
444 multi_writeback =
true;
447 event.xselection.property = ret;
453 if (multi_writeback) {
457 PropModeReplace, (
uchar *) multi, nmulti * 2);
461 event.xselection.property = req->property;
469 {
return XMaxRequestSize(dpy) > 65536 ? 65536*4 : XMaxRequestSize(dpy)*4 - 100; }
484 format = &dummy_format;
488 AnyPropertyType, type, format,
489 &length, &bytes_left, &data);
496 int offset = 0, buffer_offset = 0, format_inc = 1, proplen = bytes_left;
501 format_inc =
sizeof(char) / 1;
505 format_inc =
sizeof(short) / 2;
506 proplen *=
sizeof(short) / 2;
510 format_inc =
sizeof(long) / 4;
511 proplen *=
sizeof(long) / 4;
515 int newSize = proplen;
518 bool ok = (buffer->
size() == newSize);
527 False, AnyPropertyType, type, format,
528 &length, &bytes_left, &data);
532 offset += length / (32 / *
format);
533 length *= format_inc * (*format) / 8;
538 if ((
int)(buffer_offset + length) > buffer->
size()) {
539 length = buffer->
size() - buffer_offset;
545 memcpy(buffer->
data() + buffer_offset,
data, length);
546 buffer_offset += length;
553 XTextProperty textprop;
554 textprop.encoding = *
type;
555 textprop.format = *
format;
556 textprop.nitems = buffer_offset;
557 textprop.value = (
unsigned char *) buffer->
data();
562 &count) ==
Success && count && list_ret) {
563 offset = buffer_offset = strlen(list_ret[0]);
565 memcpy(buffer->
data(), list_ret[0], offset);
567 if (list_ret) XFreeStringList(list_ret);
573 *size = buffer_offset;
589 bool alloc_error =
false;
598 alloc_error = buf.
size() != nbytes+1;
605 if (event.xproperty.atom != property ||
606 event.xproperty.state != PropertyNewValue)
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) {
622 length = buf.
size() - offset;
664 int nbytes = buf.
size() >= 4 ? *((
int*)buf.
data()) : 0;
675 #include "qxlibclipboard.moc" The QVariant class acts like a union for the most common Qt data types.
unsigned long whitePixel()
Mode
This enum type is used to control which part of the system clipboard is used by QClipboard::mimeData(...
static QWaylandClipboard * clipboard
void handleSelectionRequest(XEvent *event)
QXlibClipboard * m_clipboard
char * data()
Returns a pointer to the data stored in the byte array.
static QString mimeAtomToString(Display *display, Atom a)
QMimeData * mimeData(QClipboard::Mode mode)
The QByteArray class provides an array of bytes.
static QStringList formatsHelper(const QMimeData *data)
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)
int count(const T &t) const
Returns the number of occurrences of value in the list.
QByteArray clipboardReadIncrementalProperty(Window win, Atom property, int nbytes, bool nullterm)
QMimeData * m_clientClipboard
The QString class provides a Unicode character string.
The QVector class is a template class that provides a dynamic array.
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.
void setMimeData(QMimeData *data, QClipboard::Mode mode)
static const int clipboard_timeout
QXlibClipboardMime(QClipboard::Mode mode, QXlibClipboard *clipboard)
QByteArray getDataInFormat(Atom modeAtom, Atom fmtatom)
Q_CORE_EXPORT void qDebug(const char *,...)
QStringList formats_sys() const
void append(const T &t)
Inserts value at the end of the list.
QVariant retrieveData_sys(const QString &fmt, QVariant::Type requestedType) const
Q_GUI_EXPORT EGLDisplay display()
void setRequestor(Window window)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
QStringList formats() const
Returns a list of formats supported by the object.
void append(const T &t)
Inserts value at the end of the vector.
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.
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.
static QStringList mimeFormatsForAtom(Display *display, Atom a)
The QMimeData class provides a container for data that records information about its MIME type...
QXlibScreen * screen() const
static int maxSelectionIncr(Display *dpy)
static Atom atom(X11Atom atom)
const char * constData() const
Returns a pointer to the data stored in the byte array.
static QVariant mimeConvertToFormat(Display *display, Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding)
Q_GUI_EXPORT EGLNativeDisplayType nativeDisplay()
static QList< Atom > mimeAtomsForFormat(Display *display, const QString &format)
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.
QXlibClipboard(QXlibScreen *screen)
int size() const
Returns the number of bytes in this byte array.
bool contains(const T &t) const
Returns true if the vector contains an occurrence of value; otherwise returns false.
QVariant property(const char *name) const
Returns the value of the object's name property.
T * data()
Returns a pointer to the data stored in the vector.
static Atom mimeAtomForFormat(Display *display, const QString &format, QVariant::Type requestedType, const QList< Atom > &atoms, QByteArray *requestedEncoding)
QMimeData * m_clientSelection
QXlibDisplay * display() const
int size() const
Returns the number of items in the vector.
unsigned long blackPixel()
The QList class is a template class that provides lists.