Fix xcb plugin compilation for -qconfig large
[profile/ivi/qtbase.git] / src / plugins / platforms / xcb / qxcbclipboard.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
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.
16 **
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.
20 **
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.
28 **
29 ** Other Usage
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.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QXCBCLIPBOARD_H
43 #define QXCBCLIPBOARD_H
44
45 #include <qpa/qplatformclipboard.h>
46 #include <qxcbobject.h>
47 #include <xcb/xcb.h>
48 #include <xcb/xfixes.h>
49
50 QT_BEGIN_NAMESPACE
51
52 #ifndef QT_NO_CLIPBOARD
53
54 class QXcbConnection;
55 class QXcbScreen;
56 class QXcbClipboardMime;
57
58 class QXcbClipboard : public QXcbObject, public QPlatformClipboard
59 {
60 public:
61     QXcbClipboard(QXcbConnection *connection);
62     ~QXcbClipboard();
63
64     QMimeData *mimeData(QClipboard::Mode mode);
65     void setMimeData(QMimeData *data, QClipboard::Mode mode);
66
67     bool supportsMode(QClipboard::Mode mode) const;
68     bool ownsMode(QClipboard::Mode mode) const;
69
70     QXcbScreen *screen() const { return m_screen; }
71
72     xcb_window_t requestor() const;
73     void setRequestor(xcb_window_t window);
74
75     xcb_window_t owner() const;
76
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);
80
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);
83
84     QByteArray getDataInFormat(xcb_atom_t modeAtom, xcb_atom_t fmtatom);
85
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);
88
89 private:
90     xcb_generic_event_t *waitForClipboardEvent(xcb_window_t win, int type, int timeout, bool checkManager = false);
91
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);
94
95     xcb_atom_t atomForMode(QClipboard::Mode mode) const;
96     QClipboard::Mode modeForAtom(xcb_atom_t atom) const;
97
98     QXcbScreen *m_screen;
99
100     // Selection and Clipboard
101     QXcbClipboardMime *m_xClipboard[2];
102     QMimeData *m_clientClipboard[2];
103     xcb_timestamp_t m_timestamp[2];
104
105     xcb_window_t m_requestor;
106     xcb_window_t m_owner;
107
108     static const int clipboard_timeout;
109
110 };
111
112 #endif // QT_NO_CLIPBOARD
113
114 QT_END_NAMESPACE
115
116 #endif // QXCBCLIPBOARD_H