summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorAndre de la Rocha <andre.rocha@qt.io>2019-02-18 16:16:23 +0100
committerAndre de la Rocha <andre.rocha@qt.io>2019-02-25 14:26:09 +0000
commit00cfb4d7801ec9b5d9b070879ef4a962390628b7 (patch)
tree88884f148b45bd53aa226f82d6d8e8af3a994956 /src/plugins/platforms/windows
parent1be070a2bef8b85caa5722ede60092b6038b13e6 (diff)
Windows QPA: Generate proper event when dragging item outside window
When an item was dragged outside the window, the mouse release event was not being properly delivered and the item would stick to mouse cursor after moving it back into the window. Fixes: QTBUG-72994 Change-Id: Ibce990390c866e16d58f7d969673dd05e862d97e Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index 95d1fc8b7d..322865b0f3 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -49,6 +49,7 @@
#include "qwindowswindow.h"
#include "qwindowsmousehandler.h"
#include "qwindowscursor.h"
+#include "qwindowskeymapper.h"
#include <QtGui/qevent.h>
#include <QtGui/qpixmap.h>
@@ -205,6 +206,9 @@ static inline Qt::MouseButtons toQtMouseButtons(DWORD keyState)
return buttons;
}
+static Qt::KeyboardModifiers lastModifiers = Qt::NoModifier;
+static Qt::MouseButtons lastButtons = Qt::NoButton;
+
/*!
\class QWindowsOleDropSource
\brief Implementation of IDropSource
@@ -403,7 +407,7 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
case DRAGDROP_S_DROP:
case DRAGDROP_S_CANCEL:
if (!m_windowUnderMouse.isNull() && m_mode != TouchDrag && fEscapePressed == FALSE
- && buttons != QGuiApplicationPrivate::mouse_buttons) {
+ && buttons != lastButtons) {
// QTBUG 66447: Synthesize a mouse release to the window under mouse at
// start of the DnD operation as Windows does not send any.
const QPoint globalPos = QWindowsCursor::mousePosition();
@@ -503,13 +507,14 @@ void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState,
QWindowsDrag *windowsDrag = QWindowsDrag::instance();
const Qt::DropActions actions = translateToQDragDropActions(*pdwEffect);
- const Qt::KeyboardModifiers keyboardModifiers = toQtKeyboardModifiers(grfKeyState);
- const Qt::MouseButtons mouseButtons = toQtMouseButtons(grfKeyState);
+
+ lastModifiers = toQtKeyboardModifiers(grfKeyState);
+ lastButtons = toQtMouseButtons(grfKeyState);
const QPlatformDragQtResponse response =
QWindowSystemInterface::handleDrag(window, windowsDrag->dropData(),
m_lastPoint, actions,
- mouseButtons, keyboardModifiers);
+ lastButtons, lastModifiers);
m_answerRect = response.answerRect();
const Qt::DropAction action = response.acceptedAction();
@@ -521,7 +526,7 @@ void QWindowsOleDropTarget::handleDrag(QWindow *window, DWORD grfKeyState,
*pdwEffect = m_chosenEffect;
qCDebug(lcQpaMime) << __FUNCTION__ << m_window
<< windowsDrag->dropData() << " supported actions=" << actions
- << " mods=" << keyboardModifiers << " mouse=" << mouseButtons
+ << " mods=" << lastModifiers << " mouse=" << lastButtons
<< " accepted: " << response.isAccepted() << action
<< m_answerRect << " effect" << *pdwEffect;
}
@@ -572,6 +577,9 @@ QWindowsOleDropTarget::DragLeave()
qCDebug(lcQpaMime) << __FUNCTION__ << ' ' << m_window;
+ lastModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
+ lastButtons = QWindowsMouseHandler::queryMouseButtons();
+
QWindowSystemInterface::handleDrag(m_window, nullptr, QPoint(), Qt::IgnoreAction,
Qt::NoButton, Qt::NoModifier);
@@ -598,12 +606,15 @@ QWindowsOleDropTarget::Drop(LPDATAOBJECT pDataObj, DWORD grfKeyState,
QWindowsDrag *windowsDrag = QWindowsDrag::instance();
+ lastModifiers = toQtKeyboardModifiers(grfKeyState);
+ lastButtons = toQtMouseButtons(grfKeyState);
+
const QPlatformDropQtResponse response =
QWindowSystemInterface::handleDrop(m_window, windowsDrag->dropData(),
m_lastPoint,
translateToQDragDropActions(*pdwEffect),
- toQtMouseButtons(grfKeyState),
- toQtKeyboardModifiers(grfKeyState));
+ lastButtons,
+ lastModifiers);
m_lastKeyState = grfKeyState;