| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 4 |
|
| 5 |
#ifndef QXCBCLIPBOARD_H |
| 6 |
#define QXCBCLIPBOARD_H |
| 7 |
|
| 8 |
#include <qpa/qplatformclipboard.h> |
| 9 |
#include <qxcbobject.h> |
| 10 |
#include <xcb/xcb.h> |
| 11 |
#include <xcb/xfixes.h> |
| 12 |
|
| 13 |
QT_BEGIN_NAMESPACE |
| 14 |
|
| 15 |
#ifndef QT_NO_CLIPBOARD |
| 16 |
|
| 17 |
class QXcbConnection; |
| 18 |
class QXcbScreen; |
| 19 |
class QXcbClipboardMime; |
| 20 |
|
| 21 |
class QXcbClipboard : public QXcbObject, public QPlatformClipboard |
| 22 |
{ |
| 23 |
public: |
| 24 |
QXcbClipboard(QXcbConnection *connection); |
| 25 |
~QXcbClipboard(); |
| 26 |
|
| 27 |
QMimeData *mimeData(QClipboard::Mode mode) Q_DECL_OVERRIDE; |
| 28 |
void setMimeData(QMimeData *data, QClipboard::Mode mode) Q_DECL_OVERRIDE; |
| 29 |
|
| 30 |
bool supportsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE; |
| 31 |
bool ownsMode(QClipboard::Mode mode) const Q_DECL_OVERRIDE; |
| 32 |
|
| 33 |
QXcbScreen *screen() const; |
| 34 |
|
| 35 |
xcb_window_t requestor() const; |
| 36 |
void setRequestor(xcb_window_t window); |
| 37 |
|
| 38 |
xcb_window_t owner() const; |
| 39 |
|
| 40 |
void handleSelectionRequest(xcb_selection_request_event_t *event); |
| 41 |
void handleSelectionClearRequest(xcb_selection_clear_event_t *event); |
| 42 |
void handleXFixesSelectionRequest(xcb_xfixes_selection_notify_event_t *event); |
| 43 |
|
| 44 |
bool clipboardReadProperty(xcb_window_t win, xcb_atom_t property, bool deleteProperty, QByteArray *buffer, int *size, xcb_atom_t *type, int *format); |
| 45 |
QByteArray clipboardReadIncrementalProperty(xcb_window_t win, xcb_atom_t property, int nbytes, bool nullterm); |
| 46 |
|
| 47 |
QByteArray getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtatom); |
| 48 |
|
| 49 |
void setProcessIncr(bool process) { m_incr_active = process; } |
| 50 |
bool processIncr() { return m_incr_active; } |
| 51 |
void incrTransactionPeeker(xcb_generic_event_t *ge, bool &accepted); |
| 52 |
|
| 53 |
xcb_window_t getSelectionOwner(xcb_atom_t atom) const; |
| 54 |
QByteArray getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t t = 0); |
| 55 |
|
| 56 |
private: |
| 57 |
xcb_generic_event_t *waitForClipboardEvent(xcb_window_t win, int type, int timeout, bool checkManager = false); |
| 58 |
|
| 59 |
xcb_atom_t sendTargetsSelection(QMimeData *d, xcb_window_t window, xcb_atom_t property); |
| 60 |
xcb_atom_t sendSelection(QMimeData *d, xcb_atom_t target, xcb_window_t window, xcb_atom_t property); |
| 61 |
|
| 62 |
xcb_atom_t atomForMode(QClipboard::Mode mode) const; |
| 63 |
QClipboard::Mode modeForAtom(xcb_atom_t atom) const; |
| 64 |
|
| 65 |
// Selection and Clipboard |
| 66 |
QScopedPointer<QXcbClipboardMime> m_xClipboard[2]; |
| 67 |
QMimeData *m_clientClipboard[2]; |
| 68 |
xcb_timestamp_t m_timestamp[2]; |
| 69 |
|
| 70 |
xcb_window_t m_requestor; |
| 71 |
xcb_window_t m_owner; |
| 72 |
|
| 73 |
static const int clipboard_timeout; |
| 74 |
|
| 75 |
bool m_incr_active; |
| 76 |
bool m_clipboard_closing; |
| 77 |
xcb_timestamp_t m_incr_receive_time; |
| 78 |
}; |
| 79 |
|
| 80 |
#endif // QT_NO_CLIPBOARD |
| 81 |
|
| 82 |
QT_END_NAMESPACE |
| 83 |
|
| 84 |
#endif // QXCBCLIPBOARD_H |