Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.3.2/qxcbdrag.h

raw
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 QXCBDRAG_H
6 #define QXCBDRAG_H
7
8 #include <qpa/qplatformdrag.h>
9 #include <private/qsimpledrag_p.h>
10 #include <qxcbobject.h>
11 #include <xcb/xcb.h>
12 #include <qlist.h>
13 #include <qpoint.h>
14 #include <qrect.h>
15 #include <qsharedpointer.h>
16 #include <qpointer.h>
17 #include <qvector.h>
18 #include <qdatetime.h>
19 #include <qpixmap.h>
20 #include <qbackingstore.h>
21
22 #include <QtCore/QDebug>
23
24 QT_BEGIN_NAMESPACE
25
26 #ifndef QT_NO_DRAGANDDROP
27
28 class QMouseEvent;
29 class QWindow;
30 class QXcbConnection;
31 class QXcbWindow;
32 class QXcbDropData;
33 class QXcbScreen;
34 class QDrag;
35 class QShapedPixmapWindow;
36
37 class QXcbDrag : public QXcbObject, public QBasicDrag
38 {
39 public:
40 QXcbDrag(QXcbConnection *c);
41 ~QXcbDrag();
42
43 virtual QMimeData *platformDropData();
44
45
46 void startDrag();
47 void cancel();
48 void move(const QMouseEvent *me);
49 void drop(const QMouseEvent *me);
50 void endDrag();
51
52 void handleEnter(QWindow *window, const xcb_client_message_event_t *event);
53 void handlePosition(QWindow *w, const xcb_client_message_event_t *event);
54 void handleLeave(QWindow *w, const xcb_client_message_event_t *event);
55 void handleDrop(QWindow *, const xcb_client_message_event_t *event);
56
57 void handleStatus(const xcb_client_message_event_t *event);
58 void handleSelectionRequest(const xcb_selection_request_event_t *event);
59 void handleFinished(const xcb_client_message_event_t *event);
60
61 bool dndEnable(QXcbWindow *win, bool on);
62
63 void updatePixmap();
64 xcb_timestamp_t targetTime() { return target_time; }
65
66 protected:
67 void timerEvent(QTimerEvent* e);
68
69 private:
70 friend class QXcbDropData;
71
72 void init();
73
74 void handle_xdnd_position(QWindow *w, const xcb_client_message_event_t *event);
75 void handle_xdnd_status(const xcb_client_message_event_t *event);
76 void send_leave();
77
78 Qt::DropAction toDropAction(xcb_atom_t atom) const;
79 xcb_atom_t toXdndAction(Qt::DropAction a) const;
80
81 QPointer<QWindow> currentWindow;
82 QPoint currentPosition;
83
84 QXcbDropData *dropData;
85 Qt::DropAction accepted_drop_action;
86
87 QWindow *desktop_proxy;
88
89 xcb_atom_t xdnd_dragsource;
90
91 // the types in this drop. 100 is no good, but at least it's big.
92 enum { xdnd_max_type = 100 };
93 QList<xcb_atom_t> xdnd_types;
94
95 // timestamp from XdndPosition and XdndDroptime for retrieving the data
96 xcb_timestamp_t target_time;
97 xcb_timestamp_t source_time;
98
99 // rectangle in which the answer will be the same
100 QRect source_sameanswer;
101 bool waiting_for_status;
102
103 // top-level window we sent position to last.
104 xcb_window_t current_target;
105 // window to send events to (always valid if current_target)
106 xcb_window_t current_proxy_target;
107
108 QXcbScreen *current_screen;
109
110 // 10 minute timer used to discard old XdndDrop transactions
111 enum { XdndDropTransactionTimeout = 600000 };
112 int cleanup_timer;
113
114 QVector<xcb_atom_t> drag_types;
115
116 struct Transaction
117 {
118 xcb_timestamp_t timestamp;
119 xcb_window_t target;
120 xcb_window_t proxy_target;
121 QWindow *targetWindow;
122 // QWidget *embedding_widget;
123 QPointer<QDrag> drag;
124 QTime time;
125 };
126 QList<Transaction> transactions;
127
128 int transaction_expiry_timer;
129 void restartDropExpiryTimer();
130 int findTransactionByWindow(xcb_window_t window);
131 int findTransactionByTime(xcb_timestamp_t timestamp);
132 xcb_window_t findRealWindow(const QPoint & pos, xcb_window_t w, int md, bool ignoreNonXdndAwareWindows);
133 };
134
135 #endif // QT_NO_DRAGANDDROP
136
137 QT_END_NAMESPACE
138
139 #endif