From 8232831bb4c23d7a544cf97e1d23b724cb83f30a Mon Sep 17 00:00:00 2001 From: Constantin Kaplinsky Date: Thu, 24 Apr 2008 08:44:24 +0000 Subject: [PATCH] Support for VideoRectangleSelection client message in the server code. The message is read but ignored (only a message will be written to stderr). git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2559 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/SConnection.cxx | 16 ++++++++++++++-- common/rfb/SConnection.h | 8 ++++++++ common/rfb/SMsgReader.cxx | 15 +++++++++++++++ common/rfb/SMsgReader.h | 1 + common/rfb/SMsgReaderV3.cxx | 1 + common/rfb/VNCSConnectionST.cxx | 1 + common/rfb/VNCServerST.cxx | 3 ++- common/rfb/VNCServerST.h | 12 ++++++++++++ common/rfb/msgTypes.h | 1 + unix/x0vncserver/x0vncserver.cxx | 2 ++ 10 files changed, 57 insertions(+), 3 deletions(-) diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx index bede90e4..2fde9fbb 100644 --- a/common/rfb/SConnection.cxx +++ b/common/rfb/SConnection.cxx @@ -46,7 +46,8 @@ SConnection::SConnection(SSecurityFactory* secFact, bool reverseConnection_) : readyForSetColourMapEntries(false), is(0), os(0), reader_(0), writer_(0), security(0), securityFactory(secFact), state_(RFBSTATE_UNINITIALISED), - reverseConnection(reverseConnection_) + reverseConnection(reverseConnection_), + m_videoSelectionEnabled(false) { defaultMajorVersion = 3; defaultMinorVersion = 8; @@ -76,6 +77,11 @@ void SConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_) os = os_; } +void SConnection::setProtocolOptions(bool enableVideoSelection) +{ + m_videoSelectionEnabled = enableVideoSelection; +} + void SConnection::initialiseProtocol() { cp.writeVersion(os); @@ -464,10 +470,16 @@ void SConnection::sendInteractionCaps() ccaps.addTightExt(msgTypeFileDeleteRequest, "FTC_RMRQ"); */ - // Continuous updates: ccaps.addTightExt(msgTypeEnableContinuousUpdates, "CUC_ENCU"); + if (m_videoSelectionEnabled) { + ccaps.addTightExt(msgTypeVideoRectangleSelection, "VRECTSEL"); + } + + // // Advertise all supported encoding types (except raw encoding). + // + CapsList ecaps; // First, add true encodings. diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h index e41ef5fb..2540ed78 100644 --- a/common/rfb/SConnection.h +++ b/common/rfb/SConnection.h @@ -50,6 +50,11 @@ namespace rfb { // (i.e. SConnection will not delete them). void setStreams(rdr::InStream* is, rdr::OutStream* os); + // setProtocolOptions() configures TightVNC-specific protocol options. + // It can be optionally called before calling initialiseProtocol(). + // See also: VNCServerST::enableVideoSelection(); + void setProtocolOptions(bool enableVideoSelection); + // initialiseProtocol() should be called once the streams and security // types are set. Subsequently, processMsg() should be called whenever // there is data to read on the InStream. @@ -198,6 +203,9 @@ namespace rfb { SSecurityFactory* securityFactory; stateEnum state_; bool reverseConnection; + + // TightVNC-specific protocol options. + bool m_videoSelectionEnabled; }; } #endif diff --git a/common/rfb/SMsgReader.cxx b/common/rfb/SMsgReader.cxx index 0e57ea76..4213e728 100644 --- a/common/rfb/SMsgReader.cxx +++ b/common/rfb/SMsgReader.cxx @@ -110,3 +110,18 @@ void SMsgReader::readEnableContinuousUpdates() } } +void SMsgReader::readVideoRectangleSelection() +{ + (void)is->readU8(); + int x = is->readU16(); + int y = is->readU16(); + int w = is->readU16(); + int h = is->readU16(); + bool enable = w > 0 && h > 0; + + // FIXME: Use proper logger. + fprintf(stderr, "Ignoring VideoRectangleSelection message\n"); + + // FIXME: Implement VideoRectangleSelection message handling. +} + diff --git a/common/rfb/SMsgReader.h b/common/rfb/SMsgReader.h index 958c03a7..997c07bf 100644 --- a/common/rfb/SMsgReader.h +++ b/common/rfb/SMsgReader.h @@ -49,6 +49,7 @@ namespace rfb { // Read TightVNC-specific protocol messages. virtual void readEnableContinuousUpdates(); + virtual void readVideoRectangleSelection(); SMsgReader(SMsgHandler* handler, rdr::InStream* is); diff --git a/common/rfb/SMsgReaderV3.cxx b/common/rfb/SMsgReaderV3.cxx index e9b020bb..468d74a0 100644 --- a/common/rfb/SMsgReaderV3.cxx +++ b/common/rfb/SMsgReaderV3.cxx @@ -62,6 +62,7 @@ void SMsgReaderV3::readMsg() case msgTypeFileDeleteRequest: handler->processFTMsg(msgType); break; case msgTypeEnableContinuousUpdates: readEnableContinuousUpdates(); break; + case msgTypeVideoRectangleSelection: readVideoRectangleSelection(); break; default: fprintf(stderr, "unknown message type %d\n", msgType); diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index 3929b1fb..7c922cfe 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -87,6 +87,7 @@ VNCSConnectionST::~VNCSConnectionST() bool VNCSConnectionST::init() { try { + setProtocolOptions(server->isVideoSelectionEnabled()); initialiseProtocol(); } catch (rdr::Exception& e) { close(e.str()); diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index e5354a41..93f947cf 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -77,7 +77,8 @@ VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_, securityFactory(sf ? sf : &defaultSecurityFactory), queryConnectionHandler(0), keyRemapper(&KeyRemapper::defInstance), useEconomicTranslate(false), - lastConnectionTime(0), disableclients(false) + lastConnectionTime(0), disableclients(false), + m_videoSelectionEnabled(false) { lastUserInputTime = lastDisconnectTime = time(0); slog.debug("creating single-threaded server %s", name.buf); diff --git a/common/rfb/VNCServerST.h b/common/rfb/VNCServerST.h index fad8cb93..81ad4ecb 100644 --- a/common/rfb/VNCServerST.h +++ b/common/rfb/VNCServerST.h @@ -192,6 +192,16 @@ namespace rfb { void setFTManager(rfb::SFileTransferManager *pFTManager) { m_pFTManager = pFTManager; }; + // Enable/disable support for TightVNC-specific VideoRectangleSelection + // client message. This is a protocol option that lets a client select a + // rectangle to be treated by the server as video data. Once selected, this + // part of the framebuffer will be sent using JpegEncoder, on each update + // request, as we expect that video data is changing continuously. By + // default, this option is disabled, as it's rather a specialized feature + // and video selection GUI can confuse users of the TightVNC client. + void enableVideoSelection(bool enable) { m_videoSelectionEnabled = enable; } + bool isVideoSelectionEnabled() { return m_videoSelectionEnabled; } + protected: friend class VNCSConnectionST; @@ -239,6 +249,8 @@ namespace rfb { time_t lastConnectionTime; bool disableclients; + + bool m_videoSelectionEnabled; }; }; diff --git a/common/rfb/msgTypes.h b/common/rfb/msgTypes.h index ec26adc7..32b1395f 100644 --- a/common/rfb/msgTypes.h +++ b/common/rfb/msgTypes.h @@ -57,5 +57,6 @@ namespace rfb { const int msgTypeFileDeleteRequest = 139; const int msgTypeEnableContinuousUpdates = 150; + const int msgTypeVideoRectangleSelection = 151; } #endif diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx index 4eb6b226..ab939846 100644 --- a/unix/x0vncserver/x0vncserver.cxx +++ b/unix/x0vncserver/x0vncserver.cxx @@ -455,9 +455,11 @@ int main(int argc, char** argv) Geometry geo(DisplayWidth(dpy, DefaultScreen(dpy)), DisplayHeight(dpy, DefaultScreen(dpy))); XDesktop desktop(dpy, &geo); + VNCServerST server("x0vncserver", &desktop); QueryConnHandler qcHandler(dpy, &server); server.setQueryConnectionHandler(&qcHandler); + server.enableVideoSelection(true); TcpListener listener((int)rfbport); vlog.info("Listening on port %d", (int)rfbport); -- 2.39.5