Commit 7602f0e7 authored by dscho's avatar dscho

libvncclient: support changing of framebuffer size; make SDLvncviewer use it

parent 9b51d63d
...@@ -209,6 +209,7 @@ int main(int argc,char** argv) { ...@@ -209,6 +209,7 @@ int main(int argc,char** argv) {
/* 16-bit: cl=rfbGetClient(5,3,2); */ /* 16-bit: cl=rfbGetClient(5,3,2); */
cl=rfbGetClient(8,3,4); cl=rfbGetClient(8,3,4);
cl->MallocFrameBuffer=resize; cl->MallocFrameBuffer=resize;
cl->canHandleNewFBSize = TRUE;
cl->GotFrameBufferUpdate=update; cl->GotFrameBufferUpdate=update;
cl->HandleKeyboardLedState=kbd_leds; cl->HandleKeyboardLedState=kbd_leds;
......
...@@ -138,14 +138,14 @@ static void FillRectangle(rfbClient* client, int x, int y, int w, int h, uint32_ ...@@ -138,14 +138,14 @@ static void FillRectangle(rfbClient* client, int x, int y, int w, int h, uint32_
} }
static void CopyRectangle(rfbClient* client, uint8_t* buffer, int x, int y, int w, int h) { static void CopyRectangle(rfbClient* client, uint8_t* buffer, int x, int y, int w, int h) {
int i,j; int j;
#define COPY_RECT(BPP) \ #define COPY_RECT(BPP) \
{ \ { \
uint##BPP##_t* _buffer=(uint##BPP##_t*)buffer; \ int rs = w * BPP / 8, rs2 = client->width * BPP / 8; \
for(j=y*client->width;j<(y+h)*client->width;j+=client->width) { \ for (j = x + y * rs2; j < (y + h) * rs2; j += rs2) { \
for(i=x;i<x+w;i++,_buffer++) \ memcpy(client->frameBuffer + j, buffer, rs); \
((uint##BPP##_t*)client->frameBuffer)[j+i]=*_buffer; \ buffer += rs; \
} \ } \
} }
...@@ -592,14 +592,17 @@ SetFormatAndEncodings(rfbClient* client) ...@@ -592,14 +592,17 @@ SetFormatAndEncodings(rfbClient* client)
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingPointerPos); encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingPointerPos);
} }
/* Keyboard State Encodings */ if (se->nEncodings < MAX_ENCODINGS)
if (se->nEncodings < MAX_ENCODINGS) { encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingLastRect);
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingKeyboardLedState);
}
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingLastRect);
} }
/* Keyboard State Encodings */
if (se->nEncodings < MAX_ENCODINGS)
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingKeyboardLedState);
if (se->nEncodings < MAX_ENCODINGS && client->canHandleNewFBSize)
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingNewFBSize);
for(e = rfbClientExtensions; e; e = e->next) for(e = rfbClientExtensions; e; e = e->next)
if(e->encodings) { if(e->encodings) {
int* enc; int* enc;
...@@ -624,8 +627,8 @@ SetFormatAndEncodings(rfbClient* client) ...@@ -624,8 +627,8 @@ SetFormatAndEncodings(rfbClient* client)
rfbBool rfbBool
SendIncrementalFramebufferUpdateRequest(rfbClient* client) SendIncrementalFramebufferUpdateRequest(rfbClient* client)
{ {
return SendFramebufferUpdateRequest(client, 0, 0, client->si.framebufferWidth, return SendFramebufferUpdateRequest(client, 0, 0, client->width,
client->si.framebufferHeight, TRUE); client->height, TRUE);
} }
...@@ -807,8 +810,17 @@ HandleRFBServerMessage(rfbClient* client) ...@@ -807,8 +810,17 @@ HandleRFBServerMessage(rfbClient* client)
continue; continue;
} }
if ((rect.r.x + rect.r.w > client->si.framebufferWidth) || if (rect.encoding == rfbEncodingNewFBSize) {
(rect.r.y + rect.r.h > client->si.framebufferHeight)) client->width = rect.r.w;
client->height = rect.r.h;
client->MallocFrameBuffer(client);
SendFramebufferUpdateRequest(client, 0, 0, rect.r.w, rect.r.h, FALSE);
rfbClientLog("Got new framebuffer size: %dx%d\n", rect.r.w, rect.r.h);
continue;
}
if ((rect.r.x + rect.r.w > client->width) ||
(rect.r.y + rect.r.h > client->height))
{ {
rfbClientLog("Rect too large: %dx%d at (%d, %d)\n", rfbClientLog("Rect too large: %dx%d at (%d, %d)\n",
rect.r.w, rect.r.h, rect.r.x, rect.r.y); rect.r.w, rect.r.h, rect.r.x, rect.r.y);
......
...@@ -201,6 +201,8 @@ typedef struct _rfbClient { ...@@ -201,6 +201,8 @@ typedef struct _rfbClient {
int KeyboardLedStateEnabled; int KeyboardLedStateEnabled;
int CurrentKeyboardLedState; int CurrentKeyboardLedState;
int canHandleNewFBSize;
/* hooks */ /* hooks */
HandleKeyboardLedStateProc HandleKeyboardLedState; HandleKeyboardLedStateProc HandleKeyboardLedState;
HandleCursorPosProc HandleCursorPos; HandleCursorPosProc HandleCursorPos;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment