45 #include <QtGui/QPlatformNativeInterface> 46 #include <QtGui/QApplication> 47 #include <QtCore/QMimeData> 48 #include <QtCore/QStringList> 49 #include <QtCore/QFile> 50 #include <QtCore/QtDebug> 51 #include <QtGui/private/qdnd_p.h> 99 static uint32_t getTime();
100 static void send(
void *data,
struct wl_selection *selection,
const char *mime_type,
int fd);
101 static void cancelled(
void *data,
struct wl_selection *selection);
102 static const struct wl_selection_listener selectionListener;
116 gettimeofday(&tv, 0);
117 return tv.tv_sec * 1000 + tv.tv_usec / 1000;
121 : mMimeData(data), mSelection(0)
123 struct wl_shell *shell = display->
wl_shell();
124 mSelection = wl_shell_create_selection(shell);
143 struct wl_selection *selection,
144 const char *mime_type,
166 : mDisplay(display), mMimeDataIn(0), mOffer(0)
174 wl_selection_offer_destroy(
mOffer);
186 *
static_cast<bool *
>(
data) =
true;
193 wl_display_iterate(display, WL_DISPLAY_WRITABLE);
195 wl_display_iterate(display, WL_DISPLAY_READABLE);
204 if (pipe(pipefd) == -1) {
205 qWarning(
"QWaylandClipboard: pipe() failed");
215 while ((n = read(pipefd[0], &buf,
sizeof buf)) > 0)
216 content.append(buf, n);
242 qWarning(
"QWaylandClipboard::setMimeData: No input devices");
260 wl_selection_offer_destroy(
mOffer);
267 struct wl_selection_offer *selection_offer,
276 struct wl_selection_offer *selection_offer,
277 wl_input_device *input_device)
281 wl_selection_offer_destroy(selection_offer);
285 clipboard->
mOffer = selection_offer;
The QVariant class acts like a union for the most common Qt data types.
static void send(void *data, struct wl_selection *selection, const char *mime_type, int fd)
Mode
This enum type is used to control which part of the system clipboard is used by QClipboard::mimeData(...
static QWaylandClipboard * clipboard
QWaylandDisplay * mDisplay
void createSelectionOffer(uint32_t id)
void clear()
Removes all the MIME type and data entries in the object.
virtual QStringList formats() const
Returns a list of formats supported by the object.
char * data()
Returns a pointer to the data stored in the byte array.
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
The QByteArray class provides an array of bytes.
QWaylandClipboardSignalEmitter mEmitter
QStringList formats_sys() const
QByteArray data(const QString &mimetype) const
Returns the data stored in the object in the format described by the MIME type specified by mimeType...
QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const
The QString class provides a Unicode character string.
QVariant retrieveData(const QString &mimeType, QVariant::Type type) const
static void forceRoundtrip(struct wl_display *display)
QWaylandMimeData * mMimeDataIn
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
void append(const T &t)
Inserts value at the end of the list.
void setFormats(const QStringList &formatList)
Q_GUI_EXPORT EGLDisplay display()
QList< QWaylandSelection * > mSelections
static void cancelled(void *data, struct wl_selection *selection)
void unregisterSelection(QWaylandSelection *selection)
static uint32_t getTime()
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 mOfferedMimeTypes
QStringList formats() const
Returns a list of formats supported by the object.
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.
bool hasFormat_sys(const QString &mimeType) const
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
void clear()
Removes all items from the list.
The QMimeData class provides a container for data that records information about its MIME type...
static void offer(void *data, struct wl_selection_offer *selection_offer, const char *type)
const char * constData() const
Returns a pointer to the data stored in the byte array.
static const struct wl_selection_offer_listener selectionOfferListener
static void syncCallback(void *data)
static const struct wl_selection_listener selectionListener
struct wl_shell * wl_shell() const
The QFile class provides an interface for reading from and writing to files.
bool supportsMode(QClipboard::Mode mode) const
struct wl_selection_offer * mOffer
void setMimeData(QMimeData *data, QClipboard::Mode mode=QClipboard::Clipboard)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
T & last()
Returns a reference to the last item in the list.
QWaylandSelection(QWaylandDisplay *display, QMimeData *data)
QWaylandClipboard(QWaylandDisplay *display)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
struct wl_selection * mSelection
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
static void keyboardFocus(void *data, struct wl_selection_offer *selection_offer, struct wl_input_device *input_device)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
QList< QWaylandInputDevice * > inputDevices() const
QMimeData * mimeData(QClipboard::Mode mode=QClipboard::Clipboard)
struct wl_display * wl_display() const