From 09f7c684a2b7eb43f283dcd938f0ccad891724e8 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Wed, 19 May 2010 20:51:26 +0200 Subject: [PATCH] Implement a DisplayFinishedHook for libvncserver. If set, this hook gets called just before rfbSendFrameBufferUpdate() returns. Signed-off-by: Christian Beier --- libvncserver/main.c | 1 + libvncserver/rfbserver.c | 12 +++++++++++- rfb/rfb.h | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libvncserver/main.c b/libvncserver/main.c index b6bd930..6aa82d3 100644 --- a/libvncserver/main.c +++ b/libvncserver/main.c @@ -894,6 +894,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv, screen->setTranslateFunction = rfbSetTranslateFunction; screen->newClientHook = rfbDefaultNewClientHook; screen->displayHook = NULL; + screen->displayFinishedHook = NULL; screen->getKeyboardLedStateHook = NULL; /* initialize client list and iterator mutex */ diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c index 465d767..48fd74a 100644 --- a/libvncserver/rfbserver.c +++ b/libvncserver/rfbserver.c @@ -2446,9 +2446,14 @@ rfbSendFramebufferUpdate(rfbClientPtr cl, fu->nRects = Swap16IfLE(1); cl->ublen = sz_rfbFramebufferUpdateMsg; if (!rfbSendNewFBSize(cl, cl->scaledScreen->width, cl->scaledScreen->height)) { + if(cl->screen->displayFinishedHook) + cl->screen->displayFinishedHook(cl, FALSE); return FALSE; } - return rfbSendUpdateBuf(cl); + result = rfbSendUpdateBuf(cl); + if(cl->screen->displayFinishedHook) + cl->screen->displayFinishedHook(cl, result); + return result; } /* @@ -2564,6 +2569,8 @@ rfbSendFramebufferUpdate(rfbClientPtr cl, !sendSupportedMessages && !sendSupportedEncodings && !sendServerIdentity) { sraRgnDestroy(updateRegion); UNLOCK(cl->updateMutex); + if(cl->screen->displayFinishedHook) + cl->screen->displayFinishedHook(cl, TRUE); return TRUE; } @@ -2841,6 +2848,9 @@ updateFailed: sraRgnReleaseIterator(i); sraRgnDestroy(updateRegion); sraRgnDestroy(updateCopyRegion); + + if(cl->screen->displayFinishedHook) + cl->screen->displayFinishedHook(cl, result); return result; } diff --git a/rfb/rfb.h b/rfb/rfb.h index a03ab21..006cc2e 100644 --- a/rfb/rfb.h +++ b/rfb/rfb.h @@ -136,6 +136,7 @@ typedef rfbBool (*rfbSetTranslateFunctionProcPtr)(struct _rfbClientRec* cl); typedef rfbBool (*rfbPasswordCheckProcPtr)(struct _rfbClientRec* cl,const char* encryptedPassWord,int len); typedef enum rfbNewClientAction (*rfbNewClientHookPtr)(struct _rfbClientRec* cl); typedef void (*rfbDisplayHookPtr)(struct _rfbClientRec* cl); +typedef void (*rfbDisplayFinishedHookPtr)(struct _rfbClientRec* cl, int result); /* support the capability to view the caps/num/scroll states of the X server */ typedef int (*rfbGetKeyboardLedStateHookPtr)(struct _rfbScreenInfo* screen); /* If x==1 and y==1 then set the whole display @@ -352,6 +353,9 @@ typedef struct _rfbScreenInfo /* command line authorization of file transfers */ rfbBool permitFileTransfer; + + /* displayFinishedHook is called just after a frame buffer update */ + rfbDisplayFinishedHookPtr displayFinishedHook; } rfbScreenInfo, *rfbScreenInfoPtr;