Don't request another FBUpdate in NextRect if one is already coming.

This helps avoid issues where the GS may be unable to "catch up" with the stream of FBUpdates, resulting in it continually drawing out-of-date screen data.
This commit is contained in:
Stephen Heumann 2016-09-21 18:30:03 -05:00
parent a6a34dd080
commit 5c1fc77f9b

View File

@ -39,6 +39,7 @@ unsigned int fbHeight;
unsigned int fbWidth; unsigned int fbWidth;
BOOLEAN displayInProgress; BOOLEAN displayInProgress;
static BOOLEAN peekedNextMsg;
static unsigned int numRects; static unsigned int numRects;
unsigned int rectX; unsigned int rectX;
@ -66,6 +67,12 @@ BOOLEAN checkBounds = FALSE; /* Adjust drawing to stay in bounds */
unsigned long skipBytes = 0; unsigned long skipBytes = 0;
/* Server-to-client message types */
#define FBUpdate 0
#define SetColourMapEntries 1
#define Bell 2
#define ServerCutText 3
#define txtColor 10 #define txtColor 10
#define txtGray 11 #define txtGray 11
#define txtTransfers 23 #define txtTransfers 23
@ -187,6 +194,7 @@ void InitVNCWindow(void) {
/* We also take the opportunity here to initialize the rectangle info. */ /* We also take the opportunity here to initialize the rectangle info. */
numRects = 0; numRects = 0;
displayInProgress = FALSE; displayInProgress = FALSE;
peekedNextMsg = FALSE;
#undef wrNum320 #undef wrNum320
#undef wrNum640 #undef wrNum640
@ -289,6 +297,16 @@ void NextRect (void) {
DoneWithReadBuffer(); DoneWithReadBuffer();
if (DoReadTCP(1)) {
peekedNextMsg = TRUE;
if (*readBufferPtr == FBUpdate) {
/* Don't request another FBUpdate if one is already coming.
* This helps avoid a condition where the GS may be unable
* to "catch up" with a stream of frequent updates. */
return;
}
}
contentOrigin.l = GetContentOrigin(vncWindow); contentOrigin.l = GetContentOrigin(vncWindow);
SendFBUpdateRequest(TRUE, contentOrigin.pt.h, contentOrigin.pt.v, SendFBUpdateRequest(TRUE, contentOrigin.pt.h, contentOrigin.pt.v,
winWidth, winHeight); winWidth, winHeight);
@ -297,10 +315,6 @@ void NextRect (void) {
void ConnectedEventLoop (void) { void ConnectedEventLoop (void) {
unsigned char messageType; unsigned char messageType;
#define FBUpdate 0
#define SetColourMapEntries 1
#define Bell 2
#define ServerCutText 3
if (FrontWindow() != vncWindow && menuOffset == noKB) if (FrontWindow() != vncWindow && menuOffset == noKB)
InitMenus(0); InitMenus(0);
@ -346,7 +360,8 @@ void ConnectedEventLoop (void) {
return; return;
} }
} }
else if (DoReadTCP(1)) { /* Read message type byte */ else if (peekedNextMsg || DoReadTCP(1)) { /* Read message type byte */
peekedNextMsg = FALSE;
messageType = *readBufferPtr; messageType = *readBufferPtr;
switch (messageType) { switch (messageType) {
case FBUpdate: DoFBUpdate(); case FBUpdate: DoFBUpdate();