Skip to content

Commit 0e72da1

Browse files
committed
libvncclient: add functionality to set what a client is requesting
With this new API, the caller can tell the client to only request a subset of the remote framebuffer during incremental framebuffer requests.
1 parent 7703004 commit 0e72da1

3 files changed

Lines changed: 53 additions & 3 deletions

File tree

include/rfb/rfbclient.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ typedef struct _rfbClient {
486486
* Callback fired when "Extended Clipboard" UTF-8 text data is received.
487487
*/
488488
GotXCutTextUTF8Proc GotXCutTextUTF8;
489+
490+
/* flag to indicate wheter updateRect is managed by lib or user */
491+
rfbBool isUpdateRectManagedByLib;
489492
} rfbClient;
490493

491494
/* cursor.c */
@@ -672,6 +675,26 @@ extern void PrintPixelFormat(rfbPixelFormat *format);
672675
extern rfbBool SupportsClient2Server(rfbClient* client, int messageType);
673676
extern rfbBool SupportsServer2Client(rfbClient* client, int messageType);
674677

678+
/**
679+
* Set the rectangle the client is interested in. If set, the client will
680+
* ask only for the given rectangle in incremental framebuffer requests.
681+
* @param client The client on which to set the rectangle
682+
* @param rect The rectangle the client is interested in. The function does
683+
* not take ownership of 'rect'. Set to NULL to have the library
684+
* manage this, which means always request the full remote
685+
* framebuffer.
686+
*/
687+
extern void rfbClientSetUpdateRect(rfbClient *client, rfbRectangle *rect);
688+
689+
/**
690+
* Get the rectangle the client asks for in incremental framebuffer
691+
* requests.
692+
* @param client The client for which to get the rectangle
693+
* @param rect Will be filled with what's currently set for the given client
694+
* @param isManagedbylib Will be set to TRUE if client is using the default
695+
*/
696+
extern void rfbClientGetUpdateRect(rfbClient *client, rfbRectangle *rect, rfbBool *isManagedByLib);
697+
675698
/* client data */
676699

677700
/**

src/libvncclient/rfbclient.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,9 +1684,12 @@ ResizeClientBuffer(rfbClient* client, int width, int height)
16841684
{
16851685
client->width = width;
16861686
client->height = height;
1687-
client->updateRect.x = client->updateRect.y = 0;
1688-
client->updateRect.w = client->width;
1689-
client->updateRect.h = client->height;
1687+
/* Only adadpt updateRect to new dimensions if managed by lib */
1688+
if (client->isUpdateRectManagedByLib) {
1689+
client->updateRect.x = client->updateRect.y = 0;
1690+
client->updateRect.w = client->width;
1691+
client->updateRect.h = client->height;
1692+
}
16901693
return client->MallocFrameBuffer(client);
16911694
}
16921695

@@ -1972,6 +1975,29 @@ rfbClientProcessExtServerCutText(rfbClient* client, char *data, int len)
19721975
}
19731976
#endif
19741977

1978+
void rfbClientSetUpdateRect(rfbClient *client, rfbRectangle *rect) {
1979+
if (rect) {
1980+
client->updateRect.x = rect->x;
1981+
client->updateRect.y = rect->y;
1982+
client->updateRect.w = rect->w;
1983+
client->updateRect.h = rect->h;
1984+
client->isUpdateRectManagedByLib = FALSE;
1985+
} else {
1986+
/* rect NULL, reset to defaults */
1987+
client->updateRect.x = client->updateRect.y = 0;
1988+
client->updateRect.w = client->width;
1989+
client->updateRect.h = client->height;
1990+
client->isUpdateRectManagedByLib = TRUE;
1991+
}
1992+
}
1993+
1994+
void rfbClientGetUpdateRect(rfbClient *client, rfbRectangle *rect, rfbBool *isManagedByLib) {
1995+
rect->x = client->updateRect.x;
1996+
rect->y = client->updateRect.y;
1997+
rect->w = client->updateRect.w;
1998+
rect->h = client->updateRect.h;
1999+
*isManagedByLib = client->isUpdateRectManagedByLib;
2000+
}
19752001

19762002
/*
19772003
* HandleRFBServerMessage.

src/libvncclient/vncviewer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ static rfbBool rfbInitConnection(rfbClient* client)
403403
client->updateRect.x = client->updateRect.y = 0;
404404
client->updateRect.w = client->width;
405405
client->updateRect.h = client->height;
406+
client->isUpdateRectManagedByLib = TRUE;
406407
}
407408

408409
if (client->appData.scaleSetting>1)

0 commit comments

Comments
 (0)