Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwaylanddnd.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qwaylanddnd_p.h"
5
10#include "qwaylanddisplay_p.h"
11
12#include <QtGui/private/qshapedpixmapdndwindow_p.h>
13
14#include <QDebug>
15
17#if QT_CONFIG(draganddrop)
18namespace QtWaylandClient {
19
20QWaylandDrag::QWaylandDrag(QWaylandDisplay *display)
21 : m_display(display)
22{
23}
24
25QWaylandDrag::~QWaylandDrag()
26{
27}
28
29void QWaylandDrag::startDrag()
30{
32 QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
33 if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
34 icon->addAttachOffset(-drag()->hotSpot());
35 } else {
36 // Cancelling immediately does not work, since the event loop for QDrag::exec is started
37 // after this function returns.
39 }
40}
41
42void QWaylandDrag::cancel()
43{
45
46 m_display->currentInputDevice()->dataDevice()->cancelDrag();
47
48 if (drag())
49 drag()->deleteLater();
50}
51
52void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
53{
54 Q_UNUSED(globalPos);
55 Q_UNUSED(b);
56 Q_UNUSED(mods);
57 // Do nothing
58}
59
60void QWaylandDrag::drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
61{
62 QBasicDrag::drop(globalPos, b, mods);
63}
64
65void QWaylandDrag::endDrag()
66{
67 m_display->currentInputDevice()->handleEndDrag();
68}
69
70void QWaylandDrag::setResponse(bool accepted)
71{
72 // This method is used for old DataDevices where the drag action is not communicated
73 Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
74 setResponse(QPlatformDropQtResponse(accepted, action));
75}
76
77void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
78{
79 setCanDrop(response.isAccepted());
80
81 if (canDrop()) {
82 updateCursor(response.acceptedAction());
83 } else {
84 updateCursor(Qt::IgnoreAction);
85 }
86}
87
88void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
89{
90 setExecutedDropAction(response.acceptedAction());
91}
92
93void QWaylandDrag::finishDrag()
94{
96 eventFilter(shapedPixmapWindow(), &event);
97
98 if (drag())
99 drag()->deleteLater();
100}
101
102bool QWaylandDrag::ownsDragObject() const
103{
104 return true;
105}
106
107}
108#endif // draganddrop
virtual void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)=0
virtual void startDrag()
virtual void cancel()
@ KeyPress
Definition qcoreevent.h:64
The QKeyEvent class describes a key event.
Definition qevent.h:424
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
Definition qobject.cpp:1555
Qt::DropAction acceptedAction() const
\inmodule QtCore\reentrant
Definition qpoint.h:25
QWaylandDrag(QWaylandSeat *seat)
QWaylandSurface * icon
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
@ Key_Escape
Definition qnamespace.h:663
@ NoModifier
DropAction
@ IgnoreAction
@ QueuedConnection
GLboolean GLboolean GLboolean b
struct _cl_event * event
#define Q_UNUSED(x)
QMimeData * mimeData
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(nullptr), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
\threadsafe This is an overloaded member function, provided for convenience. It differs from the abov...