diff options
author | Andy Nichols <andy.nichols@theqtcompany.com> | 2016-06-15 15:07:41 +0200 |
---|---|---|
committer | Andy Nichols <andy.nichols@qt.io> | 2016-06-28 10:18:34 +0000 |
commit | 2cf3696d9f11ae2aa2dba56a0774bea10d59a482 (patch) | |
tree | 79af23327f69f8549a80282ff8f123d152fee066 /src/plugins/platforms/vnc/qvnc_p.h | |
parent | 2204e9a7c48faf35e41bd338da7efaad78b8efff (diff) |
Support multiple connected clients in the VNC plugin
Previously it was only possible for one client to connect at a time.
Now it is possible for multiple clients to connect to the VNC server and
view and interact with the application.
Change-Id: I886583a3abea2955367bf2da490127b041b5c5fb
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/platforms/vnc/qvnc_p.h')
-rw-r--r-- | src/plugins/platforms/vnc/qvnc_p.h | 79 |
1 files changed, 16 insertions, 63 deletions
diff --git a/src/plugins/platforms/vnc/qvnc_p.h b/src/plugins/platforms/vnc/qvnc_p.h index b67c1df838..dd8189d30f 100644 --- a/src/plugins/platforms/vnc/qvnc_p.h +++ b/src/plugins/platforms/vnc/qvnc_p.h @@ -53,12 +53,15 @@ #include <QtCore/qvarlengtharray.h> #include <qpa/qplatformcursor.h> +QT_BEGIN_NAMESPACE + class QTcpSocket; class QTcpServer; class QVncScreen; class QVncServer; class QVncClientCursor; +class QVncClient; // This fits with the VNC hextile messages #define MAP_TILE_SIZE 16 @@ -203,19 +206,19 @@ public: class QRfbEncoder { public: - QRfbEncoder(QVncServer *s) : server(s) {} + QRfbEncoder(QVncClient *s) : client(s) {} virtual ~QRfbEncoder() {} virtual void write() = 0; protected: - QVncServer *server; + QVncClient *client; }; class QRfbRawEncoder : public QRfbEncoder { public: - QRfbRawEncoder(QVncServer *s) : QRfbEncoder(s) {} + QRfbRawEncoder(QVncClient *s) : QRfbEncoder(s) {} void write(); @@ -368,16 +371,19 @@ private: class QVncClientCursor : public QPlatformCursor { public: - QVncClientCursor(QVncServer *s); + QVncClientCursor(); ~QVncClientCursor(); - void write() const; + void write(QVncClient *client) const; void changeCursor(QCursor *widgetCursor, QWindow *window); + void addClient(QVncClient *client); + uint removeClient(QVncClient *client); + QImage cursor; QPoint hotspot; - QVncServer *server; + QVector<QVncClient *> clients; }; @@ -389,80 +395,27 @@ public: QVncServer(QVncScreen *screen, int id); ~QVncServer(); - void setDirty(); - void setDirtyCursor() { dirtyCursor = true; setDirty(); } - inline bool isConnected() const { return state == Connected; } - inline void setRefreshRate(int rate) { refreshRate = rate; } - - enum ClientMsg { SetPixelFormat = 0, - FixColourMapEntries = 1, - SetEncodings = 2, - FramebufferUpdateRequest = 3, - KeyEvent = 4, - PointerEvent = 5, - ClientCutText = 6 }; - enum ServerMsg { FramebufferUpdate = 0, SetColourMapEntries = 1 }; - void convertPixels(char *dst, const char *src, int count) const; + void setDirty(); - inline int clientBytesPerPixel() const { - return pixelFormat.bitsPerPixel / 8; - } inline QVncScreen* screen() const { return qvnc_screen; } inline QVncDirtyMap* dirtyMap() const { return qvnc_screen->dirty; } - inline QTcpSocket* clientSocket() const { return client; } QImage screenImage() const; - inline bool doPixelConversion() const { return needConversion; } - -private: - void setPixelFormat(); - void setEncodings(); - void frameBufferUpdateRequest(); - void pointerEvent(); - void keyEvent(); - void clientCutText(); - bool pixelConversionNeeded() const; + void discardClient(QVncClient *client); private slots: void newConnection(); - void readClient(); - void checkUpdate(); - void discardClient(); void init(); private: - enum ClientState { Disconnected, Protocol, Init, Connected }; - QTimer *timer; QTcpServer *serverSocket; - QTcpSocket *client; - ClientState state; - quint8 msgType; - bool handleMsg; - QRfbPixelFormat pixelFormat; - Qt::KeyboardModifiers keymod; - int encodingsPending; - int cutTextPending; - uint supportCopyRect : 1; - uint supportRRE : 1; - uint supportCoRRE : 1; - uint supportHextile : 1; - uint supportZRLE : 1; - uint supportCursor : 1; - uint supportDesktopSize : 1; - bool wantUpdate; - bool sameEndian; - bool needConversion; -#if Q_BYTE_ORDER == Q_BIG_ENDIAN - bool swapBytes; -#endif - bool dirtyCursor; - int refreshRate; + QVector<QVncClient*> clients; QVncScreen *qvnc_screen; - QRfbEncoder *encoder; }; +QT_END_NAMESPACE #endif |