]> source.dussan.org Git - tigervnc.git/commitdiff
Encapsulate setDesktopSize() in VNCServerST
authorPierre Ossman <ossman@cendio.se>
Fri, 5 Oct 2018 15:32:57 +0000 (17:32 +0200)
committerPierre Ossman <ossman@cendio.se>
Wed, 10 Oct 2018 11:07:59 +0000 (13:07 +0200)
More encapsulation of functions that require coordinate between
clients.

common/rfb/VNCSConnectionST.cxx
common/rfb/VNCServerST.cxx
common/rfb/VNCServerST.h

index c83254fbe5c0182c626a5c85eb4cc367f19626d6..b5f81c615e55d128e2294e95ccf75e69f74388ee 100644 (file)
@@ -687,27 +687,9 @@ void VNCSConnectionST::setDesktopSize(int fb_width, int fb_height,
   if (!(accessRights & AccessSetDesktopSize)) return;
   if (!rfb::Server::acceptSetDesktopSize) return;
 
-  // Don't bother the desktop with an invalid configuration
-  if (!layout.validate(fb_width, fb_height)) {
-    writer()->writeExtendedDesktopSize(reasonClient, resultInvalid,
-                                       fb_width, fb_height, layout);
-    return;
-  }
-
-  // FIXME: the desktop will call back to VNCServerST and an extra set
-  // of ExtendedDesktopSize messages will be sent. This is okay
-  // protocol-wise, but unnecessary.
-  result = server->desktop->setScreenLayout(fb_width, fb_height, layout);
-
+  result = server->setDesktopSize(this, fb_width, fb_height, layout);
   writer()->writeExtendedDesktopSize(reasonClient, result,
                                      fb_width, fb_height, layout);
-
-  // Only notify other clients on success
-  if (result == resultSuccess) {
-    if (server->screenLayout != layout)
-        throw Exception("Desktop configured a different screen layout than requested");
-    server->notifyScreenLayoutChange(this);
-  }
 }
 
 void VNCSConnectionST::fence(rdr::U32 flags, unsigned len, const char data[])
index 6affe9288e9c140fb364057ad4eac1bc2cc61b1d..31ac5d1c2dba49abc9ab5234f3c1e652f00a24a2 100644 (file)
@@ -513,6 +513,39 @@ void VNCServerST::clientCutText(const char* str, int len)
   desktop->clientCutText(str, len);
 }
 
+unsigned int VNCServerST::setDesktopSize(VNCSConnectionST* requester,
+                                         int fb_width, int fb_height,
+                                         const ScreenSet& layout)
+{
+  unsigned int result;
+  std::list<VNCSConnectionST*>::iterator ci, ci_next;
+
+  // Don't bother the desktop with an invalid configuration
+  if (!layout.validate(fb_width, fb_height))
+    return resultInvalid;
+
+  // FIXME: the desktop will call back to VNCServerST and an extra set
+  // of ExtendedDesktopSize messages will be sent. This is okay
+  // protocol-wise, but unnecessary.
+  result = desktop->setScreenLayout(fb_width, fb_height, layout);
+  if (result != resultSuccess)
+    return result;
+
+  // Sanity check
+  if (screenLayout != layout)
+    throw Exception("Desktop configured a different screen layout than requested");
+
+  // Notify other clients
+  for (ci=clients.begin();ci!=clients.end();ci=ci_next) {
+    ci_next = ci; ci_next++;
+    if ((*ci) == requester)
+      continue;
+    (*ci)->screenLayoutChangeOrClose(reasonOtherClient);
+  }
+
+  return resultSuccess;
+}
+
 // Other public methods
 
 void VNCServerST::approveConnection(network::Socket* sock, bool accept,
@@ -774,17 +807,6 @@ void VNCServerST::setConnStatus(ListConnInfo* listConn)
   }
 }
 
-void VNCServerST::notifyScreenLayoutChange(VNCSConnectionST* requester)
-{
-  std::list<VNCSConnectionST*>::iterator ci, ci_next;
-  for (ci=clients.begin();ci!=clients.end();ci=ci_next) {
-    ci_next = ci; ci_next++;
-    if ((*ci) == requester)
-      continue;
-    (*ci)->screenLayoutChangeOrClose(reasonOtherClient);
-  }
-}
-
 bool VNCServerST::getComparerState()
 {
   if (rfb::Server::compareFB == 0)
index eff52d073efc2e0e7538240dabc73b31c304a89e..54443e1f2cf7f72a01f8fb6731458bb2fed7c387 100644 (file)
@@ -125,6 +125,10 @@ namespace rfb {
     void pointerEvent(VNCSConnectionST* client, const Point& pos, int buttonMask);
     void clientCutText(const char* str, int len);
 
+    unsigned int setDesktopSize(VNCSConnectionST* requester,
+                                int fb_width, int fb_height,
+                                const ScreenSet& layout);
+
     // closeClients() closes all RFB sessions, except the specified one (if
     // any), and logs the specified reason for closure.
     void closeClients(const char* reason, network::Socket* sock);
@@ -204,8 +208,6 @@ namespace rfb {
     Region getPendingRegion();
     const RenderedCursor* getRenderedCursor();
 
-    void notifyScreenLayoutChange(VNCSConnectionST *requester);
-
     bool getComparerState();
 
     KeyRemapper* keyRemapper;