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 QtGui module 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 ****************************************************************************/
45 #include <qpa/qplatformdrag.h>
46 #include <QtPlatformSupport/private/qsimpledrag_p.h>
47 #include <qxcbobject.h>
52 #include <qsharedpointer.h>
57 #include <qbackingstore.h>
59 #include <QtCore/QDebug>
63 #ifndef QT_NO_DRAGANDDROP
72 class QShapedPixmapWindow;
74 class QXcbDrag : public QXcbObject, public QBasicDrag
77 QXcbDrag(QXcbConnection *c);
80 virtual QMimeData *platformDropData();
85 void move(const QMouseEvent *me);
86 void drop(const QMouseEvent *me);
89 void handleEnter(QWindow *window, const xcb_client_message_event_t *event);
90 void handlePosition(QWindow *w, const xcb_client_message_event_t *event);
91 void handleLeave(QWindow *w, const xcb_client_message_event_t *event);
92 void handleDrop(QWindow *, const xcb_client_message_event_t *event);
94 void handleStatus(const xcb_client_message_event_t *event);
95 void handleSelectionRequest(const xcb_selection_request_event_t *event);
96 void handleFinished(const xcb_client_message_event_t *event);
98 bool dndEnable(QXcbWindow *win, bool on);
103 void timerEvent(QTimerEvent* e);
106 friend class QXcbDropData;
110 void handle_xdnd_position(QWindow *w, const xcb_client_message_event_t *event);
111 void handle_xdnd_status(const xcb_client_message_event_t *event);
114 Qt::DropAction toDropAction(xcb_atom_t atom) const;
115 xcb_atom_t toXdndAction(Qt::DropAction a) const;
117 QPointer<QWindow> currentWindow;
118 QPoint currentPosition;
120 QXcbDropData *dropData;
121 Qt::DropAction accepted_drop_action;
123 QWindow *desktop_proxy;
125 xcb_atom_t xdnd_dragsource;
127 // the types in this drop. 100 is no good, but at least it's big.
128 enum { xdnd_max_type = 100 };
129 QList<xcb_atom_t> xdnd_types;
131 xcb_timestamp_t target_time;
132 xcb_timestamp_t source_time;
134 // rectangle in which the answer will be the same
135 QRect source_sameanswer;
136 bool waiting_for_status;
138 // top-level window we sent position to last.
139 xcb_window_t current_target;
140 // window to send events to (always valid if current_target)
141 xcb_window_t current_proxy_target;
143 QXcbScreen *current_screen;
147 QVector<xcb_atom_t> drag_types;
151 xcb_timestamp_t timestamp;
153 xcb_window_t proxy_target;
154 QWindow *targetWindow;
155 // QWidget *embedding_widget;
158 QList<Transaction> transactions;
160 int transaction_expiry_timer;
161 void restartDropExpiryTimer();
162 int findTransactionByWindow(xcb_window_t window);
163 int findTransactionByTime(xcb_timestamp_t timestamp);
164 xcb_window_t findRealWindow(const QPoint & pos, xcb_window_t w, int md, bool ignoreNonXdndAwareWindows);
167 #endif // QT_NO_DRAGANDDROP