File tightvnc-newfbsize.patch of Package tightvnc

--- vncviewer/desktop.c
+++ vncviewer/desktop.c
@@ -82,13 +82,23 @@
   for (i = 0; i < 256; i++)
     modifierPressed[i] = False;
 
-  image = NULL;
+  CreateImage();
+}
+
+void
+CreateImage()
+{
+    if (image != NULL) {
+	XDestroyImage(image);
+	image = NULL;
+    }
 
 #ifdef MITSHM
-  if (appData.useShm) {
-    image = CreateShmImage();
-    if (!image)
-      appData.useShm = False;
+    if (appData.useShm) {
+	ShmCleanup();
+	image = CreateShmImage();
+	if (!image)
+	    appData.useShm = False;
   }
 #endif
 
--- vncviewer/misc.c
+++ vncviewer/misc.c
@@ -34,6 +34,7 @@
 
 Dimension dpyWidth, dpyHeight;
 Atom wmDeleteWindow, wmState;
+Bool userGeometry = True;
 
 static Bool xloginIconified = False;
 static XErrorHandler defaultXErrorHandler;
@@ -84,6 +85,7 @@
       Dimension toplevelWidth = si.framebufferWidth;
       Dimension toplevelHeight = si.framebufferHeight;
 
+      userGeometry = False;
       if ((toplevelWidth + appData.wmDecorationWidth) >= dpyWidth)
 	toplevelWidth = dpyWidth - appData.wmDecorationWidth;
 
--- vncviewer/rfbproto.c
+++ vncviewer/rfbproto.c
@@ -66,7 +66,7 @@
 static void JpegTermSource(j_decompress_ptr cinfo);
 static void JpegSetSrcManager(j_decompress_ptr cinfo, CARD8 *compressedData,
                               int compressedLen);
-
+static void ReadNewFBSize(rfbFramebufferUpdateRectHeader *pfburh);
 
 int rfbsock;
 char *desktopName;
@@ -177,6 +177,8 @@
 	  sig_rfbEncodingPointerPos, "Pointer position update");
   CapsAdd(encodingCaps, rfbEncodingLastRect, rfbTightVncVendor,
 	  sig_rfbEncodingLastRect, "LastRect protocol extension");
+  CapsAdd(encodingCaps, rfbEncodingNewFBSize, rfbTightVncVendor,
+	  sig_rfbEncodingNewFBSize, "Framebuffer size change");
 }
 
 
@@ -806,6 +808,8 @@
     if (se->nEncodings < MAX_ENCODINGS && requestLastRectEncoding) {
       encs[se->nEncodings++] = Swap32IfLE(rfbEncodingLastRect);
     }
+    if (se->nEncodings < MAX_ENCODINGS)
+	encs[se->nEncodings++] = Swap32IfLE(rfbEncodingNewFBSize);
   }
   else {
     if (SameMachine(rfbsock)) {
@@ -849,6 +853,7 @@
     }
 
     encs[se->nEncodings++] = Swap32IfLE(rfbEncodingLastRect);
+    encs[se->nEncodings++] = Swap32IfLE(rfbEncodingNewFBSize);
   }
 
   len = sz_rfbSetEncodingsMsg + se->nEncodings * 4;
@@ -1023,6 +1028,11 @@
       rect.r.w = Swap16IfLE(rect.r.w);
       rect.r.h = Swap16IfLE(rect.r.h);
 
+      if (rect.encoding == rfbEncodingNewFBSize) {
+	  ReadNewFBSize(&rect);
+	  break;
+      }
+
       if (rect.encoding == rfbEncodingXCursor ||
 	  rect.encoding == rfbEncodingRichCursor) {
 	if (!HandleCursorShape(rect.r.x, rect.r.y, rect.r.w, rect.r.h,
@@ -1463,3 +1473,35 @@
   cinfo->src = &jpegSrcManager;
 }
 
+//
+// Processing NewFBSize pseudo-rectangle. Create new framebuffer of
+// the size specified in pfburh->r.w and pfburh->r.h, and change the
+// window size correspondingly.
+//
+
+static void ReadNewFBSize(rfbFramebufferUpdateRectHeader *pfburh)
+{
+    si.framebufferWidth = pfburh->r.w;
+    si.framebufferHeight = pfburh->r.h;
+    
+    fprintf(stderr, "NewFBSize: %dx%d\n",
+	    si.framebufferWidth, si.framebufferHeight);
+    CreateImage();
+
+    XtUnmanageChild(viewport);
+    XtVaSetValues(desktop,
+		  XtNwidth, si.framebufferWidth,
+		  XtNheight, si.framebufferHeight,
+		  NULL);
+    XtVaSetValues(viewport,
+		  XtNwidth, si.framebufferWidth,
+		  XtNheight, si.framebufferHeight,
+		  NULL);
+    XtVaSetValues(toplevel,
+		  XtNmaxWidth, si.framebufferWidth,
+		  XtNmaxHeight, si.framebufferHeight,
+		  NULL);
+    XtResizeWidget(toplevel,
+		   si.framebufferWidth, si.framebufferHeight, 0);
+    XtManageChild(viewport);
+}
--- vncviewer/vncviewer.h
+++ vncviewer/vncviewer.h
@@ -158,6 +158,7 @@
 
 extern void DesktopInitBeforeRealization();
 extern void DesktopInitAfterRealization();
+extern void CreateImage();
 extern void SendRFBEvent(Widget w, XEvent *event, String *params,
 			 Cardinal *num_params);
 extern void CopyDataToScreen(char *buf, int x, int y, int width, int height);
@@ -198,6 +199,7 @@
 extern void Quit(Widget w, XEvent *event, String *params,
 		 Cardinal *num_params);
 extern void Cleanup();
+extern Bool userGeometry;
 
 /* popup.c */
 
openSUSE Build Service is sponsored by