Qt 4.8
Public Functions | Static Private Functions | Properties | Static Private Attributes | List of all members
QWaylandClipboard Class Reference

#include <qwaylandclipboard.h>

Inheritance diagram for QWaylandClipboard:
QPlatformClipboard

Public Functions

void createSelectionOffer (uint32_t id)
 
QMimeDatamimeData (QClipboard::Mode mode=QClipboard::Clipboard)
 
 QWaylandClipboard (QWaylandDisplay *display)
 
QVariant retrieveData (const QString &mimeType, QVariant::Type type) const
 
void setMimeData (QMimeData *data, QClipboard::Mode mode=QClipboard::Clipboard)
 
bool supportsMode (QClipboard::Mode mode) const
 
void unregisterSelection (QWaylandSelection *selection)
 
 ~QWaylandClipboard ()
 
- Public Functions inherited from QPlatformClipboard
void emitChanged (QClipboard::Mode mode)
 
virtual ~QPlatformClipboard ()
 

Static Private Functions

static void forceRoundtrip (struct wl_display *display)
 
static void keyboardFocus (void *data, struct wl_selection_offer *selection_offer, struct wl_input_device *input_device)
 
static void offer (void *data, struct wl_selection_offer *selection_offer, const char *type)
 
static void syncCallback (void *data)
 

Properties

QWaylandDisplaymDisplay
 
QWaylandClipboardSignalEmitter mEmitter
 
QWaylandMimeDatamMimeDataIn
 
struct wl_selection_offer * mOffer
 
QStringList mOfferedMimeTypes
 
QList< QWaylandSelection * > mSelections
 

Static Private Attributes

static const struct wl_selection_offer_listener selectionOfferListener
 

Detailed Description

Definition at line 251 of file qwaylandclipboard.cpp.

Constructors and Destructors

◆ QWaylandClipboard()

QWaylandClipboard::QWaylandClipboard ( QWaylandDisplay display)

Definition at line 165 of file qwaylandclipboard.cpp.

166  : mDisplay(display), mMimeDataIn(0), mOffer(0)
167 {
168  clipboard = this;
169 }
static QWaylandClipboard * clipboard
QWaylandDisplay * mDisplay
QWaylandMimeData * mMimeDataIn
struct wl_selection_offer * mOffer

◆ ~QWaylandClipboard()

QWaylandClipboard::~QWaylandClipboard ( )

Definition at line 171 of file qwaylandclipboard.cpp.

172 {
173  if (mOffer)
174  wl_selection_offer_destroy(mOffer);
175  delete mMimeDataIn;
177 }
QWaylandMimeData * mMimeDataIn
QList< QWaylandSelection * > mSelections
struct wl_selection_offer * mOffer
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Functions

◆ createSelectionOffer()

void QWaylandClipboard::createSelectionOffer ( uint32_t  id)

Definition at line 256 of file qwaylandclipboard.cpp.

Referenced by QWaylandDisplay::displayHandleGlobal().

257 {
259  if (mOffer)
260  wl_selection_offer_destroy(mOffer);
261  mOffer = 0;
262  struct wl_selection_offer *offer = wl_selection_offer_create(mDisplay->wl_display(), id, 1);
263  wl_selection_offer_add_listener(offer, &selectionOfferListener, this);
264 }
QWaylandDisplay * mDisplay
QStringList mOfferedMimeTypes
void clear()
Removes all items from the list.
Definition: qlist.h:764
static void offer(void *data, struct wl_selection_offer *selection_offer, const char *type)
static const struct wl_selection_offer_listener selectionOfferListener
struct wl_selection_offer * mOffer
struct wl_display * wl_display() const

◆ forceRoundtrip()

void QWaylandClipboard::forceRoundtrip ( struct wl_display *  display)
staticprivate

Definition at line 189 of file qwaylandclipboard.cpp.

Referenced by retrieveData().

190 {
191  bool done = false;
192  wl_display_sync_callback(display, syncCallback, &done);
193  wl_display_iterate(display, WL_DISPLAY_WRITABLE);
194  while (!done)
195  wl_display_iterate(display, WL_DISPLAY_READABLE);
196 }
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static void syncCallback(void *data)

◆ keyboardFocus()

void QWaylandClipboard::keyboardFocus ( void *  data,
struct wl_selection_offer *  selection_offer,
struct wl_input_device *  input_device 
)
staticprivate

Definition at line 275 of file qwaylandclipboard.cpp.

278 {
279  Q_UNUSED(data);
280  if (!input_device) {
281  wl_selection_offer_destroy(selection_offer);
282  clipboard->mOffer = 0;
283  return;
284  }
285  clipboard->mOffer = selection_offer;
288 }
static QWaylandClipboard * clipboard
QWaylandClipboardSignalEmitter mEmitter
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< QWaylandSelection * > mSelections
static const char * data(const QByteArray &arr)
struct wl_selection_offer * mOffer
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ mimeData()

QMimeData * QWaylandClipboard::mimeData ( QClipboard::Mode  mode = QClipboard::Clipboard)
virtual

Reimplemented from QPlatformClipboard.

Definition at line 221 of file qwaylandclipboard.cpp.

