From 865bfc531c54dfdf3d53518bd7c2b08b7736eb73 Mon Sep 17 00:00:00 2001 From: Santhosh Kumar Date: Fri, 9 Jun 2023 13:17:01 +0200 Subject: [PATCH] Fix button state validation in windows platform during drag and drop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The button state from windows when we use GetAsynckeyState() provides both MK_LBUTTON and MK_RIGHTBUTTON at the same time. This creates an issue when we validate only with single state to determine DRAGDROP_S_DROP operation. Normally, The MK_RBUTTON will be delivered when we have long press during drag. But sometimes (no definitive reason identified) the key state from windows contains both the key state (MK_LBUTTON | Mk_RBUTTON) during drag and drop operation with touch. This patch set fixes the issue by validating all key state instead of a particular state. Fixes: QTBUG-112995 Change-Id: I67bf5f4956b68279ecc5fbeca8e8e7aef46d0482 Reviewed-by: Timothée Keller Reviewed-by: Qt CI Bot Reviewed-by: Wladimir Leuschner Reviewed-by: Shawn Rutledge (cherry picked from commit 3902fb0438d946a466b67f2b82ba8779c731e55d) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/windows/qwindowsdrag.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 48e0bba41ff..b797217c6fc 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -348,7 +348,7 @@ QWindowsOleDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) } else { if (buttons && !m_currentButtons) { m_currentButtons = buttons; - } else if (!(m_currentButtons & buttons)) { // Button changed: Complete Drop operation. + } else if (m_currentButtons != buttons) { // Button changed: Complete Drop operation. result = DRAGDROP_S_DROP; } }