Add plugin arguments to VNC plugin
It is now possible to specify a port number to run the VNC server on, as well as the screen properties: Logical Size Physical Size Depth Change-Id: I79b38c6e37ad5abb5e158eca9a17d7e8a86e692f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>bb10
parent
2cf3696d9f
commit
adf6bd931f
|
|
@ -54,7 +54,6 @@ public:
|
|||
QPlatformIntegration* QVncIntegrationPlugin::create(const QString& system, const QStringList& paramList)
|
||||
{
|
||||
QT_VNC_DEBUG() << "loading vnc plugin" << system;
|
||||
Q_UNUSED(paramList);
|
||||
if (!system.compare(QLatin1String("vnc"), Qt::CaseInsensitive))
|
||||
return new QVncIntegration(paramList);
|
||||
|
||||
|
|
|
|||
|
|
@ -611,28 +611,20 @@ uint QVncClientCursor::removeClient(QVncClient *client)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
QVncServer::QVncServer(QVncScreen *screen)
|
||||
: qvnc_screen(screen)
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
QVncServer::QVncServer(QVncScreen *screen, int /*id*/)
|
||||
QVncServer::QVncServer(QVncScreen *screen, quint16 port)
|
||||
: qvnc_screen(screen)
|
||||
, m_port(port)
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void QVncServer::init()
|
||||
{
|
||||
const int port = 5900;
|
||||
|
||||
serverSocket = new QTcpServer(this);
|
||||
if (!serverSocket->listen(QHostAddress::Any, port))
|
||||
if (!serverSocket->listen(QHostAddress::Any, m_port))
|
||||
qDebug() << "QVncServer could not connect:" << serverSocket->errorString();
|
||||
else
|
||||
QT_VNC_DEBUG("QVncServer created on port %d", port);
|
||||
QT_VNC_DEBUG("QVncServer created on port %d", m_port);
|
||||
QT_VNC_DEBUG() << "running in thread" << thread() << QThread::currentThread();
|
||||
|
||||
connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection()));
|
||||
|
|
|
|||
|
|
@ -391,8 +391,7 @@ class QVncServer : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QVncServer(QVncScreen *screen);
|
||||
QVncServer(QVncScreen *screen, int id);
|
||||
QVncServer(QVncScreen *screen, quint16 port = 5900);
|
||||
~QVncServer();
|
||||
|
||||
enum ServerMsg { FramebufferUpdate = 0,
|
||||
|
|
@ -414,6 +413,7 @@ private:
|
|||
QTcpServer *serverSocket;
|
||||
QVector<QVncClient*> clients;
|
||||
QVncScreen *qvnc_screen;
|
||||
quint16 m_port;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -53,14 +53,24 @@
|
|||
#include <QtPlatformSupport/private/qlibinputhandler_p.h>
|
||||
#endif
|
||||
|
||||
#include <QtCore/QRegularExpression>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QVncIntegration::QVncIntegration(const QStringList ¶mList)
|
||||
: m_fontDb(new QGenericUnixFontDatabase),
|
||||
m_services(new QGenericUnixServices)
|
||||
{
|
||||
QRegularExpression portRx(QLatin1String("port=(\\d+)"));
|
||||
quint16 port = 5900;
|
||||
for (const QString &arg : paramList) {
|
||||
QRegularExpressionMatch match;
|
||||
if (arg.contains(portRx, &match))
|
||||
port = match.captured(1).toInt();
|
||||
}
|
||||
|
||||
m_primaryScreen = new QVncScreen(paramList);
|
||||
m_server = new QVncServer(m_primaryScreen);
|
||||
m_server = new QVncServer(m_primaryScreen, port);
|
||||
m_primaryScreen->vncServer = m_server;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
#include <QtPlatformSupport/private/qfbcursor_p.h>
|
||||
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtCore/QRegularExpression>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -62,11 +63,27 @@ 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+)"));
|
||||
|
||||
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 : mArgs) {
|
||||
QRegularExpressionMatch match;
|
||||
if (arg.contains(mmSizeRx, &match)) {
|
||||
mPhysicalSize = QSizeF(match.captured("width").toDouble(), match.captured("height").toDouble());
|
||||
} else if (arg.contains(sizeRx, &match)) {
|
||||
mGeometry.setSize(QSize(match.captured(1).toInt(), match.captured(2).toInt()));
|
||||
} else if (arg.contains(depthRx, &match)) {
|
||||
mDepth = match.captured(1).toInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QFbScreen::initializeCompositor();
|
||||
QT_VNC_DEBUG() << "QVncScreen::init" << geometry();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue