From 1f1b773a35a1403af02c5f5a359933bfc459457d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 17 Dec 2015 13:29:34 +0100 Subject: Support for client side cursors in the VNC plugin Client side cursors are a major performance optimization, avoiding the need to transmit images to the client just because the cursor has moved. Change-Id: Icdf4ff948571d39d82c86d251bca46390889d02f Reviewed-by: Frederik Gladhorn --- src/plugins/platforms/vnc/qvnc.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'src/plugins/platforms/vnc/qvnc.cpp') diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp index da03d889a6..6b9c55e4db 100644 --- a/src/plugins/platforms/vnc/qvnc.cpp +++ b/src/plugins/platforms/vnc/qvnc.cpp @@ -526,6 +526,9 @@ void QRfbRawEncoder::write() QVncClientCursor::QVncClientCursor(QVncServer *s) : server(s) { + QWindow *w = QGuiApplication::focusWindow(); + QCursor c = w ? w->cursor() : QCursor(Qt::ArrowCursor); + changeCursor(&c, 0); } QVncClientCursor::~QVncClientCursor() @@ -634,9 +637,6 @@ void QVncServer::init() connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection())); -#ifndef QT_NO_QWS_CURSOR - qvnc_cursor = 0; -#endif encoder = 0; } @@ -646,10 +646,6 @@ QVncServer::~QVncServer() encoder = 0; delete client; client = 0; -#ifndef QT_NO_QWS_CURSOR - delete qvnc_cursor; - qvnc_cursor = 0; -#endif } void QVncServer::setDirty() @@ -977,10 +973,8 @@ void QVncServer::setEncodings() break; case Cursor: supportCursor = true; - if (!qvnc_screen->screen()) { - delete qvnc_cursor; - qvnc_cursor = new QVncClientCursor(this); - } + qDebug() << "client side cursor supported."; + qvnc_screen->enableClientCursor(); break; case DesktopSize: supportDesktopSize = true; @@ -1259,10 +1253,7 @@ void QVncServer::checkUpdate() return; if (dirtyCursor) { -#ifndef QT_NO_QWS_CURSOR - Q_ASSERT(qvnc_cursor); - qvnc_cursor->write(); -#endif + qvnc_screen->clientCursor->write(); dirtyCursor = false; wantUpdate = false; return; @@ -1287,11 +1278,7 @@ void QVncServer::discardClient() state = Disconnected; delete encoder; encoder = 0; -#ifndef QT_NO_QWS_CURSOR - delete qvnc_cursor; - qvnc_cursor = 0; -#endif - + qvnc_screen->disableClientCursor(); qvnc_screen->setPowerState(QPlatformScreen::PowerStateOff); } -- cgit v1.2.3