From 2affd7753274ddf3b93505f0ae26af3c45aa3fec Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 20 Jun 2018 07:03:10 +0200 Subject: [PATCH] Stop requiring CConnection::serverInit() to be overridden Add an explicit callback for subclasses to do their startup in. This makes it easier to do proper ordering, and avoids mistakes. --- common/rfb/CConnection.cxx | 12 +++++++++--- common/rfb/CConnection.h | 10 +++++++--- vncviewer/CConn.cxx | 6 ++---- vncviewer/CConn.h | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx index a503a2c4..805c8c31 100644 --- a/common/rfb/CConnection.cxx +++ b/common/rfb/CConnection.cxx @@ -335,6 +335,14 @@ void CConnection::setExtendedDesktopSize(unsigned reason, CMsgHandler::setExtendedDesktopSize(reason, result, w, h, layout); } +void CConnection::serverInit() +{ + state_ = RFBSTATE_NORMAL; + vlog.debug("initialisation done"); + + initDone(); +} + void CConnection::readAndDecodeRect(const Rect& r, int encoding, ModifiablePixelBuffer* pb) { @@ -363,10 +371,8 @@ void CConnection::authSuccess() { } -void CConnection::serverInit() +void CConnection::initDone() { - state_ = RFBSTATE_NORMAL; - vlog.debug("initialisation done"); } void CConnection::fence(rdr::U32 flags, unsigned len, const char data[]) diff --git a/common/rfb/CConnection.h b/common/rfb/CConnection.h index 1e66a641..c996ecf4 100644 --- a/common/rfb/CConnection.h +++ b/common/rfb/CConnection.h @@ -100,6 +100,8 @@ namespace rfb { int w, int h, const ScreenSet& layout); + virtual void serverInit(); + virtual void readAndDecodeRect(const Rect& r, int encoding, ModifiablePixelBuffer* pb); @@ -113,9 +115,11 @@ namespace rfb { // authSuccess() is called when authentication has succeeded. virtual void authSuccess(); - // serverInit() is called when the ServerInit message is received. The - // derived class must call on to CConnection::serverInit(). - virtual void serverInit(); + // initDone() is called when the connection is fully established + // and standard messages can be sent. This is called before the + // initial FramebufferUpdateRequest giving a derived class the + // chance to modify pixel format and settings. + virtual void initDone(); // Other methods diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index fe8e6cf5..23257ee6 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -308,13 +308,11 @@ void CConn::socketEvent(FL_SOCKET fd, void *data) ////////////////////// CConnection callback methods ////////////////////// -// serverInit() is called when the serverInit message has been received. At +// initDone() is called when the serverInit message has been received. At // this point we create the desktop window and display it. We also tell the // server the pixel format and encodings to use and request the first update. -void CConn::serverInit() +void CConn::initDone() { - CConnection::serverInit(); - // If using AutoSelect with old servers, start in FullColor // mode. See comment in autoSelectFormatAndEncoding. if (server.beforeVersion(3, 8) && autoSelect) diff --git a/vncviewer/CConn.h b/vncviewer/CConn.h index 5988a94f..66ef1d02 100644 --- a/vncviewer/CConn.h +++ b/vncviewer/CConn.h @@ -51,7 +51,7 @@ public: static void socketEvent(FL_SOCKET fd, void *data); // CConnection callback methods - void serverInit(); + void initDone(); void setDesktopSize(int w, int h); void setExtendedDesktopSize(unsigned reason, unsigned result, -- 2.39.5