Don't block waiting for large clipboard transfers.

This commit is contained in:
Stephen Heumann 2016-09-17 23:40:10 -05:00
parent f4c403d8d8
commit a6a34dd080
4 changed files with 26 additions and 6 deletions

View File

@ -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) {

View File

@ -1,3 +1,5 @@
extern void DoServerCutText (void);
extern void GetClipboard (void);
extern void DoSendClipboard (void);
extern int waitingForClipboard;

View File

@ -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.",

View File

@ -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