This commit is contained in:
Saul Gio Perez 2013-02-09 16:39:31 -08:00 committed by Michael Jumper
parent 58a0422008
commit 50ed651c1f
3 changed files with 44 additions and 1 deletions

View File

@ -48,6 +48,7 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client);
void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen); void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen);
void guac_vnc_client_log_info(const char* format, ...); void guac_vnc_client_log_info(const char* format, ...);
void guac_vnc_client_log_error(const char* format, ...); void guac_vnc_client_log_error(const char* format, ...);
void guac_vnc_set_pixel_format(rfbClient* client, int color_depth);
#endif #endif

View File

@ -56,6 +56,7 @@ const char* GUAC_CLIENT_ARGS[] = {
"encodings", "encodings",
"password", "password",
"swap-red-blue", "swap-red-blue",
"color-depth",
NULL NULL
}; };
@ -75,7 +76,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/*** PARSE ARGUMENTS ***/ /*** PARSE ARGUMENTS ***/
if (argc < 6) { if (argc < 7) {
guac_protocol_send_error(client->socket, "Wrong argument count received."); guac_protocol_send_error(client->socket, "Wrong argument count received.");
guac_socket_flush(client->socket); guac_socket_flush(client->socket);
return 1; return 1;
@ -117,6 +118,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/* Password */ /* Password */
rfb_client->GetPassword = guac_vnc_get_password; rfb_client->GetPassword = guac_vnc_get_password;
/* Depth */
guac_vnc_set_pixel_format(rfb_client, atoi(argv[6]));
/* Hook into allocation so we can handle resize. */ /* Hook into allocation so we can handle resize. */
guac_client_data->rfb_MallocFrameBuffer = rfb_client->MallocFrameBuffer; guac_client_data->rfb_MallocFrameBuffer = rfb_client->MallocFrameBuffer;

View File

@ -251,6 +251,44 @@ char* guac_vnc_get_password(rfbClient* client) {
return ((vnc_guac_client_data*) gc->data)->password; return ((vnc_guac_client_data*) gc->data)->password;
} }
void guac_vnc_set_pixel_format(rfbClient* client, int color_depth) {
switch(color_depth) {
case 8:
client->format.depth = 8;
client->format.bitsPerPixel = 8;
client->format.blueShift = 6;
client->format.redShift = 0;
client->format.greenShift = 3;
client->format.blueMax = 3;
client->format.redMax = 7;
client->format.greenMax = 7;
break;
case 16:
client->format.depth = 16;
client->format.bitsPerPixel = 16;
client->format.blueShift = 0;
client->format.redShift = 11;
client->format.greenShift = 5;
client->format.blueMax = 0x1f;
client->format.redMax = 0x1f;
client->format.greenMax = 0x3f;
break;
case 24:
case 32:
default:
client->format.depth = 24;
client->format.bitsPerPixel = 32;
client->format.blueShift = 0;
client->format.redShift = 16;
client->format.greenShift = 8;
client->format.blueMax = 0xff;
client->format.redMax = 0xff;
client->format.greenMax = 0xff;
}
}
rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) {
guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT); guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT);