diff options
Diffstat (limited to 'src/plugins/platforms/vnc')
-rw-r--r-- | src/plugins/platforms/vnc/.prev_CMakeLists.txt | 39 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/CMakeLists.txt | 17 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/main.cpp | 44 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvnc.cpp | 130 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvnc_p.h | 40 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncclient.cpp | 48 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncclient.h | 42 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncintegration.cpp | 45 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncintegration.h | 40 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncscreen.cpp | 62 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/qvncscreen.h | 40 | ||||
-rw-r--r-- | src/plugins/platforms/vnc/vnc.pro | 30 |
12 files changed, 97 insertions, 480 deletions
diff --git a/src/plugins/platforms/vnc/.prev_CMakeLists.txt b/src/plugins/platforms/vnc/.prev_CMakeLists.txt deleted file mode 100644 index 48e172ed70..0000000000 --- a/src/plugins/platforms/vnc/.prev_CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Generated from vnc.pro. - -##################################################################### -## QVncIntegrationPlugin Plugin: -##################################################################### - -qt_internal_add_plugin(QVncIntegrationPlugin - OUTPUT_NAME qvnc - TYPE 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 - PUBLIC_LIBRARIES - Qt::Core - Qt::CorePrivate - Qt::FbSupportPrivate - Qt::Gui - Qt::GuiPrivate - Qt::Network -) - -#### Keys ignored in scope 1:.:.:vnc.pro:<TRUE>: -# OTHER_FILES = "vnc.json" - -## Scopes: -##################################################################### - -qt_internal_extend_target(QVncIntegrationPlugin CONDITION TARGET Qt::InputSupportPrivate - PUBLIC_LIBRARIES - Qt::InputSupportPrivate -) - -#### Keys ignored in scope 3:.:.:vnc.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: -# PLUGIN_EXTENDS = "-" diff --git a/src/plugins/platforms/vnc/CMakeLists.txt b/src/plugins/platforms/vnc/CMakeLists.txt index f3782b5434..25cb399bd0 100644 --- a/src/plugins/platforms/vnc/CMakeLists.txt +++ b/src/plugins/platforms/vnc/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from vnc.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## QVncIntegrationPlugin Plugin: @@ -6,8 +7,8 @@ qt_internal_add_plugin(QVncIntegrationPlugin OUTPUT_NAME qvnc - TYPE platforms - DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES vnc # special case + PLUGIN_TYPE platforms + DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES vnc SOURCES main.cpp qvnc.cpp qvnc_p.h @@ -16,7 +17,7 @@ qt_internal_add_plugin(QVncIntegrationPlugin qvncscreen.cpp qvncscreen.h DEFINES QT_NO_FOREACH - PUBLIC_LIBRARIES + LIBRARIES Qt::Core Qt::CorePrivate Qt::FbSupportPrivate @@ -25,16 +26,10 @@ qt_internal_add_plugin(QVncIntegrationPlugin Qt::Network ) -#### Keys ignored in scope 1:.:.:vnc.pro:<TRUE>: -# OTHER_FILES = "vnc.json" - ## Scopes: ##################################################################### qt_internal_extend_target(QVncIntegrationPlugin CONDITION TARGET Qt::InputSupportPrivate - PUBLIC_LIBRARIES + LIBRARIES Qt::InputSupportPrivate ) - -#### Keys ignored in scope 3:.:.:vnc.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: -# PLUGIN_EXTENDS = "-" diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index ac7e18e03f..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,7 +19,7 @@ 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 nullptr; diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp index d1dc6634af..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++; } @@ -430,9 +394,9 @@ bool QRfbPointerEvent::read(QTcpSocket *s) 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,21 +453,19 @@ 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)); qsizetype linestep = screenImage.bytesPerLine(); const uchar *screendata = screenImage.scanLine(rect.y) @@ -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; } } @@ -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) @@ -600,7 +567,7 @@ void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window) cursor = *platformImage.image(); hotspot = platformImage.hotspot(); } - for (auto client : qAsConst(clients)) + for (auto client : std::as_const(clients)) client->setDirtyCursor(); } @@ -616,7 +583,7 @@ void QVncClientCursor::addClient(QVncClient *client) uint QVncClientCursor::removeClient(QVncClient *client) { clients.removeOne(client); - return clients.count(); + return clients.size(); } #endif // QT_CONFIG(cursor) @@ -646,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(); @@ -668,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 @@ -681,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 9c71cd8f94..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 diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp index ba0ef90891..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) @@ -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 9836839274..48e6567d89 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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" @@ -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 7ef23601ba..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); @@ -105,6 +70,8 @@ bool QVncScreen::initialize() return false; } + QFbScreen::initializeCompositor(); + setPowerState(PowerStateOff); return true; @@ -146,9 +113,10 @@ void QVncScreen::disableClientCursor(QVncClient *client) if (clientCount == 0) { delete clientCursor; clientCursor = nullptr; - } - mCursor = new QFbCursor(this); + if (mCursor == nullptr) + mCursor = new QFbCursor(this); + } #else Q_UNUSED(client); #endif @@ -213,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 a250ba999e..0000000000 --- a/src/plugins/platforms/vnc/vnc.pro +++ /dev/null @@ -1,30 +0,0 @@ -TARGET = qvnc - -QT += \ - core-private network gui-private \ - fb_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) |