6#include "QtNetwork/qtcpserver.h"
7#include "QtNetwork/qtcpsocket.h"
11#include <QtGui/qguiapplication.h>
12#include <QtGui/QWindow>
20#include <QtCore/QDebug>
75 const int lstep = bufferStride;
79 + startY * lstep + startX * bytesPerPixel;
80 uchar *old =
buffer + startY * bufferStride + startX *
sizeof(T);
82 const int tileHeight = (startY +
MAP_TILE_SIZE > bufferHeight ?
109 if (memcmp(old, scrn,
sizeof(T) * tileWidth)) {
119 memcpy(old, scrn,
sizeof(T) * tileWidth);
127 const int mapIndex = tileY * mapWidth + tileX;
128 if ((force || changed) && !
map[mapIndex]) {
212 s->read(
reinterpret_cast<char*
>(
buf), 8);
226 s->write(
reinterpret_cast<char*
>(
buf) , 8);
285 name =
new char [strlen(
n) + 1];
291 s->read(
reinterpret_cast<char *
>(&
width), 2);
293 s->read(
reinterpret_cast<char *
>(&
height), 2);
298 s->read(
reinterpret_cast<char *
>(&
len), 4);
309 s->write(
reinterpret_cast<char *
>(&
t), 2);
311 s->write(
reinterpret_cast<char *
>(&
t), 2);
315 s->write(
reinterpret_cast<char *
>(&
len), 4);
321 if (
s->bytesAvailable() < 3)
326 s->read(
reinterpret_cast<char *
>(&
count), 2);
334 if (
s->bytesAvailable() < 9)
345 if (
s->bytesAvailable() < 7)
350 s->read(
reinterpret_cast<char *
>(&tmp), 2);
353 s->read(
reinterpret_cast<char *
>(&
key), 4);
360 if (
keyMap[
i].keysym ==
static_cast<int>(
key))
371 if (
key >=
'a' &&
key <=
'z')
373 else if (
key >=
' ' &&
key <=
'~')
383 if (
s->bytesAvailable() < 5)
387 s->read(&buttonMask, 1);
397 s->read(
reinterpret_cast<char *
>(&tmp), 2);
399 s->read(
reinterpret_cast<char *
>(&tmp), 2);
407 if (
s->bytesAvailable() < 7)
412 s->read(
reinterpret_cast<char *
>(&
length), 4);
428 qCDebug(lcVnc) <<
"QRfbRawEncoder::write()" << rgn;
445 rgn &= screenImage.
rect();
447 const auto rectsInRegion = rgn.
rectCount();
450 const char tmp[2] = { 0, 0 };
459 if (rectsInRegion <= 0)
462 for (
const QRect &tileRect: rgn) {
464 tileRect.width(), tileRect.height());
467 const quint32 encoding = htonl(0);
468 socket->
write(
reinterpret_cast<const char *
>(&encoding),
sizeof(encoding));
475 const int bufferSize =
rect.w *
rect.h * bytesPerPixel;
476 if (bufferSize >
buffer.size())
477 buffer.resize(bufferSize);
481 const int bstep =
rect.w * bytesPerPixel;
483 for (
int i = 0;
i <
rect.h; ++
i) {
485 screendata += linestep;
490 for (
int i = 0;
i <
rect.h; ++
i) {
491 socket->
write(
reinterpret_cast<const char*
>(screendata),
rect.w * bytesPerPixel);
492 screendata += linestep;
502QVncClientCursor::QVncClientCursor()
506 changeCursor(&
c,
nullptr);
509QVncClientCursor::~QVncClientCursor()
513void QVncClientCursor::write(
QVncClient *client)
const
519 const quint16 tmp[6] = { htons(0),
521 htons(
static_cast<uint16_t
>(hotspot.x())), htons(
static_cast<uint16_t
>(hotspot.y())),
522 htons(
static_cast<uint16_t
>(
cursor.width())),
523 htons(
static_cast<uint16_t
>(
cursor.height())) };
524 socket->
write(
reinterpret_cast<const char*
>(tmp),
sizeof(tmp));
527 socket->
write(
reinterpret_cast<const char*
>(&encoding),
sizeof(encoding));
539 for (
int i = 0;
i <
img.height(); ++
i) {
550 for (
int i = 0;
i <
bitmap.height(); ++
i)
561 hotspot = widgetCursor->
hotSpot();
566 platformImage.set(shape);
567 cursor = *platformImage.image();
568 hotspot = platformImage.hotspot();
570 for (
auto client :
std::as_const(clients))
571 client->setDirtyCursor();
574void QVncClientCursor::addClient(
QVncClient *client)
576 if (!clients.contains(client)) {
577 clients.append(client);
585 clients.removeOne(client);
586 return clients.size();
597void QVncServer::init()
603 qWarning(
"QVncServer created on port %d", m_port);
616 for (
auto client : std::as_const(clients))
623void QVncServer::newConnection()
646 return *qvnc_screen->
image();
651#include "moc_qvnc_p.cpp"
bool flush()
This function writes as much as possible from the internal write buffer to the underlying network soc...
QHostAddress localAddress() const
Returns the host address of the local socket if available; otherwise returns QHostAddress::Null.
SocketState state() const
Returns the state of the socket.
The QCursor class provides a mouse cursor with an arbitrary shape.
QPixmap pixmap() const
Returns the cursor pixmap.
Qt::CursorShape shape() const
Returns the cursor shape identifier.
QPoint hotSpot() const
Returns the cursor hot spot, or (0, 0) if it is one of the standard cursors.
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
int depth() const override
Reimplement in subclass to return current depth of the screen.
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
qsizetype bytesPerLine() const
Returns the number of bytes per image scanline.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
QRect rect() const
Returns the enclosing rectangle (0, 0, width(), height()) of the image.
bool isEmpty() const noexcept
bool removeOne(const AT &t)
void append(parameter_type t)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void deleteLater()
\threadsafe
QImage toImage() const
Converts the pixmap to a QImage.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
int rectCount() const noexcept
void write(QTcpSocket *s) const
void setName(const char *n)
void write(QTcpSocket *s)
The QTcpServer class provides a TCP-based server.
QString errorString() const
Returns a human readable description of the last error that occurred.
virtual QTcpSocket * nextPendingConnection()
Returns the next pending connection as a connected QTcpSocket object.
bool listen(const QHostAddress &address=QHostAddress::Any, quint16 port=0)
Tells the server to listen for incoming connections on address address and port port.
The QTcpSocket class provides a TCP socket.
int clientBytesPerPixel() const
QRegion dirtyRegion() const
bool doPixelConversion() const
void convertPixels(char *dst, const char *src, int count, int depth) const
QTcpSocket * clientSocket() const
void setDirty(const QRegion ®ion)
QVncServer * server() const
void setDirty(int x, int y, bool force=false) override
QVncDirtyMap(QVncScreen *screen)
bool dirty(int x, int y) const
void setClean(int x, int y)
void disableClientCursor(QVncClient *client)
QVncScreen * screen() const
QImage screenImage() const
void discardClient(QVncClient *client)
QVncDirtyMap * dirtyMap() const
QVncServer(QVncScreen *screen, quint16 port=5900)
QMap< QString, QString > map
[6]
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
constexpr T qToBigEndian(T source)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLint GLenum GLsizei GLsizei GLsizei depth
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
static const struct @437 keyMap[]
QUdpSocket clientSocket
[0]