diff options
author | David Edmundson <davidedmundson@kde.org> | 2023-05-17 09:06:03 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-10-23 12:40:10 +0000 |
commit | 5b05fec4f2016107bc21aaba4a3e74b6a8c82795 (patch) | |
tree | a0044664d90c7a5952522df8b63f70f66f46854b /src | |
parent | b42f90ab96ede109ee7ac5ba4ddb4697d346e0bd (diff) |
Client: Always populate mimedata in drags
It's possible for clients to perform a drag and drop operation within
their own client without any mimeData. A user can directly access the
original drag.
On wayland without any mimedata it's impossible for a client to accept a
drag as the mechansim involved is to either select a given mimedata
entry or an empty string. Within Qt we always accept the first format if
we accept a drag.
When dragging within our own window we also start a wayland drag so will
receive a cancel event from the compositor if the compositor doesn't
believe the client has accepted the drag.
This patch provides a dummy mimedata entry so that something can be
accepted.
Fixes: QTBUG-112161
Pick-to: 6.5 6.2 5.15
Change-Id: I6309d82e20545e10ebdb9dafde7e13a5e3be5ff2
Reviewed-by: Liang Qi <liang.qi@qt.io>
(cherry picked from commit 32fedb6fa6579711b6cb192a2e3cfb7ad1264546)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/qwaylanddatadevice.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp index fe8e91235..3344d3806 100644 --- a/src/client/qwaylanddatadevice.cpp +++ b/src/client/qwaylanddatadevice.cpp @@ -93,6 +93,12 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supporte return false; } + // dragging data without mimetypes is a legal operation in Qt terms + // but Wayland uses a mimetype to determine if a drag is accepted or not + // In this rare case, insert a placeholder + if (mimeData->formats().isEmpty()) + mimeData->setData("application/x-qt-avoid-empty-placeholder"_L1, QByteArray("1")); + m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData)); if (version() >= 3) |