/[rdesktop]/sourceforge.net/trunk/rdesktop/vnc/vnc.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/vnc/vnc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 651 by astrand, Thu Apr 15 20:12:42 2004 UTC revision 782 by astrand, Thu Oct 7 13:00:29 2004 UTC
# Line 84  BOOL enable_compose = False; Line 84  BOOL enable_compose = False;
84  void  void
85  vncHideCursor()  vncHideCursor()
86  {  {
87          if (server->rfbClientHead)          if (server->clientHead)
88                  rfbUndrawCursor(server);                  rfbUndrawCursor(server);
89  }  }
90    
# Line 218  vncMouse(int buttonMask, int x, int y, s Line 218  vncMouse(int buttonMask, int x, int y, s
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    
# Line 231  rdp2vnc_connect(char *server, uint32 fla Line 231  rdp2vnc_connect(char *server, uint32 fla
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);
# Line 259  rdp2vnc_connect(char *server, uint32 fla Line 259  rdp2vnc_connect(char *server, uint32 fla
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();
# Line 293  ui_create_window() Line 295  ui_create_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;
# Line 312  ui_create_window() Line 314  ui_create_window()
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();
# Line 332  ui_create_window() Line 334  ui_create_window()
334  void  void
335  ui_destroy_window()  ui_destroy_window()
336  {  {
337          rfbCloseClient(server->rfbClientHead);          rfbCloseClient(server->clientHead);
338  }  }
339    
340    
# Line 354  ui_select(int rdpSocket) Line 356  ui_select(int rdpSocket)
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;
# Line 465  ui_create_cursor(unsigned int x, unsigne Line 467  ui_create_cursor(unsigned int x, unsigne
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;
# Line 933  ui_desktop_save(uint32 offset, int x, in Line 936  ui_desktop_save(uint32 offset, int x, in
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    
# Line 949  ui_desktop_restore(uint32 offset, int x, Line 952  ui_desktop_restore(uint32 offset, int x,
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    
# Line 1007  vncDupBuffer(vncBuffer * b) Line 1010  vncDupBuffer(vncBuffer * b)
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 */
# Line 1026  vncCopyBlitFromNoEncode(rfbScreenInfoPtr Line 1029  vncCopyBlitFromNoEncode(rfbScreenInfoPtr
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
# Line 1240  vncSetRect(rfbScreenInfoPtr s, int x, in Line 1243  vncSetRect(rfbScreenInfoPtr s, int x, in
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;
# Line 1269  vncBuffer * Line 1272  vncBuffer *
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);
# Line 1341  vncSetColourMap(rfbScreenInfoPtr s, rfbC Line 1344  vncSetColourMap(rfbScreenInfoPtr s, rfbC
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    }

Legend:
Removed from v.651  
changed lines
  Added in v.782

  ViewVC Help
Powered by ViewVC 1.1.26