1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QXCBCLIPBOARD_H
43 #define QXCBCLIPBOARD_H
45 #include <qpa/qplatformclipboard.h>
46 #include <qxcbobject.h>
48 #include <xcb/xfixes.h>
52 #ifndef QT_NO_CLIPBOARD
56 class QXcbClipboardMime;
58 class QXcbClipboard : public QXcbObject, public QPlatformClipboard
61 QXcbClipboard(QXcbConnection *connection);
64 QMimeData *mimeData(QClipboard::Mode mode);
65 void setMimeData(QMimeData *data, QClipboard::Mode mode);
67 bool supportsMode(QClipboard::Mode mode) const;
68 bool ownsMode(QClipboard::Mode mode) const;
70 QXcbScreen *screen() const { return m_screen; }
72 xcb_window_t requestor() const;
73 void setRequestor(xcb_window_t window);
75 xcb_window_t owner() const;
77 void handleSelectionRequest(xcb_selection_request_event_t *event);
78 void handleSelectionClearRequest(xcb_selection_clear_event_t *event);
79 void handleXFixesSelectionRequest(xcb_xfixes_selection_notify_event_t *event);
81 bool clipboardReadProperty(xcb_window_t win, xcb_atom_t property, bool deleteProperty, QByteArray *buffer, int *size, xcb_atom_t *type, int *format) const;
82 QByteArray clipboardReadIncrementalProperty(xcb_window_t win, xcb_atom_t property, int nbytes, bool nullterm);
84 QByteArray getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtatom);
86 xcb_window_t getSelectionOwner(xcb_atom_t atom) const;
87 QByteArray getSelection(xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property);
90 xcb_generic_event_t *waitForClipboardEvent(xcb_window_t win, int type, int timeout, bool checkManager = false);
92 xcb_atom_t sendTargetsSelection(QMimeData *d, xcb_window_t window, xcb_atom_t property);
93 xcb_atom_t sendSelection(QMimeData *d, xcb_atom_t target, xcb_window_t window, xcb_atom_t property);
95 xcb_atom_t atomForMode(QClipboard::Mode mode) const;
96 QClipboard::Mode modeForAtom(xcb_atom_t atom) const;
100 // Selection and Clipboard
101 QXcbClipboardMime *m_xClipboard[2];
102 QMimeData *m_clientClipboard[2];
103 xcb_timestamp_t m_timestamp[2];
105 xcb_window_t m_requestor;
106 xcb_window_t m_owner;
108 static const int clipboard_timeout;
112 #endif // QT_NO_CLIPBOARD
116 #endif // QXCBCLIPBOARD_H