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. /* Update the Scrap Manager clipboard with new data sent from server.
*/ */
void DoServerCutText (void) { void DoServerCutText (void) {
unsigned long textLen;
unsigned long i;
if (! DoWaitingReadTCP (3)) { /* Read & ignore padding */ if (! DoWaitingReadTCP (3)) { /* Read & ignore padding */
DoClose(vncWindow); DoClose(vncWindow);
return; return;
@ -92,9 +91,17 @@ void DoServerCutText (void) {
return; return;
} }
textLen = SwapBytes4(*(unsigned long *)readBufferPtr); 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)) { void GetClipboard (void) {
DoClose(vncWindow); unsigned long i;
if (! DoReadTCP(textLen)) {
return; return;
}; };
if (allowClipboardTransfers) { if (allowClipboardTransfers) {
@ -116,6 +123,8 @@ void DoServerCutText (void) {
/* Potential errors (e.g. out of memory) ignored */ /* Potential errors (e.g. out of memory) ignored */
DoneWithReadBuffer(); DoneWithReadBuffer();
} }
displayInProgress = FALSE;
} }
void DoSendClipboard (void) { void DoSendClipboard (void) {

View File

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

View File

@ -316,6 +316,8 @@ void ConnectedEventLoop (void) {
return; return;
case encodingHextile: HexDispatch(); case encodingHextile: HexDispatch();
return; return;
case nonEncodingClipboard: GetClipboard();
return;
default: DoClose(vncWindow); default: DoClose(vncWindow);
return; return;
} }
@ -353,7 +355,8 @@ void ConnectedEventLoop (void) {
break; break;
case Bell: SysBeep(); case Bell: SysBeep();
break; break;
case ServerCutText: DoServerCutText(); case ServerCutText: rectEncoding = nonEncodingClipboard;
DoServerCutText();
break; break;
default: DisplayConnectStatus ( default: DisplayConnectStatus (
"\pInvalid message from server.", "\pInvalid message from server.",

View File

@ -18,10 +18,16 @@ extern unsigned int rectHeight;
#define encodingRRE 2 #define encodingRRE 2
#define encodingCoRRE 4 #define encodingCoRRE 4
#define encodingHextile 5 #define encodingHextile 5
#define encodingZlib 6
#define encodingTight 7
#define encodingZlibhex 8
#define encodingTRLE 15
#define encodingZRLE 16 #define encodingZRLE 16
#define encodingCursor 0xffffff11 #define encodingCursor 0xffffff11
#define encodingDesktopSize 0xffffff21 #define encodingDesktopSize 0xffffff21
#define nonEncodingClipboard 3 /* should be different from any encoding */
#define WIN_WIDTH_320 302 #define WIN_WIDTH_320 302
#define WIN_WIDTH_640 613 #define WIN_WIDTH_640 613
#define WIN_HEIGHT 174 #define WIN_HEIGHT 174