diff options
Diffstat (limited to 'src/plugins/platforms/vnc')
-rw-r--r-- | src/plugins/platforms/vnc/CMakeLists.txt | 35 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/main.cpp | 46 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvnc.cpp | 143 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvnc_p.h | 44 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncclient.cpp | 50 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncclient.h | 42 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncintegration.cpp | 51 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncintegration.h | 40 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncscreen.cpp | 71 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncscreen.h | 40 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/vnc.pro | 31 |
11 files changed, 147 insertions, 446 deletions
diff --git a/src/plugins/platforms/vnc/CMakeLists.txt b/src/plugins/platforms/vnc/CMakeLists.txt new file mode 100644 index 0000000000..34370807ae --- /dev/null +++ b/src/plugins/platforms/vnc/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## QVncIntegrationPlugin Plugin: +##################################################################### + +qt_internal_add_plugin(QVncIntegrationPlugin + OUTPUT_NAME qvnc + PLUGIN_TYPE platforms + DEFAULT_IF "vnc" IN_LIST QT_QPA_PLATFORMS + SOURCES + main.cpp + qvnc.cpp qvnc_p.h + qvncclient.cpp qvncclient.h + qvncintegration.cpp qvncintegration.h + qvncscreen.cpp qvncscreen.h + DEFINES + QT_NO_FOREACH + LIBRARIES + Qt::Core + Qt::CorePrivate + Qt::FbSupportPrivate + Qt::Gui + Qt::GuiPrivate + Qt::Network +) + +## Scopes: +##################################################################### + +qt_internal_extend_target(QVncIntegrationPlugin CONDITION TARGET Qt::InputSupportPrivate + LIBRARIES + Qt::InputSupportPrivate +) diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index 3ec0f0b78d..43c59454a3 100644 --- a/src/plugins/platforms/vnc/main.cpp +++ b/src/plugins/platforms/vnc/main.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <qpa/qplatformintegrationplugin.h> #include "qvncintegration.h" @@ -43,6 +7,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class QVncIntegrationPlugin : public QPlatformIntegrationPlugin { Q_OBJECT @@ -53,10 +19,10 @@ public: QPlatformIntegration* QVncIntegrationPlugin::create(const QString& system, const QStringList& paramList) { - if (!system.compare(QLatin1String("vnc"), Qt::CaseInsensitive)) + if (!system.compare("vnc"_L1, Qt::CaseInsensitive)) return new QVncIntegration(paramList); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp index 32114c6443..99e80e5801 100644 --- a/src/plugins/platforms/vnc/qvnc.cpp +++ b/src/plugins/platforms/vnc/qvnc.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qvnc_p.h" #include "qvncscreen.h" #include "qvncclient.h" @@ -48,7 +12,7 @@ #include <QtGui/QWindow> #ifdef Q_OS_WIN -#include <Winsock2.h> +#include <winsock2.h> #else #include <arpa/inet.h> #endif @@ -245,7 +209,7 @@ static const struct { void QRfbRect::read(QTcpSocket *s) { quint16 buf[4]; - s->read((char*)buf, 8); + s->read(reinterpret_cast<char*>(buf), 8); x = ntohs(buf[0]); y = ntohs(buf[1]); w = ntohs(buf[2]); @@ -259,7 +223,7 @@ void QRfbRect::write(QTcpSocket *s) const buf[1] = htons(y); buf[2] = htons(w); buf[3] = htons(h); - s->write((char*)buf, 8); + s->write(reinterpret_cast<char*>(buf) , 8); } void QRfbPixelFormat::read(QTcpSocket *s) @@ -271,15 +235,15 @@ void QRfbPixelFormat::read(QTcpSocket *s) bigEndian = buf[2]; trueColor = buf[3]; - quint16 a = ntohs(*(quint16 *)(buf + 4)); + quint16 a = ntohs(*reinterpret_cast<quint16 *>(buf + 4)); redBits = 0; while (a) { a >>= 1; redBits++; } - a = ntohs(*(quint16 *)(buf + 6)); + a = ntohs(*reinterpret_cast<quint16 *>(buf + 6)); greenBits = 0; while (a) { a >>= 1; greenBits++; } - a = ntohs(*(quint16 *)(buf + 8)); + a = ntohs(*reinterpret_cast<quint16 *>(buf + 8)); blueBits = 0; while (a) { a >>= 1; blueBits++; } @@ -298,15 +262,15 @@ void QRfbPixelFormat::write(QTcpSocket *s) quint16 a = 0; for (int i = 0; i < redBits; i++) a = (a << 1) | 1; - *(quint16 *)(buf + 4) = htons(a); + *reinterpret_cast<quint16 *>(buf + 4) = htons(a); a = 0; for (int i = 0; i < greenBits; i++) a = (a << 1) | 1; - *(quint16 *)(buf + 6) = htons(a); + *reinterpret_cast<quint16 *>(buf + 6) = htons(a); a = 0; for (int i = 0; i < blueBits; i++) a = (a << 1) | 1; - *(quint16 *)(buf + 8) = htons(a); + *reinterpret_cast<quint16 *>(buf + 8) = htons(a); buf[10] = redShift; buf[11] = greenShift; @@ -324,14 +288,14 @@ void QRfbServerInit::setName(const char *n) void QRfbServerInit::read(QTcpSocket *s) { - s->read((char *)&width, 2); + s->read(reinterpret_cast<char *>(&width), 2); width = ntohs(width); - s->read((char *)&height, 2); + s->read(reinterpret_cast<char *>(&height), 2); height = ntohs(height); format.read(s); quint32 len; - s->read((char *)&len, 4); + s->read(reinterpret_cast<char *>(&len), 4); len = ntohl(len); name = new char [len + 1]; @@ -342,14 +306,14 @@ void QRfbServerInit::read(QTcpSocket *s) void QRfbServerInit::write(QTcpSocket *s) { quint16 t = htons(width); - s->write((char *)&t, 2); + s->write(reinterpret_cast<char *>(&t), 2); t = htons(height); - s->write((char *)&t, 2); + s->write(reinterpret_cast<char *>(&t), 2); format.write(s); - quint32 len = strlen(name); + quint32 len = static_cast<quint32>(strlen(name)); len = htonl(len); - s->write((char *)&len, 4); - s->write(name, strlen(name)); + s->write(reinterpret_cast<char *>(&len), 4); + s->write(name, static_cast<qint64>(strlen(name))); } bool QRfbSetEncodings::read(QTcpSocket *s) @@ -359,7 +323,7 @@ bool QRfbSetEncodings::read(QTcpSocket *s) char tmp; s->read(&tmp, 1); // padding - s->read((char *)&count, 2); + s->read(reinterpret_cast<char *>(&count), 2); count = ntohs(count); return true; @@ -383,17 +347,17 @@ bool QRfbKeyEvent::read(QTcpSocket *s) s->read(&down, 1); quint16 tmp; - s->read((char *)&tmp, 2); // padding + s->read(reinterpret_cast<char *>(&tmp), 2); // padding quint32 key; - s->read((char *)&key, 4); + s->read(reinterpret_cast<char *>(&key), 4); key = ntohl(key); unicode = 0; keycode = 0; int i = 0; while (keyMap[i].keysym && !keycode) { - if (keyMap[i].keysym == (int)key) + if (keyMap[i].keysym == static_cast<int>(key)) keycode = keyMap[i].keycode; i++; } @@ -425,14 +389,14 @@ bool QRfbPointerEvent::read(QTcpSocket *s) if (buttonMask & 1) buttons |= Qt::LeftButton; if (buttonMask & 2) - buttons |= Qt::MidButton; + buttons |= Qt::MiddleButton; if (buttonMask & 4) buttons |= Qt::RightButton; quint16 tmp; - s->read((char *)&tmp, 2); + s->read(reinterpret_cast<char *>(&tmp), 2); x = ntohs(tmp); - s->read((char *)&tmp, 2); + s->read(reinterpret_cast<char *>(&tmp), 2); y = ntohs(tmp); return true; @@ -445,7 +409,7 @@ bool QRfbClientCutText::read(QTcpSocket *s) char tmp[3]; s->read(tmp, 3); // padding - s->read((char *)&length, 4); + s->read(reinterpret_cast<char *>(&length), 4); length = ntohl(length); return true; @@ -477,6 +441,9 @@ void QRfbRawEncoder::write() // server->screen()->geometry().height()); // } + const QImage screenImage = client->server()->screenImage(); + rgn &= screenImage.rect(); + const auto rectsInRegion = rgn.rectCount(); { @@ -486,23 +453,21 @@ void QRfbRawEncoder::write() { const quint16 count = htons(rectsInRegion); - socket->write((char *)&count, sizeof(count)); + socket->write(reinterpret_cast<const char *>(&count), sizeof(count)); } if (rectsInRegion <= 0) return; - const QImage screenImage = client->server()->screenImage(); - for (const QRect &tileRect: rgn) { const QRfbRect rect(tileRect.x(), tileRect.y(), tileRect.width(), tileRect.height()); rect.write(socket); const quint32 encoding = htonl(0); // raw encoding - socket->write((char *)&encoding, sizeof(encoding)); + socket->write(reinterpret_cast<const char *>(&encoding), sizeof(encoding)); - int linestep = screenImage.bytesPerLine(); + qsizetype linestep = screenImage.bytesPerLine(); const uchar *screendata = screenImage.scanLine(rect.y) + rect.x * screenImage.depth() / 8; @@ -514,15 +479,16 @@ void QRfbRawEncoder::write() // convert pixels char *b = buffer.data(); const int bstep = rect.w * bytesPerPixel; + const int depth = screenImage.depth(); for (int i = 0; i < rect.h; ++i) { - client->convertPixels(b, (const char*)screendata, rect.w); + client->convertPixels(b, reinterpret_cast<const char*>(screendata), rect.w, depth); screendata += linestep; b += bstep; } socket->write(buffer.constData(), bufferSize); } else { for (int i = 0; i < rect.h; ++i) { - socket->write((const char*)screendata, rect.w * bytesPerPixel); + socket->write(reinterpret_cast<const char*>(screendata), rect.w * bytesPerPixel); screendata += linestep; } } @@ -537,7 +503,7 @@ QVncClientCursor::QVncClientCursor() { QWindow *w = QGuiApplication::focusWindow(); QCursor c = w ? w->cursor() : QCursor(Qt::ArrowCursor); - changeCursor(&c, 0); + changeCursor(&c, nullptr); } QVncClientCursor::~QVncClientCursor() @@ -552,13 +518,13 @@ void QVncClientCursor::write(QVncClient *client) const { const quint16 tmp[6] = { htons(0), htons(1), - htons(uint16_t(hotspot.x())), htons(uint16_t(hotspot.y())), - htons(uint16_t(cursor.width())), - htons(uint16_t(cursor.height())) }; - socket->write((char*)tmp, sizeof(tmp)); + htons(static_cast<uint16_t>(hotspot.x())), htons(static_cast<uint16_t>(hotspot.y())), + htons(static_cast<uint16_t>(cursor.width())), + htons(static_cast<uint16_t>(cursor.height())) }; + socket->write(reinterpret_cast<const char*>(tmp), sizeof(tmp)); const qint32 encoding = qToBigEndian(-239); - socket->write((char*)(&encoding), sizeof(encoding)); + socket->write(reinterpret_cast<const char*>(&encoding), sizeof(encoding)); } if (cursor.isNull()) @@ -568,9 +534,10 @@ void QVncClientCursor::write(QVncClient *client) const Q_ASSERT(cursor.hasAlphaChannel()); const QImage img = cursor.convertToFormat(client->server()->screen()->format()); const int n = client->clientBytesPerPixel() * img.width(); + const int depth = img.depth(); char *buffer = new char[n]; for (int i = 0; i < img.height(); ++i) { - client->convertPixels(buffer, (const char*)img.scanLine(i), img.width()); + client->convertPixels(buffer, (const char*)img.scanLine(i), img.width(), depth); socket->write(buffer, n); } delete[] buffer; @@ -581,7 +548,7 @@ void QVncClientCursor::write(QVncClient *client) const Q_ASSERT(bitmap.size() == img.size()); const int width = (bitmap.width() + 7) / 8; for (int i = 0; i < bitmap.height(); ++i) - socket->write((const char*)bitmap.scanLine(i), width); + socket->write(reinterpret_cast<const char*>(bitmap.scanLine(i)), width); } void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window) @@ -595,25 +562,28 @@ void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window) cursor = widgetCursor->pixmap().toImage(); } else { // system cursor - QPlatformCursorImage platformImage(0, 0, 0, 0, 0, 0); + QPlatformCursorImage platformImage(nullptr, nullptr, 0, 0, 0, 0); platformImage.set(shape); cursor = *platformImage.image(); hotspot = platformImage.hotspot(); } - for (auto client : qAsConst(clients)) + for (auto client : std::as_const(clients)) client->setDirtyCursor(); } void QVncClientCursor::addClient(QVncClient *client) { - if (!clients.contains(client)) + if (!clients.contains(client)) { clients.append(client); + // Force a cursor update when the client connects. + client->setDirtyCursor(); + } } uint QVncClientCursor::removeClient(QVncClient *client) { clients.removeOne(client); - return clients.count(); + return clients.size(); } #endif // QT_CONFIG(cursor) @@ -643,7 +613,7 @@ QVncServer::~QVncServer() void QVncServer::setDirty() { - for (auto client : qAsConst(clients)) + for (auto client : std::as_const(clients)) client->setDirty(qvnc_screen->dirtyRegion); qvnc_screen->clearDirty(); @@ -665,11 +635,10 @@ void QVncServer::newConnection() void QVncServer::discardClient(QVncClient *client) { clients.removeOne(client); + qvnc_screen->disableClientCursor(client); client->deleteLater(); - if (clients.isEmpty()) { - qvnc_screen->disableClientCursor(client); + if (clients.isEmpty()) qvnc_screen->setPowerState(QPlatformScreen::PowerStateOff); - } } inline QImage QVncServer::screenImage() const @@ -678,3 +647,5 @@ inline QImage QVncServer::screenImage() const } QT_END_NAMESPACE + +#include "moc_qvnc_p.cpp" diff --git a/src/plugins/platforms/vnc/qvnc_p.h b/src/plugins/platforms/vnc/qvnc_p.h index f7f2f74ddb..642f872c21 100644 --- a/src/plugins/platforms/vnc/qvnc_p.h +++ b/src/plugins/platforms/vnc/qvnc_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QVNC_P_H #define QVNC_P_H @@ -380,7 +344,7 @@ public: QImage cursor; QPoint hotspot; - QVector<QVncClient *> clients; + QList<QVncClient *> clients; }; #endif // QT_CONFIG(cursor) @@ -408,7 +372,7 @@ private slots: private: QTcpServer *serverSocket; - QVector<QVncClient*> clients; + QList<QVncClient*> clients; QVncScreen *qvnc_screen; quint16 m_port; }; diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp index 2450f7dad5..b3aafd0194 100644 --- a/src/plugins/platforms/vnc/qvncclient.cpp +++ b/src/plugins/platforms/vnc/qvncclient.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qvncclient.h" #include "qvnc_p.h" @@ -47,7 +11,7 @@ #include <QtGui/qguiapplication.h> #ifdef Q_OS_WIN -#include <Winsock2.h> +#include <winsock2.h> #else #include <arpa/inet.h> #endif @@ -97,10 +61,8 @@ void QVncClient::setDirty(const QRegion ®ion) } } -void QVncClient::convertPixels(char *dst, const char *src, int count) const +void QVncClient::convertPixels(char *dst, const char *src, int count, int screendepth) const { - const int screendepth = m_server->screen()->depth(); - // cutoffs #if Q_BYTE_ORDER == Q_BIG_ENDIAN if (!m_swapBytes) @@ -617,7 +579,7 @@ void QVncClient::keyEvent() m_keymod = ev.down ? m_keymod | Qt::AltModifier : m_keymod & ~Qt::AltModifier; if (ev.unicode || ev.keycode) - QWindowSystemInterface::handleKeyEvent(0, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(ev.unicode)); + QWindowSystemInterface::handleKeyEvent(nullptr, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(QChar::fromUcs2(ev.unicode))); m_handleMsg = false; } } @@ -668,3 +630,5 @@ bool QVncClient::pixelConversionNeeded() const } QT_END_NAMESPACE + +#include "moc_qvncclient.cpp" diff --git a/src/plugins/platforms/vnc/qvncclient.h b/src/plugins/platforms/vnc/qvncclient.h index a7a6b6b361..4c4c8d71e5 100644 --- a/src/plugins/platforms/vnc/qvncclient.h +++ b/src/plugins/platforms/vnc/qvncclient.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QVNCCLIENT_H #define QVNCCLIENT_H @@ -77,7 +41,7 @@ public: return m_pixelFormat.bitsPerPixel / 8; } - void convertPixels(char *dst, const char *src, int count) const; + void convertPixels(char *dst, const char *src, int count, int depth) const; inline bool doPixelConversion() const { return m_needConversion; } signals: diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index c7a796464a..48e6567d89 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -1,49 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qvncintegration.h" #include "qvncscreen.h" #include "qvnc_p.h" -#include <QtFontDatabaseSupport/private/qgenericunixfontdatabase_p.h> -#include <QtServiceSupport/private/qgenericunixservices_p.h> -#include <QtEventDispatcherSupport/private/qgenericunixeventdispatcher_p.h> +#include <QtGui/private/qgenericunixfontdatabase_p.h> +#include <QtGui/private/qgenericunixservices_p.h> +#include <QtGui/private/qgenericunixeventdispatcher_p.h> #include <QtFbSupport/private/qfbbackingstore_p.h> #include <QtFbSupport/private/qfbwindow_p.h> @@ -58,11 +22,13 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QVncIntegration::QVncIntegration(const QStringList ¶mList) : m_fontDb(new QGenericUnixFontDatabase), m_services(new QGenericUnixServices) { - QRegularExpression portRx(QLatin1String("port=(\\d+)")); + QRegularExpression portRx("port=(\\d+)"_L1); quint16 port = 5900; for (const QString &arg : paramList) { QRegularExpressionMatch match; @@ -105,6 +71,7 @@ bool QVncIntegration::hasCapability(QPlatformIntegration::Capability cap) const switch (cap) { case ThreadedPixmaps: return true; case WindowManagement: return false; + case RhiBasedRendering: return false; default: return QPlatformIntegration::hasCapability(cap); } } diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h index 34a6a6b941..6c00ba8493 100644 --- a/src/plugins/platforms/vnc/qvncintegration.h +++ b/src/plugins/platforms/vnc/qvncintegration.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QVNCINTEGRATION_H #define QVNCINTEGRATION_H diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp index 2eca18fb4d..c87df20ef6 100644 --- a/src/plugins/platforms/vnc/qvncscreen.cpp +++ b/src/plugins/platforms/vnc/qvncscreen.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qvncscreen.h" #include "qvnc_p.h" @@ -49,6 +13,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QVncScreen::QVncScreen(const QStringList &args) : mArgs(args) @@ -66,16 +32,16 @@ QVncScreen::~QVncScreen() bool QVncScreen::initialize() { - QRegularExpression sizeRx(QLatin1String("size=(\\d+)x(\\d+)")); - QRegularExpression mmSizeRx(QLatin1String("mmsize=(?<width>(\\d*\\.)?\\d+)x(?<height>(\\d*\\.)?\\d+)")); - QRegularExpression depthRx(QLatin1String("depth=(\\d+)")); + QRegularExpression sizeRx("size=(\\d+)x(\\d+)"_L1); + QRegularExpression mmSizeRx("mmsize=(?<width>(\\d*\\.)?\\d+)x(?<height>(\\d*\\.)?\\d+)"_L1); + QRegularExpression depthRx("depth=(\\d+)"_L1); mGeometry = QRect(0, 0, 1024, 768); mFormat = QImage::Format_ARGB32_Premultiplied; mDepth = 32; mPhysicalSize = QSizeF(mGeometry.width()/96.*25.4, mGeometry.height()/96.*25.4); - for (const QString &arg : qAsConst(mArgs)) { + for (const QString &arg : std::as_const(mArgs)) { QRegularExpressionMatch match; if (arg.contains(mmSizeRx, &match)) { mPhysicalSize = QSizeF(match.captured("width").toDouble(), match.captured("height").toDouble()); @@ -86,14 +52,13 @@ bool QVncScreen::initialize() } } - QFbScreen::initializeCompositor(); - switch (depth()) { case 32: dirty = new QVncDirtyMapOptimized<quint32>(this); break; case 16: dirty = new QVncDirtyMapOptimized<quint16>(this); + mFormat = QImage::Format_RGB16; break; case 8: dirty = new QVncDirtyMapOptimized<quint8>(this); @@ -101,10 +66,12 @@ bool QVncScreen::initialize() default: qWarning("QVNCScreen::initDevice: No support for screen depth %d", depth()); - dirty = 0; + dirty = nullptr; return false; } + QFbScreen::initializeCompositor(); + setPowerState(PowerStateOff); return true; @@ -132,22 +99,26 @@ void QVncScreen::enableClientCursor(QVncClient *client) clientCursor = new QVncClientCursor(); clientCursor->addClient(client); #else - Q_UNUSED(client) + Q_UNUSED(client); #endif } void QVncScreen::disableClientCursor(QVncClient *client) { #if QT_CONFIG(cursor) + if (!clientCursor) + return; + uint clientCount = clientCursor->removeClient(client); if (clientCount == 0) { delete clientCursor; clientCursor = nullptr; - } - mCursor = new QFbCursor(this); + if (mCursor == nullptr) + mCursor = new QFbCursor(this); + } #else - Q_UNUSED(client) + Q_UNUSED(client); #endif } @@ -210,3 +181,5 @@ QFbScreen::Flags QVncScreen::flags() const QT_END_NAMESPACE +#include "moc_qvncscreen.cpp" + diff --git a/src/plugins/platforms/vnc/qvncscreen.h b/src/plugins/platforms/vnc/qvncscreen.h index db658d4ecc..a954a670ec 100644 --- a/src/plugins/platforms/vnc/qvncscreen.h +++ b/src/plugins/platforms/vnc/qvncscreen.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QVncScreen_H #define QVncScreen_H diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro deleted file mode 100644 index 1fa682303f..0000000000 --- a/src/plugins/platforms/vnc/vnc.pro +++ /dev/null @@ -1,31 +0,0 @@ -TARGET = qvnc - -QT += \ - core-private network gui-private \ - service_support-private theme_support-private fb_support-private \ - eventdispatcher_support-private fontdatabase_support-private - -qtHaveModule(input_support-private): \ - QT += input_support-private - -DEFINES += QT_NO_FOREACH - -SOURCES = \ - main.cpp \ - qvncintegration.cpp \ - qvncscreen.cpp \ - qvnc.cpp \ - qvncclient.cpp - -HEADERS = \ - qvncintegration.h \ - qvncscreen.h \ - qvnc_p.h \ - qvncclient.h - -OTHER_FILES += vnc.json - -PLUGIN_TYPE = platforms -PLUGIN_CLASS_NAME = QVncIntegrationPlugin -!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - -load(qt_plugin) |