|
|
@ -348,6 +348,8 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
|
|
|
|
cl->enableCursorPosUpdates = FALSE;
|
|
|
|
cl->enableCursorPosUpdates = FALSE;
|
|
|
|
cl->useRichCursorEncoding = FALSE;
|
|
|
|
cl->useRichCursorEncoding = FALSE;
|
|
|
|
cl->enableLastRectEncoding = FALSE;
|
|
|
|
cl->enableLastRectEncoding = FALSE;
|
|
|
|
|
|
|
|
cl->enableKeyboardLedState = FALSE;
|
|
|
|
|
|
|
|
cl->lastKeyboardLedState = -1;
|
|
|
|
cl->cursorX = rfbScreen->cursorX;
|
|
|
|
cl->cursorX = rfbScreen->cursorX;
|
|
|
|
cl->cursorY = rfbScreen->cursorY;
|
|
|
|
cl->cursorY = rfbScreen->cursorY;
|
|
|
|
cl->useNewFBSize = FALSE;
|
|
|
|
cl->useNewFBSize = FALSE;
|
|
|
@ -729,6 +731,40 @@ static rfbBool rectSwapIfLEAndClip(uint16_t* x,uint16_t* y,uint16_t* w,uint16_t*
|
|
|
|
return TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Send keyboard state (PointerPos pseudo-encoding).
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rfbBool
|
|
|
|
|
|
|
|
rfbSendKeyboardLedState(rfbClientPtr cl)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
rfbFramebufferUpdateRectHeader rect;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cl->ublen + sz_rfbFramebufferUpdateRectHeader > UPDATE_BUF_SIZE) {
|
|
|
|
|
|
|
|
if (!rfbSendUpdateBuf(cl))
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rect.encoding = Swap32IfLE(rfbEncodingKeyboardLedState);
|
|
|
|
|
|
|
|
rect.r.x = Swap16IfLE(cl->lastKeyboardLedState);
|
|
|
|
|
|
|
|
rect.r.y = 0;
|
|
|
|
|
|
|
|
rect.r.w = 0;
|
|
|
|
|
|
|
|
rect.r.h = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(&cl->updateBuf[cl->ublen], (char *)&rect,
|
|
|
|
|
|
|
|
sz_rfbFramebufferUpdateRectHeader);
|
|
|
|
|
|
|
|
cl->ublen += sz_rfbFramebufferUpdateRectHeader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cl->cursorPosBytesSent += sz_rfbFramebufferUpdateRectHeader;
|
|
|
|
|
|
|
|
cl->cursorPosUpdatesSent++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!rfbSendUpdateBuf(cl))
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* rfbProcessClientNormalMessage is called when the client has sent a normal
|
|
|
|
* rfbProcessClientNormalMessage is called when the client has sent a normal
|
|
|
|
* protocol message.
|
|
|
|
* protocol message.
|
|
|
@ -911,6 +947,13 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
|
|
|
|
cl->useNewFBSize = TRUE;
|
|
|
|
cl->useNewFBSize = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rfbEncodingKeyboardLedState:
|
|
|
|
|
|
|
|
if (!cl->enableKeyboardLedState) {
|
|
|
|
|
|
|
|
rfbLog("Enabling KeyboardLedState protocol extension for client "
|
|
|
|
|
|
|
|
"%s\n", cl->host);
|
|
|
|
|
|
|
|
cl->enableKeyboardLedState = TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
#ifdef LIBVNCSERVER_HAVE_LIBZ
|
|
|
|
#ifdef LIBVNCSERVER_HAVE_LIBZ
|
|
|
|
case rfbEncodingZRLE:
|
|
|
|
case rfbEncodingZRLE:
|
|
|
|
if (cl->preferredEncoding == -1) {
|
|
|
|
if (cl->preferredEncoding == -1) {
|
|
|
@ -1175,8 +1218,10 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
|
|
|
|
int dx, dy;
|
|
|
|
int dx, dy;
|
|
|
|
rfbBool sendCursorShape = FALSE;
|
|
|
|
rfbBool sendCursorShape = FALSE;
|
|
|
|
rfbBool sendCursorPos = FALSE;
|
|
|
|
rfbBool sendCursorPos = FALSE;
|
|
|
|
|
|
|
|
rfbBool sendKeyboardLedState = FALSE;
|
|
|
|
rfbBool result = TRUE;
|
|
|
|
rfbBool result = TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(cl->screen->displayHook)
|
|
|
|
if(cl->screen->displayHook)
|
|
|
|
cl->screen->displayHook(cl);
|
|
|
|
cl->screen->displayHook(cl);
|
|
|
|
|
|
|
|
|
|
|
@ -1216,6 +1261,21 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
|
|
|
|
if (cl->enableCursorPosUpdates && cl->cursorWasMoved)
|
|
|
|
if (cl->enableCursorPosUpdates && cl->cursorWasMoved)
|
|
|
|
sendCursorPos = TRUE;
|
|
|
|
sendCursorPos = TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Do we plan to send a keyboard state update?
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((cl->enableKeyboardLedState) &&
|
|
|
|
|
|
|
|
(cl->screen->getKeyboardLedStateHook!=NULL))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int x;
|
|
|
|
|
|
|
|
x=cl->screen->getKeyboardLedStateHook(cl->screen);
|
|
|
|
|
|
|
|
if (x!=cl->lastKeyboardLedState)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sendKeyboardLedState = TRUE;
|
|
|
|
|
|
|
|
cl->lastKeyboardLedState=x;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOCK(cl->updateMutex);
|
|
|
|
LOCK(cl->updateMutex);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -1259,7 +1319,7 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
|
|
|
|
sraRgnEmpty(updateRegion) &&
|
|
|
|
sraRgnEmpty(updateRegion) &&
|
|
|
|
(cl->enableCursorShapeUpdates ||
|
|
|
|
(cl->enableCursorShapeUpdates ||
|
|
|
|
(cl->cursorX == cl->screen->cursorX && cl->cursorY == cl->screen->cursorY)) &&
|
|
|
|
(cl->cursorX == cl->screen->cursorX && cl->cursorY == cl->screen->cursorY)) &&
|
|
|
|
!sendCursorShape && !sendCursorPos) {
|
|
|
|
!sendCursorShape && !sendCursorPos && !sendKeyboardLedState) {
|
|
|
|
sraRgnDestroy(updateRegion);
|
|
|
|
sraRgnDestroy(updateRegion);
|
|
|
|
UNLOCK(cl->updateMutex);
|
|
|
|
UNLOCK(cl->updateMutex);
|
|
|
|
return TRUE;
|
|
|
|
return TRUE;
|
|
|
@ -1395,7 +1455,7 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fu->nRects = Swap16IfLE((uint16_t)(sraRgnCountRects(updateCopyRegion) +
|
|
|
|
fu->nRects = Swap16IfLE((uint16_t)(sraRgnCountRects(updateCopyRegion) +
|
|
|
|
nUpdateRegionRects +
|
|
|
|
nUpdateRegionRects +
|
|
|
|
!!sendCursorShape + !!sendCursorPos));
|
|
|
|
!!sendCursorShape + !!sendCursorPos + !!sendKeyboardLedState));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
fu->nRects = 0xFFFF;
|
|
|
|
fu->nRects = 0xFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1413,6 +1473,11 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
|
|
|
|
goto updateFailed;
|
|
|
|
goto updateFailed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sendKeyboardLedState) {
|
|
|
|
|
|
|
|
if (!rfbSendKeyboardLedState(cl))
|
|
|
|
|
|
|
|
goto updateFailed;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!sraRgnEmpty(updateCopyRegion)) {
|
|
|
|
if (!sraRgnEmpty(updateCopyRegion)) {
|
|
|
|
if (!rfbSendCopyRegion(cl,updateCopyRegion,dx,dy))
|
|
|
|
if (!rfbSendCopyRegion(cl,updateCopyRegion,dx,dy))
|
|
|
|
goto updateFailed;
|
|
|
|
goto updateFailed;
|
|
|
|