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 <Friedemann.Kleint@qt.io>
bb10
Frank Richter 2017-11-22 16:52:12 +01:00
parent 5e8bc07cb2
commit 2e5294883b
1 changed files with 13 additions and 1 deletions

View File

@ -246,7 +246,7 @@ private:
typedef QMap<Qt::DropAction, CursorEntry> 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);