Qt 6.x
The Qt SDK
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 Q_UNUSED(globalPos);
63 Q_UNUSED(b);
64 Q_UNUSED(mods);
65 // Do nothing
66}
67
68void QWaylandDrag::endDrag()
69{
70 m_display->currentInputDevice()->handleEndDrag();
71}
72
73void QWaylandDrag::setResponse(bool accepted)
74{
75 // This method is used for old DataDevices where the drag action is not communicated
76 Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
77 setResponse(QPlatformDropQtResponse(accepted, action));
78}
79
80void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
81{
82 setCanDrop(response.isAccepted());
83
84 if (canDrop()) {
85 updateCursor(response.acceptedAction());
86 } else {
87 updateCursor(Qt::IgnoreAction);
88 }
89}
90
91void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
92{
93 setExecutedDropAction(response.acceptedAction());
94}
95
96void QWaylandDrag::finishDrag()
97{
99 eventFilter(shapedPixmapWindow(), &event);
100
101 if (drag())
102 drag()->deleteLater();
103}
104
105bool QWaylandDrag::ownsDragObject() const
106{
107 return true;
108}
109
110}
111#endif // draganddrop
virtual void startDrag()
virtual void cancel()
@ KeyPress
Definition qcoreevent.h:64
The QKeyEvent class describes a key event.
Definition qevent.h:423
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:1518
Qt::DropAction acceptedAction() const
\inmodule QtCore\reentrant
Definition qpoint.h:23
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:658
@ 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...