From 2e5294883b77a9274b473fb17afa51a7f56ccb8f Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Wed, 22 Nov 2017 16:52:12 +0100 Subject: Windows QPA: Avoid 'large' mouse cursors over RDP On some combinations of RDP client and server a large mouse cursor results in a hang of the RDP session. However, the 'touch' drag facility (creating a transparent window) works just fine, so use that when encountering a large cursor on RDP. (The threshold of 96 for a 'large' cursor was extracted from the spec, as that is the largest supported size mentioned.) Change-Id: I9782c45e8bd6640f36bb5a392961681a99e214e6 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsdrag.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/windows/qwindowsdrag.cpp') diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index aa6454ef63..777c45ae86 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -246,7 +246,7 @@ private: typedef QMap ActionCursorMap; - const Mode m_mode; + Mode m_mode; QWindowsDrag *m_drag; Qt::MouseButtons m_currentButtons; ActionCursorMap m_cursors; @@ -301,6 +301,15 @@ void QWindowsOleDropSource::createCursors() Q_ASSERT(platformScreen); QPlatformCursor *platformCursor = platformScreen->cursor(); + if (GetSystemMetrics (SM_REMOTESESSION) != 0) { + /* Workaround for RDP issues with large cursors. + * Touch drag window seems to work just fine... + * 96 pixel is a 'large' mouse cursor, according to RDP spec */ + const int rdpLargeCursor = qRound(qreal(96) / QHighDpiScaling::factor(platformScreen)); + if (pixmap.width() > rdpLargeCursor || pixmap.height() > rdpLargeCursor) + m_mode = TouchDrag; + } + qreal pixmapScaleFactor = 1; qreal hotSpotScaleFactor = 1; if (m_mode != TouchDrag) { // Touch drag: pixmap is shown in a separate QWindow, which will be scaled.) @@ -433,6 +442,9 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect) SetCursor(e.cursor->handle()); break; case TouchDrag: + // "Touch drag" with an unsuppressed cursor may happen with RDP (see createCursors()) + if (QWindowsCursor::cursorState() != QWindowsCursor::CursorSuppressed) + SetCursor(nullptr); if (!m_touchDragWindow) m_touchDragWindow = new QWindowsDragCursorWindow; m_touchDragWindow->setPixmap(e.pixmap); -- cgit v1.2.3