summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Mardegan <mardy@users.sourceforge.net>2016-04-13 16:28:57 +0300
committerAlberto Mardegan <mardy@users.sourceforge.net>2016-05-09 20:46:14 +0000
commitab2cf73440e5fbda9e2a3ba15dc1df7895c49679 (patch)
treefc28dc85a543c91375b4164e69d772f931422c8e
parent50723bf3d0d56ba58dbf2343ea890b2d874239e9 (diff)
QXcbDrag: forward mouse release event to initiator window
The mouse release event which ends the drag and drop operation must be forwarded to the window where the drag started, and not to the QShapedPixmapWindow, which is not supposed to handle input events. Task-number: QTBUG-52541 Change-Id: I24a7c7b331a06342ac28b420ff9467aa05fe00dd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Błażej Szczygieł <spaz16@wp.pl> Reviewed-by: Dmitry Shachnev <mitya57@gmail.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp14
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index 529f91e1ec..6fa5dfa483 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -50,6 +50,7 @@
#include <qpa/qwindowsysteminterface.h>
+#include <private/qguiapplication_p.h>
#include <private/qshapedpixmapdndwindow_p.h>
#include <private/qsimpledrag_p.h>
#include <private/qhighdpiscaling_p.h>
@@ -170,6 +171,17 @@ QMimeData *QXcbDrag::platformDropData()
return dropData;
}
+bool QXcbDrag::eventFilter(QObject *o, QEvent *e)
+{
+ /* We are setting a mouse grab on the QShapedPixmapWindow in order not to
+ * lose the grab when the virtual desktop changes, but
+ * QBasicDrag::eventFilter() expects the events to be coming from the
+ * window where the drag was started. */
+ if (initiatorWindow && o == shapedPixmapWindow())
+ o = initiatorWindow.data();
+ return QBasicDrag::eventFilter(o, e);
+}
+
void QXcbDrag::startDrag()
{
// #fixme enableEventFilter();
@@ -194,6 +206,7 @@ void QXcbDrag::startDrag()
setUseCompositing(current_virtual_desktop->compositingActive());
setScreen(current_virtual_desktop->screens().constFirst()->screen());
+ initiatorWindow = QGuiApplicationPrivate::currentMouseWindow;
QBasicDrag::startDrag();
if (connection()->mouseGrabber() == Q_NULLPTR)
shapedPixmapWindow()->setMouseGrabEnabled(true);
@@ -202,6 +215,7 @@ void QXcbDrag::startDrag()
void QXcbDrag::endDrag()
{
QBasicDrag::endDrag();
+ initiatorWindow.clear();
}
static xcb_translate_coordinates_reply_t *
diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h
index c9d257906f..738da1268d 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.h
+++ b/src/plugins/platforms/xcb/qxcbdrag.h
@@ -69,6 +69,7 @@ public:
~QXcbDrag();
virtual QMimeData *platformDropData() Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE;
void startDrag() Q_DECL_OVERRIDE;
void cancel() Q_DECL_OVERRIDE;
@@ -106,6 +107,7 @@ private:
Qt::DropAction toDropAction(xcb_atom_t atom) const;
xcb_atom_t toXdndAction(Qt::DropAction a) const;
+ QPointer<QWindow> initiatorWindow;
QPointer<QWindow> currentWindow;
QPoint currentPosition;