summaryrefslogtreecommitdiffstats
path: root/rfbserver.c
diff options
context:
space:
mode:
Diffstat (limited to 'rfbserver.c')
-rw-r--r--rfbserver.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/rfbserver.c b/rfbserver.c
index 11aeff6..f2dfada 100644
--- a/rfbserver.c
+++ b/rfbserver.c
@@ -266,6 +266,7 @@ rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP)
cl->enableCursorShapeUpdates = FALSE;
cl->useRichCursorEncoding = FALSE;
cl->enableLastRectEncoding = FALSE;
+ cl->useNewFBSize = FALSE;
cl->compStreamInited = FALSE;
cl->compStream.total_in = 0;
@@ -663,6 +664,7 @@ rfbProcessClientNormalMessage(cl)
cl->useCopyRect = FALSE;
cl->enableCursorShapeUpdates = FALSE;
cl->enableLastRectEncoding = FALSE;
+ cl->useNewFBSize = FALSE;
for (i = 0; i < msg.se.nEncodings; i++) {
if ((n = ReadExact(cl, (char *)&enc, 4)) <= 0) {
@@ -742,6 +744,13 @@ rfbProcessClientNormalMessage(cl)
cl->enableLastRectEncoding = TRUE;
}
break;
+ case rfbEncodingNewFBSize:
+ if (!cl->useNewFBSize) {
+ rfbLog("Enabling NewFBSize protocol extension for client "
+ "%s\n", cl->host);
+ cl->useNewFBSize = TRUE;
+ }
+ break;
#ifdef BACKCHANNEL
case rfbEncodingBackChannel:
if (!cl->enableBackChannel) {
@@ -924,6 +933,25 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
if(cl->screen->displayHook)
cl->screen->displayHook(cl);
+
+ /*
+ * If framebuffer size was changed and the client supports NewFBSize
+ * encoding, just send NewFBSize marker and return.
+ */
+
+ if (cl->useNewFBSize && cl->newFBSizePending) {
+ LOCK(cl->updateMutex);
+ cl->newFBSizePending = FALSE;
+ UNLOCK(cl->updateMutex);
+ cl->rfbFramebufferUpdateMessagesSent++;
+ fu->type = rfbFramebufferUpdate;
+ fu->nRects = Swap16IfLE(1);
+ cl->ublen = sz_rfbFramebufferUpdateMsg;
+ if (!rfbSendNewFBSize(cl, cl->screen->width, cl->screen->height)) {
+ return FALSE;
+ }
+ return rfbSendUpdateBuf(cl);
+ }
/*
* If this client understands cursor shape updates, cursor should be
@@ -1310,6 +1338,40 @@ rfbSendLastRectMarker(cl)
/*
+ * Send NewFBSize pseudo-rectangle. This tells the client to change
+ * its framebuffer size.
+ */
+
+Bool
+rfbSendNewFBSize(cl, w, h)
+ rfbClientPtr cl;
+ int w, h;
+{
+ rfbFramebufferUpdateRectHeader rect;
+
+ if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE) {
+ if (!rfbSendUpdateBuf(cl))
+ return FALSE;
+ }
+
+ rect.encoding = Swap32IfLE(rfbEncodingNewFBSize);
+ rect.r.x = 0;
+ rect.r.y = 0;
+ rect.r.w = Swap16IfLE(w);
+ rect.r.h = Swap16IfLE(h);
+
+ memcpy(&cl->updateBuf[cl->ublen], (char *)&rect,
+ sz_rfbFramebufferUpdateRectHeader);
+ cl->ublen += sz_rfbFramebufferUpdateRectHeader;
+
+ cl->rfbLastRectMarkersSent++;
+ cl->rfbLastRectBytesSent += sz_rfbFramebufferUpdateRectHeader;
+
+ return TRUE;
+}
+
+
+/*
* Send the contents of cl->updateBuf. Returns 1 if successful, -1 if
* not (errno should be set).
*/