222 {
224  if (!mSelections.isEmpty())
225  return mSelections.last()->mMimeData;
226  if (!mMimeDataIn)
229  if (!mOfferedMimeTypes.isEmpty() && mOffer)
231  return mMimeDataIn;
232 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QWaylandMimeData * mMimeDataIn
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void setFormats(const QStringList &formatList)
QList< QWaylandSelection * > mSelections
QStringList mOfferedMimeTypes
struct wl_selection_offer * mOffer
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284

◆ offer()

void QWaylandClipboard::offer ( void *  data,
struct wl_selection_offer *  selection_offer,
const char *  type 
)
staticprivate

Definition at line 266 of file qwaylandclipboard.cpp.

Referenced by createSelectionOffer().

269 {
270  Q_UNUSED(data);
271  Q_UNUSED(selection_offer);
273 }
static QWaylandClipboard * clipboard
int type
Definition: qmetatype.cpp:239
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QStringList mOfferedMimeTypes
static const char * data(const QByteArray &arr)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ retrieveData()

QVariant QWaylandClipboard::retrieveData ( const QString mimeType,
QVariant::Type  type 
) const

Definition at line 198 of file qwaylandclipboard.cpp.

Referenced by QWaylandMimeData::retrieveData_sys().

199 {
200  Q_UNUSED(type);
201  if (mOfferedMimeTypes.isEmpty() || !mOffer)
202  return QVariant();
203  int pipefd[2];
204  if (pipe(pipefd) == -1) {
205  qWarning("QWaylandClipboard: pipe() failed");
206  return QVariant();
207  }
208  QByteArray mimeTypeBa = mimeType.toLatin1();
209  wl_selection_offer_receive(mOffer, mimeTypeBa.constData(), pipefd[1]);
210  QByteArray content;
212  char buf[256];
213  int n;
214  close(pipefd[1]);
215  while ((n = read(pipefd[0], &buf, sizeof buf)) > 0)
216  content.append(buf, n);
217  close(pipefd[0]);
218  return content;
219 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QWaylandDisplay * mDisplay
int type
Definition: qmetatype.cpp:239
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static void forceRoundtrip(struct wl_display *display)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QStringList mOfferedMimeTypes
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
struct wl_selection_offer * mOffer
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
struct wl_display * wl_display() const

◆ setMimeData()

void QWaylandClipboard::setMimeData ( QMimeData data,
QClipboard::Mode  mode = QClipboard::Clipboard 
)
virtual

Reimplemented from QPlatformClipboard.

Definition at line 234 of file qwaylandclipboard.cpp.

235 {
237  if (!mDisplay->inputDevices().isEmpty()) {
238  if (!data)
239  data = new QMimeData;
241  } else {
242  qWarning("QWaylandClipboard::setMimeData: No input devices");
243  }
244 }
QWaylandDisplay * mDisplay
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QWaylandSelection * > mSelections
Q_CORE_EXPORT void qWarning(const char *,...)
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
QList< QWaylandInputDevice * > inputDevices() const

◆ supportsMode()

bool QWaylandClipboard::supportsMode ( QClipboard::Mode  mode) const
virtual

Reimplemented from QPlatformClipboard.

Definition at line 246 of file qwaylandclipboard.cpp.

247 {
248  return mode == QClipboard::Clipboard;
249 }

◆ syncCallback()

void QWaylandClipboard::syncCallback ( void *  data)
staticprivate

Definition at line 184 of file qwaylandclipboard.cpp.

Referenced by forceRoundtrip().

185 {
186  *static_cast<bool *>(data) = true;
187 }
static const char * data(const QByteArray &arr)

◆ unregisterSelection()

void QWaylandClipboard::unregisterSelection ( QWaylandSelection selection)

Definition at line 179 of file qwaylandclipboard.cpp.

Referenced by QWaylandSelection::~QWaylandSelection().

180 {
181  mSelections.removeOne(selection);
182 }
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
QList< QWaylandSelection * > mSelections

Properties

◆ mDisplay

QWaylandDisplay* QWaylandClipboard::mDisplay
private

Definition at line 89 of file qwaylandclipboard.h.

Referenced by createSelectionOffer(), retrieveData(), and setMimeData().

◆ mEmitter

QWaylandClipboardSignalEmitter QWaylandClipboard::mEmitter
private

Definition at line 94 of file qwaylandclipboard.h.

Referenced by keyboardFocus().

◆ mMimeDataIn

QWaylandMimeData* QWaylandClipboard::mMimeDataIn
private

Definition at line 90 of file qwaylandclipboard.h.

Referenced by mimeData(), and ~QWaylandClipboard().

◆ mOffer

struct wl_selection_offer* QWaylandClipboard::mOffer
private

◆ mOfferedMimeTypes

QStringList QWaylandClipboard::mOfferedMimeTypes
private

Definition at line 92 of file qwaylandclipboard.h.

Referenced by createSelectionOffer(), mimeData(), offer(), and retrieveData().

◆ mSelections

QList<QWaylandSelection *> QWaylandClipboard::mSelections
private

◆ selectionOfferListener

const struct wl_selection_offer_listener QWaylandClipboard::selectionOfferListener
staticprivate

Definition at line 84 of file qwaylandclipboard.h.

Referenced by createSelectionOffer().


The documentation for this class was generated from the following files: