diff --git a/clipboard.cc b/clipboard.cc index f64c245..3fe578a 100644 --- a/clipboard.cc +++ b/clipboard.cc @@ -77,12 +77,11 @@ static unsigned char windows1252ToMacRoman[128] = { }; +static unsigned long textLen; + /* Update the Scrap Manager clipboard with new data sent from server. */ void DoServerCutText (void) { - unsigned long textLen; - unsigned long i; - if (! DoWaitingReadTCP (3)) { /* Read & ignore padding */ DoClose(vncWindow); return; @@ -92,9 +91,17 @@ void DoServerCutText (void) { return; } textLen = SwapBytes4(*(unsigned long *)readBufferPtr); + + /* Set up to wait for clipboard data. Treat this like a + * "display in progress," although it's really not. */ + displayInProgress = TRUE; + GetClipboard(); +} - if (! DoWaitingReadTCP(textLen)) { - DoClose(vncWindow); +void GetClipboard (void) { + unsigned long i; + + if (! DoReadTCP(textLen)) { return; }; if (allowClipboardTransfers) { @@ -116,6 +123,8 @@ void DoServerCutText (void) { /* Potential errors (e.g. out of memory) ignored */ DoneWithReadBuffer(); } + + displayInProgress = FALSE; } void DoSendClipboard (void) { diff --git a/clipboard.h b/clipboard.h index 27a49aa..732062c 100644 --- a/clipboard.h +++ b/clipboard.h @@ -1,3 +1,5 @@ extern void DoServerCutText (void); +extern void GetClipboard (void); extern void DoSendClipboard (void); +extern int waitingForClipboard; diff --git a/vncdisplay.cc b/vncdisplay.cc index ccdbd70..137f43a 100644 --- a/vncdisplay.cc +++ b/vncdisplay.cc @@ -316,6 +316,8 @@ void ConnectedEventLoop (void) { return; case encodingHextile: HexDispatch(); return; + case nonEncodingClipboard: GetClipboard(); + return; default: DoClose(vncWindow); return; } @@ -353,7 +355,8 @@ void ConnectedEventLoop (void) { break; case Bell: SysBeep(); break; - case ServerCutText: DoServerCutText(); + case ServerCutText: rectEncoding = nonEncodingClipboard; + DoServerCutText(); break; default: DisplayConnectStatus ( "\pInvalid message from server.", diff --git a/vncdisplay.h b/vncdisplay.h index 3a777be..00ef783 100644 --- a/vncdisplay.h +++ b/vncdisplay.h @@ -18,10 +18,16 @@ extern unsigned int rectHeight; #define encodingRRE 2 #define encodingCoRRE 4 #define encodingHextile 5 +#define encodingZlib 6 +#define encodingTight 7 +#define encodingZlibhex 8 +#define encodingTRLE 15 #define encodingZRLE 16 #define encodingCursor 0xffffff11 #define encodingDesktopSize 0xffffff21 +#define nonEncodingClipboard 3 /* should be different from any encoding */ + #define WIN_WIDTH_320 302 #define WIN_WIDTH_640 613 #define WIN_HEIGHT 174