diff --git a/src/private/DragController.cpp b/src/private/DragController.cpp index d36a6be7..a1bd471c 100644 --- a/src/private/DragController.cpp +++ b/src/private/DragController.cpp @@ -331,6 +331,7 @@ void StateDraggingWayland::onEntry(QEvent *) auto mimeData = new WaylandMimeData(); QDrag drag(this); drag.setMimeData(mimeData); + drag.setPixmap(q->m_windowBeingDragged->pixmap()); qApp->installEventFilter(q); const Qt::DropAction result = drag.exec(); diff --git a/src/private/WindowBeingDragged.cpp b/src/private/WindowBeingDragged.cpp index 1e5c8468..3a252b19 100644 --- a/src/private/WindowBeingDragged.cpp +++ b/src/private/WindowBeingDragged.cpp @@ -15,6 +15,8 @@ #include "Utils_p.h" #include "DropArea_p.h" +#include + using namespace KDDockWidgets; static Draggable* bestDraggable(Draggable *draggable) @@ -143,3 +145,13 @@ bool WindowBeingDragged::contains(DropArea *dropArea) const return m_floatingWindow && m_floatingWindow->dropArea() == dropArea; } + +QPixmap WindowBeingDragged::pixmap() const +{ + QPixmap pixmap(size()); + + if (m_floatingWindow) + m_floatingWindow->render(&pixmap); + + return pixmap; +} diff --git a/src/private/WindowBeingDragged_p.h b/src/private/WindowBeingDragged_p.h index 2b65957e..32562eb1 100644 --- a/src/private/WindowBeingDragged_p.h +++ b/src/private/WindowBeingDragged_p.h @@ -17,6 +17,10 @@ #include +QT_BEGIN_NAMESPACE +class QPixmap; +QT_END_NAMESPACE + namespace KDDockWidgets { class FloatingWindow; @@ -55,6 +59,10 @@ public: /// @brief returns whether the window being dragged contains the specified drop area /// useful since we don't want to drop onto outselves. bool contains(DropArea *) const; + + /// @brief Returns a pixmap representing this Window. For purposes of QDrag + /// For wayland only + QPixmap pixmap() const; private: Q_DISABLE_COPY(WindowBeingDragged) QPointer m_floatingWindow;