84 |
void |
void |
85 |
vncHideCursor() |
vncHideCursor() |
86 |
{ |
{ |
87 |
if (server->rfbClientHead) |
if (server->clientHead) |
88 |
rfbUndrawCursor(server); |
rfbUndrawCursor(server); |
89 |
} |
} |
90 |
|
|
218 |
lastbuttons = buttonMask; |
lastbuttons = buttonMask; |
219 |
|
|
220 |
/* handle cursor */ |
/* handle cursor */ |
221 |
defaultPtrAddEvent(buttonMask, x, y, cl); |
rfbDefaultPtrAddEvent(buttonMask, x, y, cl); |
222 |
} |
} |
223 |
|
|
224 |
|
|
231 |
struct timeval tv; |
struct timeval tv; |
232 |
int rfbListenSock, addrlen = sizeof(addr); |
int rfbListenSock, addrlen = sizeof(addr); |
233 |
|
|
234 |
rfbListenSock = ListenOnTCPPort(rfb_port); |
rfbListenSock = rfbListenOnTCPPort(rfb_port); |
235 |
fprintf(stderr, "Listening on VNC port %d\n", rfb_port); |
fprintf(stderr, "Listening on VNC port %d\n", rfb_port); |
236 |
if (rfbListenSock <= 0) |
if (rfbListenSock <= 0) |
237 |
error("Cannot listen on port %d", rfb_port); |
error("Cannot listen on port %d", rfb_port); |
259 |
} |
} |
260 |
if (!fork()) |
if (!fork()) |
261 |
{ |
{ |
262 |
|
BOOL deactivated; |
263 |
|
uint32_t ext_disc_reason; |
264 |
printf("Connection successful.\n"); |
printf("Connection successful.\n"); |
265 |
rdp_main_loop(); |
rdp_main_loop(&deactivated, &ext_disc_reason); |
266 |
printf("Disconnecting...\n"); |
printf("Disconnecting...\n"); |
267 |
rdp_disconnect(); |
rdp_disconnect(); |
268 |
ui_destroy_window(); |
ui_destroy_window(); |
295 |
server->kbdAddEvent = vncKey; |
server->kbdAddEvent = vncKey; |
296 |
#ifdef ENABLE_SHADOW |
#ifdef ENABLE_SHADOW |
297 |
server->httpPort = 6124 + client_counter; |
server->httpPort = 6124 + client_counter; |
298 |
server->rfbPort = 5924 + client_counter; |
server->port = 5924 + client_counter; |
299 |
rfbInitSockets(server); |
rfbInitSockets(server); |
300 |
server->rfbAlwaysShared = TRUE; |
server->alwaysShared = TRUE; |
301 |
server->rfbNeverShared = FALSE; |
server->neverShared = FALSE; |
302 |
#else |
#else |
303 |
server->rfbPort = -1; |
server->port = -1; |
304 |
server->rfbAlwaysShared = FALSE; |
server->alwaysShared = FALSE; |
305 |
server->rfbNeverShared = FALSE; |
server->neverShared = FALSE; |
306 |
#endif |
#endif |
307 |
server->inetdSock = rfbClientSocket; |
server->inetdSock = rfbClientSocket; |
308 |
server->rfbServerFormat.trueColour = FALSE; /* activate colour maps */ |
server->serverFormat.trueColour = FALSE; /* activate colour maps */ |
309 |
server->rfbDeferUpdateTime = defer_time; |
server->deferUpdateTime = defer_time; |
310 |
|
|
311 |
frameBuffer = (vncBuffer *) malloc(sizeof(vncBuffer)); |
frameBuffer = (vncBuffer *) malloc(sizeof(vncBuffer)); |
312 |
frameBuffer->w = g_width; |
frameBuffer->w = g_width; |
314 |
frameBuffer->linew = g_width; |
frameBuffer->linew = g_width; |
315 |
frameBuffer->data = server->frameBuffer; |
frameBuffer->data = server->frameBuffer; |
316 |
frameBuffer->owner = FALSE; |
frameBuffer->owner = FALSE; |
317 |
frameBuffer->format = &server->rfbServerFormat; |
frameBuffer->format = &server->serverFormat; |
318 |
|
|
319 |
ui_set_clip(0, 0, g_width, g_height); |
ui_set_clip(0, 0, g_width, g_height); |
320 |
|
|
321 |
rfbInitServer(server); |
rfbInitServer(server); |
322 |
#ifndef ENABLE_SHADOW |
#ifndef ENABLE_SHADOW |
323 |
server->rfbPort = rfb_port; |
server->port = rfb_port; |
324 |
#else |
#else |
325 |
fprintf(stderr, "server listening on port %d (socket %d)\n", server->rfbPort, |
fprintf(stderr, "server listening on port %d (socket %d)\n", server->port, |
326 |
server->rfbListenSock); |
server->listenSock); |
327 |
#endif |
#endif |
328 |
|
|
329 |
init_keyboard(); |
init_keyboard(); |
334 |
void |
void |
335 |
ui_destroy_window() |
ui_destroy_window() |
336 |
{ |
{ |
337 |
rfbCloseClient(server->rfbClientHead); |
rfbCloseClient(server->clientHead); |
338 |
} |
} |
339 |
|
|
340 |
|
|
356 |
n = select(m + 1, &fds, NULL, NULL, &tv); |
n = select(m + 1, &fds, NULL, NULL, &tv); |
357 |
rfbProcessEvents(server, 0); |
rfbProcessEvents(server, 0); |
358 |
/* if client is gone, close connection */ |
/* if client is gone, close connection */ |
359 |
if (!server->rfbClientHead) |
if (!server->clientHead) |
360 |
close(rdpSocket); |
close(rdpSocket); |
361 |
if (FD_ISSET(rdpSocket, &fds)) |
if (FD_ISSET(rdpSocket, &fds)) |
362 |
return 1; |
return 1; |
467 |
cursor->mask = (char *) d0; |
cursor->mask = (char *) d0; |
468 |
cursor->source = 0; |
cursor->source = 0; |
469 |
cursor->richSource = cdata; |
cursor->richSource = cdata; |
470 |
|
cursor->cleanup = 0; // workaround: this produces a memleak |
471 |
|
|
472 |
cursor->backRed = cursor->backGreen = cursor->backBlue = 0xffff; |
cursor->backRed = cursor->backGreen = cursor->backBlue = 0xffff; |
473 |
cursor->foreRed = cursor->foreGreen = cursor->foreBlue = 0; |
cursor->foreRed = cursor->foreGreen = cursor->foreBlue = 0; |
936 |
vncBuffer *buf; |
vncBuffer *buf; |
937 |
|
|
938 |
buf = vncGetRect(server, x, y, cx, cy); |
buf = vncGetRect(server, x, y, cx, cy); |
939 |
offset *= TOBYTES(server->rfbServerFormat.bitsPerPixel); |
offset *= TOBYTES(server->serverFormat.bitsPerPixel); |
940 |
cache_put_desktop(offset, cx, cy, cx, TOBYTES(server->rfbServerFormat.bitsPerPixel), |
cache_put_desktop(offset, cx, cy, cx, TOBYTES(server->serverFormat.bitsPerPixel), |
941 |
(buf->data)); |
(buf->data)); |
942 |
} |
} |
943 |
|
|
952 |
ox = x; |
ox = x; |
953 |
oy = y; |
oy = y; |
954 |
|
|
955 |
offset *= TOBYTES(server->rfbServerFormat.bitsPerPixel); |
offset *= TOBYTES(server->serverFormat.bitsPerPixel); |
956 |
data = cache_get_desktop(offset, cx, cy, TOBYTES(server->rfbServerFormat.bitsPerPixel)); |
data = cache_get_desktop(offset, cx, cy, TOBYTES(server->serverFormat.bitsPerPixel)); |
957 |
if (data == NULL) |
if (data == NULL) |
958 |
return; |
return; |
959 |
|
|
1010 |
void |
void |
1011 |
vncPrintStats() |
vncPrintStats() |
1012 |
{ |
{ |
1013 |
if (server && server->rfbClientHead) |
if (server && server->clientHead) |
1014 |
rfbPrintStats(server->rfbClientHead); |
rfbPrintStats(server->clientHead); |
1015 |
} |
} |
1016 |
|
|
1017 |
/* blit */ |
/* blit */ |
1029 |
|
|
1030 |
vncHideCursor(); |
vncHideCursor(); |
1031 |
|
|
1032 |
if (s->rfbServerFormat.bitsPerPixel == src->format->bitsPerPixel |
if (s->serverFormat.bitsPerPixel == src->format->bitsPerPixel |
1033 |
&& srcx + w <= src->w && srcy + h <= src->h) |
&& srcx + w <= src->w && srcy + h <= src->h) |
1034 |
{ |
{ |
1035 |
//simple copy |
//simple copy |
1243 |
vncHideCursor(); |
vncHideCursor(); |
1244 |
|
|
1245 |
// - Fill the rect in the local framebuffer |
// - Fill the rect in the local framebuffer |
1246 |
if (s->rfbServerFormat.bitsPerPixel == 8) |
if (s->serverFormat.bitsPerPixel == 8) |
1247 |
{ |
{ |
1248 |
// - Simple 8-bit fill |
// - Simple 8-bit fill |
1249 |
uint8_t *dstdata; |
uint8_t *dstdata; |
1272 |
vncGetRect(rfbScreenInfoPtr s, int x, int y, int w, int h) |
vncGetRect(rfbScreenInfoPtr s, int x, int y, int w, int h) |
1273 |
{ |
{ |
1274 |
int xx, yy; |
int xx, yy; |
1275 |
vncBuffer *b = vncNewBuffer(w, h, s->rfbServerFormat.depth); |
vncBuffer *b = vncNewBuffer(w, h, s->serverFormat.depth); |
1276 |
|
|
1277 |
vncHideCursor(); |
vncHideCursor(); |
1278 |
|
|
1279 |
if (s->rfbServerFormat.bitsPerPixel == 8) |
if (s->serverFormat.bitsPerPixel == 8) |
1280 |
{ |
{ |
1281 |
//simple copy |
//simple copy |
1282 |
int srcstep, dststep; |
int srcstep, dststep; |
1283 |
char *srcdata, *dstdata; |
char *srcdata, *dstdata; |
1284 |
srcstep = s->paddedWidthInBytes * s->rfbServerFormat.bitsPerPixel / 8; |
srcstep = s->paddedWidthInBytes * s->serverFormat.bitsPerPixel / 8; |
1285 |
dststep = w * s->rfbServerFormat.bitsPerPixel / 8; |
dststep = w * s->serverFormat.bitsPerPixel / 8; |
1286 |
dstdata = b->data; |
dstdata = b->data; |
1287 |
srcdata = s->frameBuffer + (y * srcstep + x * s->rfbServerFormat.bitsPerPixel / 8); |
srcdata = s->frameBuffer + (y * srcstep + x * s->serverFormat.bitsPerPixel / 8); |
1288 |
for (yy = 0; yy < h; yy++) |
for (yy = 0; yy < h; yy++) |
1289 |
{ |
{ |
1290 |
memcpy(dstdata, srcdata, dststep); |
memcpy(dstdata, srcdata, dststep); |
1344 |
s->colourMap = *m; |
s->colourMap = *m; |
1345 |
rfbSetClientColourMaps(s, 0, 0); |
rfbSetClientColourMaps(s, 0, 0); |
1346 |
} |
} |
1347 |
|
|
1348 |
|
void |
1349 |
|
ui_begin_update() |
1350 |
|
{ |
1351 |
|
} |
1352 |
|
|
1353 |
|
void |
1354 |
|
ui_end_update() |
1355 |
|
{ |
1356 |
|
} |
1357 |
|
|
1358 |
|
void |
1359 |
|
ui_resize_window() |
1360 |
|
{ |
1361 |
|
rfbClientIteratorPtr iter; |
1362 |
|
rfbClientPtr cl; |
1363 |
|
|
1364 |
|
server->width = g_width; |
1365 |
|
server->height = g_height; |
1366 |
|
server->frameBuffer = (char *) realloc(server->frameBuffer, g_width * g_height); |
1367 |
|
server->paddedWidthInBytes = g_width; |
1368 |
|
|
1369 |
|
iter = rfbGetClientIterator(server); |
1370 |
|
while ((cl = rfbClientIteratorNext(iter))) |
1371 |
|
if (cl->useNewFBSize) |
1372 |
|
cl->newFBSizePending = TRUE; |
1373 |
|
else |
1374 |
|
rfbLog("Warning: Client %s does not support NewFBSize!\n ", cl->host); |
1375 |
|
rfbReleaseClientIterator(iter); |
1376 |
|
} |