ReactOS  0.4.11-dev-465-g0e6bc23
vnc.c File Reference
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include "../rdesktop.h"
#include "vnc.h"
#include <errno.h>
#include <rfb/rfbregion.h>
Include dependency graph for vnc.c:

Go to the source code of this file.

Macros

#define BITSPERBYTES   8
 
#define TOBYTES(bits)   ((bits)/BITSPERBYTES)
 
#define FIRST_MODIFIER   XK_Shift_L
 
#define LAST_MODIFIER   XK_Hyper_R
 
#define DO_GLYPH(ttext, idx)
 
#define GETPIXEL(buf, x, y)   (((uint8_t*)(buf->data))[(x)+((y)*buf->linew)])
 
#define SETPIXEL(buf, x, y, p)   (((uint8_t*)(buf->data))[(x)+((y)*buf->linew)] = (uint8_t)p)
 

Functions

int ListenOnTCPPort (int port)
 
void vncHideCursor ()
 
BOOL vncwinClipRect (int *x, int *y, int *cx, int *cy)
 
void xwin_toggle_fullscreen (void)
 
void init_keyboard ()
 
BOOL get_key_state (unsigned int state, uint32 keysym)
 
void vncKey (rfbBool down, rfbKeySym keysym, struct _rfbClientRec *cl)
 
void vncMouse (int buttonMask, int x, int y, struct _rfbClientRec *cl)
 
void rdp2vnc_connect (char *server, uint32 flags, char *domain, char *password, char *shell, char *directory)
 
BOOL ui_create_window ()
 
void ui_destroy_window ()
 
int ui_select (int rdpSocket)
 
void ui_move_pointer (int x, int y)
 
HBITMAP ui_create_bitmap (int width, int height, uint8 *data)
 
void ui_paint_bitmap (int x, int y, int cx, int cy, int width, int height, uint8 *data)
 
void ui_destroy_bitmap (HBITMAP bmp)
 
uint8_t vncLookupColour (rfbColourMap *colourMap, uint8_t *p)
 
HCURSOR ui_create_cursor (unsigned int x, unsigned int y, int width, int height, uint8 *mask, uint8 *data)
 
void ui_set_cursor (HCURSOR cursor)
 
void ui_destroy_cursor (HCURSOR cursor)
 
void ui_set_null_cursor (void)
 
HGLYPH ui_create_glyph (int width, int height, uint8 *data)
 
void ui_destroy_glyph (HGLYPH glyph)
 
HCOLOURMAP ui_create_colourmap (COLOURMAP *colours)
 
void ui_destroy_colourmap (HCOLOURMAP map)
 
void ui_set_colourmap (HCOLOURMAP map)
 
void ui_set_clip (int x, int y, int cx, int cy)
 
void ui_reset_clip ()
 
void ui_bell ()
 
void ui_destblt (uint8 opcode, int x, int y, int cx, int cy)
 
void ui_patblt (uint8 opcode, int x, int y, int cx, int cy, BRUSH *brush, int bgcolour, int fgcolour)
 
void ui_screenblt (uint8 opcode, int x, int y, int cx, int cy, int srcx, int srcy)
 
void ui_memblt (uint8 opcode, int x, int y, int cx, int cy, HBITMAP src, int srcx, int srcy)
 
void ui_triblt (uint8 opcode, int x, int y, int cx, int cy, HBITMAP src, int srcx, int srcy, BRUSH *brush, int bgcolour, int fgcolour)
 
void ui_line (uint8 opcode, int startx, int starty, int endx, int endy, PEN *pen)
 
void ui_rect (int x, int y, int cx, int cy, int colour)
 
void ui_draw_glyph (int mixmode, int x, int y, int cx, int cy, HGLYPH glyph, int srcx, int srcy, int bgcolour, int fgcolour)
 
void ui_draw_text (uint8 font, uint8 flags, int mixmode, int x, int y, int clipx, int clipy, int clipcx, int clipcy, int boxx, int boxy, int boxcx, int boxcy, int bgcolour, int fgcolour, uint8 *text, uint8 length)
 
void ui_desktop_save (uint32 offset, int x, int y, int cx, int cy)
 
void ui_desktop_restore (uint32 offset, int x, int y, int cx, int cy)
 
rfbPixelFormat * vncNewFormat (int depth)
 
vncBuffervncNewBuffer (int w, int h, int depth)
 
vncBuffervncDupBuffer (vncBuffer *b)
 
void vncPrintStats ()
 
void vncCopyBlitFromNoEncode (rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
 
void vncCopyBlit (rfbScreenInfoPtr s, int x, int y, int w, int h, int srcx, int srcy)
 
void vncCopyBlitFrom (rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
 
void vncTransBlitFrom (rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy, int bg)
 
void vncXorBlitFrom (rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
 
void vncAndBlitFrom (rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
 
void vncDeleteBuffer (vncBuffer *b)
 
rfbCursorPtr vncNewCursor (vncBuffer *mask, vncBuffer *pointer, int hotx, int hoty)
 
void vncSetCursor (rfbScreenInfoPtr s, rfbCursorPtr c)
 
vncPixel vncGetPixel (vncBuffer *b, int x, int y)
 
void vncSetPixel (vncBuffer *b, int x, int y, vncPixel c)
 
void vncSetRect (rfbScreenInfoPtr s, int x, int y, int w, int h, vncPixel c)
 
vncBuffervncGetRect (rfbScreenInfoPtr s, int x, int y, int w, int h)
 
rfbColourMap * vncNewColourMap (rfbScreenInfoPtr s, int n)
 
void vncSetColourMapEntry (rfbColourMap *m, int i, vncPixel r, vncPixel g, vncPixel b)
 
void vncDeleteColourMap (rfbColourMap *m)
 
void vncSetColourMap (rfbScreenInfoPtr s, rfbColourMap *m)
 
void ui_begin_update ()
 
void ui_end_update ()
 
void ui_resize_window ()
 

Variables

int rfbClientSocket = 0
 
int g_width
 
int g_height
 
int keylayout
 
BOOL sendmotion
 
int rfb_port = 5923
 
int defer_time = 5
 
static rfbScreenInfoPtr server = NULL
 
static vncBufferframeBuffer = NULL
 
static uint8_t reverseByte [0x100]
 
BOOL g_enable_compose = False
 
int g_display = 0
 
BOOL owncolmap = False
 
BOOL enable_compose = False
 
int mouseLookup [3]
 
int clipX
 
int clipY
 
int clipW
 
int clipH
 
static int lastbuttons = 0
 
static BOOL keystate [LAST_MODIFIER-FIRST_MODIFIER]
 
char g_title []
 
rfbPixelFormat vnc_formats []
 

Macro Definition Documentation

#define BITSPERBYTES   8

Definition at line 59 of file vnc.c.

#define DO_GLYPH (   ttext,
  idx 
)
Value:
{\
glyph = cache_get_font (font, ttext[idx]);\
{\
offset = ttext[++idx];\
if ((offset & 0x80))\
offset = ((offset & 0x7f) << 8) | ttext[++idx];\
x += offset;\
}\
if (glyph != NULL)\
{\
ui_draw_glyph (mixmode, x + (short) glyph->offset,\
y + (short) glyph->baseline,\
glyph->width, glyph->height,\
glyph->pixmap, 0, 0, bgcolour, fgcolour);\
x += glyph->width;\
}\
}
#define TEXT2_IMPLICIT_X
Definition: constants.h:276
GLintptr offset
Definition: glext.h:5920
FONTGLYPH * cache_get_font(uint8 font, uint16 character)
Definition: cache.c:279
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:717
GLbitfield flags
Definition: glext.h:7161
void ui_draw_glyph(int mixmode, int x, int y, int cx, int cy, HGLYPH glyph, int srcx, int srcy, int bgcolour, int fgcolour)
Definition: vnc.c:782
#define TEXT2_VERTICAL
Definition: constants.h:275
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62

Definition at line 837 of file vnc.c.

Referenced by ui_draw_text().

#define FIRST_MODIFIER   XK_Shift_L

Definition at line 130 of file vnc.c.

Referenced by get_key_state(), init_keyboard(), and vncKey().

#define GETPIXEL (   buf,
  x,
  y 
)    (((uint8_t*)(buf->data))[(x)+((y)*buf->linew)])
#define LAST_MODIFIER   XK_Hyper_R

Definition at line 131 of file vnc.c.

Referenced by get_key_state(), init_keyboard(), and vncKey().

#define SETPIXEL (   buf,
  x,
  y,
  p 
)    (((uint8_t*)(buf->data))[(x)+((y)*buf->linew)] = (uint8_t)p)
#define TOBYTES (   bits)    ((bits)/BITSPERBYTES)

Definition at line 60 of file vnc.c.

Referenced by ui_desktop_restore(), and ui_desktop_save().

Function Documentation

BOOL get_key_state ( unsigned int  state,
uint32  keysym 
)

Definition at line 146 of file vnc.c.

Referenced by handle_special_keys(), reset_modifier_keys(), and ui_get_numlock_state().

147 {
148  if (keysym >= FIRST_MODIFIER && keysym <= LAST_MODIFIER)
149  return keystate[keysym - FIRST_MODIFIER];
150  return 0;
151 }
#define LAST_MODIFIER
Definition: vnc.c:131
#define FIRST_MODIFIER
Definition: vnc.c:130
static BOOL keystate[LAST_MODIFIER-FIRST_MODIFIER]
Definition: vnc.c:133
void init_keyboard ( )

Definition at line 136 of file vnc.c.

Referenced by ui_create_window().

137 {
138  int i;
139  for (i = 0; i < LAST_MODIFIER - FIRST_MODIFIER; i++)
140  keystate[i] = 0;
141 
142  xkeymap_init();
143 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define LAST_MODIFIER
Definition: vnc.c:131
void xkeymap_init(void)
#define FIRST_MODIFIER
Definition: vnc.c:130
static BOOL keystate[LAST_MODIFIER-FIRST_MODIFIER]
Definition: vnc.c:133
int ListenOnTCPPort ( int  port)
void rdp2vnc_connect ( char server,
uint32  flags,
char domain,
char password,
char shell,
char directory 
)

Definition at line 226 of file vnc.c.

Referenced by main().

228 {
229  struct sockaddr addr;
230  fd_set fdset;
231  struct timeval tv;
232  int rfbListenSock, addrlen = sizeof(addr);
233 
234  rfbListenSock = rfbListenOnTCPPort(rfb_port);
235  fprintf(stderr, "Listening on VNC port %d\n", rfb_port);
236  if (rfbListenSock <= 0)
237  error("Cannot listen on port %d", rfb_port);
238  else
239  while (1)
240  {
241  FD_ZERO(&fdset);
242  FD_SET(rfbListenSock, &fdset);
243  tv.tv_sec = 5;
244  tv.tv_usec = 0;
245  if (select(rfbListenSock + 1, &fdset, NULL, NULL, &tv) > 0)
246  {
247  rfbClientSocket = accept(rfbListenSock, &addr, &addrlen);
248  if (rfbClientSocket < 0)
249  {
250  error("Error accepting client (%d: %s.\n",
251  errno, strerror(errno));
252  continue;
253  }
255  if (!rdp_connect(server, flags, domain, password, shell, directory))
256  {
257  error("Error connecting to RDP server.\n");
258  continue;
259  }
260  if (!fork())
261  {
264  printf("Connection successful.\n");
265  rdp_main_loop(&deactivated, &ext_disc_reason);
266  printf("Disconnecting...\n");
267  rdp_disconnect();
269  exit(0);
270  }
271  }
272  }
273 }
Definition: winsock.h:66
static rfbScreenInfoPtr server
Definition: vnc.c:74
int deactivated
Definition: svgawin.c:63
#define error(str)
Definition: mkdosfs.c:1605
uint32 ext_disc_reason
Definition: svgawin.c:64
void rdp_main_loop(RD_BOOL *deactivated, uint32 *ext_disc_reason)
Definition: rdp.c:1682
int errno
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
const char * strerror(int err)
Definition: compat_str.c:23
RD_BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, char *command, char *directory, RD_BOOL reconnect)
Definition: rdp.c:1742
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
unsigned int BOOL
Definition: ntddk_ex.h:94
void rdp_disconnect(void)
Definition: rdp.c:1779
int rfbClientSocket
Definition: vnc.c:73
GLbitfield flags
Definition: glext.h:7161
GLenum const GLvoid * addr
Definition: glext.h:9621
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
UINT32 uint32_t
Definition: types.h:75
int rfb_port
Definition: vnc.c:71
FILE * stderr
void ui_destroy_window()
Definition: vnc.c:335
void exit(int exitcode)
Definition: _exit.c:33
BOOL ui_create_window()
Definition: vnc.c:281
#define printf
Definition: config.h:203
void ui_begin_update ( void  )

Definition at line 1349 of file vnc.c.

Referenced by process_update_pdu(), and rdp5_process().

1350 {
1351 }
void ui_bell ( void  )

Definition at line 571 of file vnc.c.

Referenced by process_data_pdu().

572 {
573  rfbSendBell(server);
574 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
HBITMAP ui_create_bitmap ( int  width,
int  height,
uint8 data 
)

Definition at line 377 of file vnc.c.

Referenced by process_bmpcache(), process_bmpcache2(), process_raw_bmpcache(), pstcache_load_bitmap(), and ui_paint_bitmap().

378 {
379  vncBuffer *buf;
380 
381  buf = vncNewBuffer(width, height, 8);
382  memcpy(buf->data, data, width * height);
383 
384  return (HBITMAP) buf;
385 }
#define HBITMAP
Definition: msvc.h:28
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: vnc.h:10
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
vncBuffer * vncNewBuffer(int w, int h, int depth)
Definition: vnc.c:990
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char * data
Definition: vnc.h:15
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
HCOLOURMAP ui_create_colourmap ( COLOURMAP colours)

Definition at line 528 of file vnc.c.

Referenced by process_colcache(), and process_palette().

529 {
530  int i;
531  rfbColourMap *map = vncNewColourMap(server, colours->ncolours);
532  for (i = 0; i < colours->ncolours; i++)
533  {
534  vncSetColourMapEntry(map, i, colours->colours[i].red,
535  colours->colours[i].green, colours->colours[i].blue);
536  }
537  return map;
538 }
uint16 ncolours
Definition: types.h:66
static rfbScreenInfoPtr server
Definition: vnc.c:74
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint GLenum GLfloat GLenum GLint GLenum GLsizei GLenum GLboolean GLenum GLdouble GLenum GLfloat GLenum GLenum GLfloat GLenum GLenum GLdouble GLenum GLenum GLint GLenum GLenum GLint GLenum map
Definition: glfuncs.h:124
rfbColourMap * vncNewColourMap(rfbScreenInfoPtr s, int n)
Definition: vnc.c:1312
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void vncSetColourMapEntry(rfbColourMap *m, int i, vncPixel r, vncPixel g, vncPixel b)
Definition: vnc.c:1322
uint8 blue
Definition: types.h:59
COLOURENTRY * colours
Definition: types.h:67
Definition: _map.h:44
uint8 green
Definition: types.h:58
uint8 red
Definition: types.h:57
HCURSOR ui_create_cursor ( unsigned int  x,
unsigned int  y,
int  width,
int  height,
uint8 mask,
uint8 data 
)

Definition at line 421 of file vnc.c.

422 {
423  int i, j;
424  uint8_t *d0, *d1;
425  uint8_t *cdata;
426  uint8_t white[3] = { 0xff, 0xff, 0xff };
427  uint8_t black[3] = { 0, 0, 0 };
428  uint8_t *cur;
429  rfbCursorPtr cursor;
430  rfbColourMap *colourMap = &server->colourMap;
431 
432  cdata = xmalloc(sizeof(uint8_t) * width * height);
433  d0 = xmalloc(sizeof(uint32_t) * width * height / 4);
434  d1 = (uint8_t *) mask;
435  for (j = 0; j < height; j++)
436  for (i = 0; i < width / 8; i++)
437  {
438  d0[j * width / 8 + i] = d1[(height - 1 - j) * width / 8 + i] ^ 0xffffffff;
439  }
440  for (j = 0; j < height; j++)
441  {
442  for (i = 0; i < width; i++)
443  {
444  //strange that the pointer is in 24bit depth when everything
445  //else is in 8bit palletized.
446  cur = data + ((height - 1 - j) * width + i) * 3;
447  if (cur[0] > 0x80 || cur[1] > 0x80 || cur[2] > 0x80)
448  {
449  if (!(d0[(j * width + i) / 8] & (0x80 >> (i & 7))))
450  {
451  /* text cursor! */
452  cdata[j * width + i] = vncLookupColour(colourMap, black);
453  d0[(j * width + i) / 8] |= 0x80 >> (i & 7);
454  }
455  else
456  cdata[j * width + i] = vncLookupColour(colourMap, white);
457  }
458  else
459  cdata[j * width + i] = vncLookupColour(colourMap, cur);
460  }
461  }
462  cursor = (rfbCursorPtr) xmalloc(sizeof(rfbCursor));
463  cursor->width = width;
464  cursor->height = height;
465  cursor->xhot = x;
466  cursor->yhot = y;
467  cursor->mask = (char *) d0;
468  cursor->source = 0;
469  cursor->richSource = cdata;
470  cursor->cleanup = 0; // workaround: this produces a memleak
471 
472  cursor->backRed = cursor->backGreen = cursor->backBlue = 0xffff;
473  cursor->foreRed = cursor->foreGreen = cursor->foreBlue = 0;
474 
475  return (HCURSOR) cursor;
476 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
static rfbScreenInfoPtr server
Definition: vnc.c:74
HICON HCURSOR
Definition: windef.h:289
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLenum GLint GLuint mask
Definition: glext.h:6028
void * xmalloc(int size)
Definition: uimain.c:747
GLint GLint GLsizei width
Definition: gl.h:1546
uint8_t vncLookupColour(rfbColourMap *colourMap, uint8_t *p)
Definition: vnc.c:403
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BYTE uint8_t
Definition: msvideo1.c:66
const char cursor[]
Definition: icontest.c:13
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
UINT32 uint32_t
Definition: types.h:75
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
HGLYPH ui_create_glyph ( int  width,
int  height,
uint8 data 
)

Definition at line 499 of file vnc.c.

Referenced by process_fontcache(), and ui_patblt().

500 {
501  int x, y;
502  vncBuffer *buf;
503 
504  buf = vncNewBuffer(width, height, 8);
505 
506  //data is padded to multiple of 16bit line lengths
507  for (y = 0; y < height; y++)
508  {
509  for (x = 0; x < width; x++)
510  {
511  int byte = x / 8 + (y * ((width + 7) / 8));
512  byte = rfbEndianTest ? reverseByte[data[byte]] : data[byte];
513  byte = (byte >> (x & 7)) & 0x01;
514  vncSetPixel(buf, x, y, byte ? 0x7f : 0x00);
515  }
516  }
517 
518  return (HGLYPH) buf;
519 }
unsigned char byte
Definition: rpcndr.h:116
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
Definition: vnc.h:10
void vncSetPixel(vncBuffer *b, int x, int y, vncPixel c)
Definition: vnc.c:1225
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
vncBuffer * vncNewBuffer(int w, int h, int depth)
Definition: vnc.c:990
#define byte(x, n)
Definition: tomcrypt.h:118
static uint8_t reverseByte[0x100]
Definition: vnc.c:76
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
BOOL ui_create_window ( void  )

Definition at line 281 of file vnc.c.

Referenced by main(), and rdp2vnc_connect().

282 {
283  int i;
284 
285  for (i = 0; i < 0x100; i++)
286  reverseByte[i] =
287  (((i >> 7) & 1)) | (((i >> 6) & 1) << 1) | (((i >> 5) & 1) << 2) |
288  (((i >> 4) & 1) << 3) | (((i >> 3) & 1) << 4) | (((i >> 2) & 1) << 5) |
289  (((i >> 1) & 1) << 6) | (((i >> 0) & 1) << 7);
290 
291  server = rfbGetScreen(0, NULL, g_width, g_height, 8, 1, 1);
292  server->desktopName = g_title;
293  server->frameBuffer = (char *) malloc(g_width * g_height);
294  server->ptrAddEvent = vncMouse;
295  server->kbdAddEvent = vncKey;
296 #ifdef ENABLE_SHADOW
297  server->httpPort = 6124 + client_counter;
298  server->port = 5924 + client_counter;
299  rfbInitSockets(server);
300  server->alwaysShared = TRUE;
301  server->neverShared = FALSE;
302 #else
303  server->port = -1;
304  server->alwaysShared = FALSE;
305  server->neverShared = FALSE;
306 #endif
307  server->inetdSock = rfbClientSocket;
308  server->serverFormat.trueColour = FALSE; /* activate colour maps */
309  server->deferUpdateTime = defer_time;
310 
311  frameBuffer = (vncBuffer *) malloc(sizeof(vncBuffer));
312  frameBuffer->w = g_width;
315  frameBuffer->data = server->frameBuffer;
317  frameBuffer->format = &server->serverFormat;
318 
319  ui_set_clip(0, 0, g_width, g_height);
320 
321  rfbInitServer(server);
322 #ifndef ENABLE_SHADOW
323  server->port = rfb_port;
324 #else
325  fprintf(stderr, "server listening on port %d (socket %d)\n", server->port,
326  server->listenSock);
327 #endif
328 
329  init_keyboard();
330 
331  return (server != NULL);
332 }
char g_title[]
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
int defer_time
Definition: vnc.c:72
uint16_t h
Definition: vnc.h:12
void init_keyboard()
Definition: vnc.c:136
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void vncMouse(int buttonMask, int x, int y, struct _rfbClientRec *cl)
Definition: vnc.c:198
#define FALSE
Definition: types.h:117
Definition: vnc.h:10
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
smooth NULL
Definition: ftsmooth.c:416
uint16_t w
Definition: vnc.h:12
uint16_t linew
Definition: vnc.h:13
int rfbClientSocket
Definition: vnc.c:73
int g_height
Definition: uimain.c:43
char * data
Definition: vnc.h:15
static uint8_t reverseByte[0x100]
Definition: vnc.c:76
void ui_set_clip(int x, int y, int cx, int cy)
Definition: vnc.c:553
int rfb_port
Definition: vnc.c:71
FILE * stderr
#define malloc
Definition: debug_ros.c:4
static vncBuffer * frameBuffer
Definition: vnc.c:75
BOOL owner
Definition: vnc.h:16
void vncKey(rfbBool down, rfbKeySym keysym, struct _rfbClientRec *cl)
Definition: vnc.c:154
int g_width
Definition: uimain.c:42
rfbPixelFormat * format
Definition: vnc.h:14
void ui_desktop_restore ( uint32  offset,
int  x,
int  y,
int  cx,
int  cy 
)

Definition at line 945 of file vnc.c.

Referenced by process_desksave().

946 {
947  uint8 *data;
948  vncBuffer *buf;
949  int ox, oy, srcx, srcy;
950 
951  srcx = srcy = 0;
952  ox = x;
953  oy = y;
954 
955  offset *= TOBYTES(server->serverFormat.bitsPerPixel);
956  data = cache_get_desktop(offset, cx, cy, TOBYTES(server->serverFormat.bitsPerPixel));
957  if (data == NULL)
958  return;
959 
960  buf = vncNewBuffer(cx, cy, 8);
961  memcpy(buf->data, data, cx * cy * 1);
962 
963  if (vncwinClipRect(&x, &y, &cx, &cy))
964  {
965  srcx += x - ox;
966  srcy += y - oy;
967  vncCopyBlitFrom(server, x, y, cx, cy, buf, srcx, srcy);
968  }
969  vncDeleteBuffer(buf);
970 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLintptr offset
Definition: glext.h:5920
void vncCopyBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
Definition: vnc.c:1075
Definition: vnc.h:10
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
uint8 * cache_get_desktop(uint32 offset, int cx, int cy, int bytes_per_pixel)
Definition: cache.c:353
smooth NULL
Definition: ftsmooth.c:416
#define TOBYTES(bits)
Definition: vnc.c:60
unsigned char uint8
Definition: types.h:28
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
vncBuffer * vncNewBuffer(int w, int h, int depth)
Definition: vnc.c:990
BOOL vncwinClipRect(int *x, int *y, int *cx, int *cy)
Definition: vnc.c:102
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char * data
Definition: vnc.h:15
void vncDeleteBuffer(vncBuffer *b)
Definition: vnc.c:1170
_Out_opt_ int * cx
Definition: commctrl.h:570
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_desktop_save ( uint32  offset,
int  x,
int  y,
int  cx,
int  cy 
)

Definition at line 934 of file vnc.c.

Referenced by process_desksave().

935 {
936  vncBuffer *buf;
937 
938  buf = vncGetRect(server, x, y, cx, cy);
939  offset *= TOBYTES(server->serverFormat.bitsPerPixel);
940  cache_put_desktop(offset, cx, cy, cx, TOBYTES(server->serverFormat.bitsPerPixel),
941  (buf->data));
942 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLintptr offset
Definition: glext.h:5920
vncBuffer * vncGetRect(rfbScreenInfoPtr s, int x, int y, int w, int h)
Definition: vnc.c:1272
Definition: vnc.h:10
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
void cache_put_desktop(uint32 offset, int cx, int cy, int scanline, int bytes_per_pixel, uint8 *data)
Definition: cache.c:371
#define TOBYTES(bits)
Definition: vnc.c:60
char * data
Definition: vnc.h:15
_Out_opt_ int * cx
Definition: commctrl.h:570
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_destblt ( uint8  opcode,
int  x,
int  y,
int  cx,
int  cy 
)

Definition at line 577 of file vnc.c.

Referenced by process_destblt().

579 {
580  int i;
581  vncBuffer *buf;
582 
583  switch (opcode)
584  {
585  case 0:
586  case 15:
587  ui_rect(x, y, cx, cy, 0xff);
588  break;
589  case 5: // invert
590  buf = vncGetRect(server, x, y, cx, cy);
591  for (i = 0; i < cx * cy; i++)
592  ((char *) (buf->data))[i] = !((char *) (buf->data))[i];
593  break;
594  default:
595  unimpl("ui_destblt: opcode=%d %d,%d %dx%d\n", opcode, x, y, cx, cy);
596  }
597 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint GLenum GLfloat GLenum GLint GLenum GLsizei GLenum GLboolean GLenum GLdouble GLenum GLfloat GLenum GLenum GLfloat GLenum GLenum GLdouble GLenum GLenum GLint GLenum GLenum GLint GLenum GLuint GLenum GLvoid const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLint GLenum GLint GLenum GLenum GLint GLuint GLdouble GLfloat GLint GLshort GLubyte GLenum GLuint GLenum const GLfloat GLenum const GLint GLenum GLenum const GLfloat GLenum GLenum const GLint GLfloat const GLfloat GLenum opcode
Definition: glfuncs.h:172
GLenum GLclampf GLint i
Definition: glfuncs.h:14
vncBuffer * vncGetRect(rfbScreenInfoPtr s, int x, int y, int w, int h)
Definition: vnc.c:1272
Definition: vnc.h:10
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
void ui_rect(int x, int y, int cx, int cy, int colour)
Definition: vnc.c:771
char * data
Definition: vnc.h:15
_Out_opt_ int * cx
Definition: commctrl.h:570
void unimpl(char *format,...)
Definition: uimain.c:801
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_destroy_bitmap ( HBITMAP  bmp)

Definition at line 397 of file vnc.c.

Referenced by ui_destroy_glyph().

398 {
400 }
Definition: vnc.h:10
BITMAP bmp
Definition: alphablend.c:62
void vncDeleteBuffer(vncBuffer *b)
Definition: vnc.c:1170
void ui_destroy_colourmap ( HCOLOURMAP  map)

Definition at line 541 of file vnc.c.

542 {
543  vncDeleteColourMap(map);
544 }
void vncDeleteColourMap(rfbColourMap *m)
Definition: vnc.c:1333
void ui_destroy_cursor ( HCURSOR  cursor)

Definition at line 486 of file vnc.c.

487 {
488  if (cursor)
489  rfbFreeCursor((rfbCursorPtr) cursor);
490 }
const char cursor[]
Definition: icontest.c:13
void ui_destroy_glyph ( HGLYPH  glyph)

Definition at line 522 of file vnc.c.

Referenced by cache_put_font(), and ui_patblt().

523 {
524  ui_destroy_bitmap((HBITMAP) glyph);
525 }
#define HBITMAP
Definition: msvc.h:28
void ui_destroy_bitmap(HBITMAP bmp)
Definition: vnc.c:397
void ui_destroy_window ( void  )

Definition at line 335 of file vnc.c.

Referenced by main(), and rdp2vnc_connect().

336 {
337  rfbCloseClient(server->clientHead);
338 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
void ui_draw_glyph ( int  mixmode,
int  x,
int  y,
int  cx,
int  cy,
HGLYPH  glyph,
int  srcx,
int  srcy,
int  bgcolour,
int  fgcolour 
)

Definition at line 782 of file vnc.c.

786 {
787  int xx, yy;
788  int ox, oy;
789  vncBuffer *buf = vncDupBuffer(glyph);
790 
791  x &= 0xffff;
792  y &= 0xffff;
793 
794  /* yes, sometimes same fgcolour and bgcolour are sent, but because
795  * of transparency, we have to change that! */
796  if (mixmode == MIX_TRANSPARENT && fgcolour == bgcolour)
797  bgcolour = fgcolour ^ 0xff;
798 
799  ox = x;
800  oy = y;
801 
802  for (yy = srcy; yy < srcy + cy; yy++)
803  {
804  for (xx = srcx; xx < srcx + cx; xx++)
805  {
806  vncSetPixel(buf, xx, yy, vncGetPixel(buf, xx, yy) ? fgcolour : bgcolour);
807  }
808  }
809 
810  switch (mixmode)
811  {
812  case MIX_TRANSPARENT:
813  if (vncwinClipRect(&x, &y, &cx, &cy))
814  {
815  //if we clipped top or left, we have to adjust srcx,srcy;
816  srcx += x - ox;
817  srcy += y - oy;
818  vncTransBlitFrom(server, x, y, cx, cy, buf, srcx, srcy, bgcolour);
819  }
820  break;
821  case MIX_OPAQUE:
822  if (vncwinClipRect(&x, &y, &cx, &cy))
823  {
824  //if we clipped top or left, we have to adjust srcx,srcy;
825  srcx += x - ox;
826  srcy += y - oy;
827  vncCopyBlitFrom(server, x, y, cx, cy, buf, srcx, srcy);
828  }
829  break;
830 
831  default:
832  unimpl("mix %d\n", mixmode);
833  }
834  vncDeleteBuffer(buf);
835 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
vncBuffer * vncDupBuffer(vncBuffer *b)
Definition: vnc.c:1003
#define MIX_OPAQUE
Definition: constants.h:273
void vncCopyBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
Definition: vnc.c:1075
Definition: vnc.h:10
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
#define MIX_TRANSPARENT
Definition: constants.h:272
void vncSetPixel(vncBuffer *b, int x, int y, vncPixel c)
Definition: vnc.c:1225
int xx
Definition: npserver.c:29
BOOL vncwinClipRect(int *x, int *y, int *cx, int *cy)
Definition: vnc.c:102
vncPixel vncGetPixel(vncBuffer *b, int x, int y)
Definition: vnc.c:1218
void vncTransBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy, int bg)
Definition: vnc.c:1082
void vncDeleteBuffer(vncBuffer *b)
Definition: vnc.c:1170
_Out_opt_ int * cx
Definition: commctrl.h:570
void unimpl(char *format,...)
Definition: uimain.c:801
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_draw_text ( uint8  font,
uint8  flags,
int  mixmode,
int  x,
int  y,
int  clipx,
int  clipy,
int  clipcx,
int  clipcy,
int  boxx,
int  boxy,
int  boxcx,
int  boxcy,
int  bgcolour,
int  fgcolour,
uint8 text,
uint8  length 
)

Definition at line 863 of file vnc.c.

867 {
868  FONTGLYPH *glyph;
869  int i, j, offset;
870  DATABLOB *entry;
871 
872  if (boxcx > 1)
873  {
874  ui_rect(boxx, boxy, boxcx, boxcy, bgcolour);
875  }
876  else if (mixmode == MIX_OPAQUE)
877  {
878  ui_rect(clipx, clipy, clipcx, clipcy, bgcolour);
879  }
880 
881  /* Paint text, character by character */
882  for (i = 0; i < length;)
883  {
884  switch (text[i])
885  {
886  case 0xff:
887  if (i + 2 < length)
888  cache_put_text(text[i + 1], &(text[i - text[i + 2]]),
889  text[i + 2]);
890  else
891  {
892  error("this shouldn't be happening\n");
893  break;
894  }
895  /* this will move pointer from start to first character after FF command */
896  length -= i + 3;
897  text = &(text[i + 3]);
898  i = 0;
899  break;
900 
901  case 0xfe:
902  entry = cache_get_text(text[i + 1]);
903  if (entry != NULL)
904  {
905  if ((((uint8 *) (entry->data))[1] == 0)
906  && (!(flags & TEXT2_IMPLICIT_X)))
907  {
908  if (flags & 0x04) /* vertical text */
909  y += text[i + 2];
910  else
911  x += text[i + 2];
912  }
913  if (i + 2 < length)
914  i += 3;
915  else
916  i += 2;
917  length -= i;
918  /* this will move pointer from start to first character after FE command */
919  text = &(text[i]);
920  i = 0;
921  for (j = 0; j < entry->size; j++)
922  DO_GLYPH(((uint8 *) (entry->data)), j);
923  }
924  break;
925  default:
926  DO_GLYPH(text, i);
927  i++;
928  break;
929  }
930  }
931 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define error(str)
Definition: mkdosfs.c:1605
int size
Definition: types.h:124
#define TEXT2_IMPLICIT_X
Definition: constants.h:276
const WCHAR * text
Definition: package.c:1827
uint8_t entry
Definition: isohybrid.c:63
GLintptr offset
Definition: glext.h:5920
#define MIX_OPAQUE
Definition: constants.h:273
#define DO_GLYPH(ttext, idx)
Definition: vnc.c:837
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void cache_put_text(uint8 cache_id, void *data, int length)
Definition: cache.c:335
smooth NULL
Definition: ftsmooth.c:416
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned char uint8
Definition: types.h:28
GLbitfield flags
Definition: glext.h:7161
void * data
Definition: types.h:123
void ui_rect(int x, int y, int cx, int cy, int colour)
Definition: vnc.c:771
DATABLOB * cache_get_text(uint8 cache_id)
Definition: cache.c:325
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_end_update ( void  )

Definition at line 1354 of file vnc.c.

Referenced by process_update_pdu(), and rdp5_process().

1355 {
1356 }
void ui_line ( uint8  opcode,
int  startx,
int  starty,
int  endx,
int  endy,
PEN pen 
)

Definition at line 760 of file vnc.c.

Referenced by process_line().

763 {
764  //vncSetRect(server,startx,starty,1+endx-startx,endy-starty,pen->colour);
765  //unimpl("drawline: pen colour=%d\n",pen->colour);
766  /* TODO: implement opcodes */
767  rfbDrawLine(server, startx, starty, endx, endy, pen->colour);
768 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
uint32 colour
Definition: types.h:86
void ui_memblt ( uint8  opcode,
int  x,
int  y,
int  cx,
int  cy,
HBITMAP  src,
int  srcx,
int  srcy 
)

Definition at line 692 of file vnc.c.

Referenced by ui_triblt().

695 {
696  int ox, oy;
697  ox = x;
698  oy = y;
699 
700  if (vncwinClipRect(&x, &y, &cx, &cy))
701  {
702  //if we clipped top or left, we have to adjust srcx,srcy;
703  srcx += x - ox;
704  srcy += y - oy;
705  switch (ROP2_S(opcode))
706  {
707  case ROP2_OR:
708  vncTransBlitFrom(server, x, y, cx, cy, (vncBuffer *) src, srcx,
709  srcy, 0x0);
710  break;
711  case ROP2_XOR:
712  vncXorBlitFrom(server, x, y, cx, cy, (vncBuffer *) src, srcx, srcy);
713  break;
714  case ROP2_AND:
715  vncAndBlitFrom(server, x, y, cx, cy, (vncBuffer *) src, srcx, srcy);
716  break;
717  case ROP2_COPY:
718  vncCopyBlitFrom(server, x, y, cx, cy, (vncBuffer *) src, srcx,
719  srcy);
720  break;
721  default:
722  unimpl("ui_memblt: op%d %d,%d %dx%d\n", opcode, x, y, cx, cy);
723  vncCopyBlitFrom(server, x, y, cx, cy, (vncBuffer *) src, srcx,
724  srcy);
725  break;
726  }
727  }
728 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
void vncAndBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
Definition: vnc.c:1141
#define ROP2_S(rop3)
Definition: constants.h:263
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint GLenum GLfloat GLenum GLint GLenum GLsizei GLenum GLboolean GLenum GLdouble GLenum GLfloat GLenum GLenum GLfloat GLenum GLenum GLdouble GLenum GLenum GLint GLenum GLenum GLint GLenum GLuint GLenum GLvoid const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLint GLenum GLint GLenum GLenum GLint GLuint GLdouble GLfloat GLint GLshort GLubyte GLenum GLuint GLenum const GLfloat GLenum const GLint GLenum GLenum const GLfloat GLenum GLenum const GLint GLfloat const GLfloat GLenum opcode
Definition: glfuncs.h:172
void vncXorBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
Definition: vnc.c:1112
void vncCopyBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
Definition: vnc.c:1075
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
Definition: vnc.h:10
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
#define ROP2_OR
Definition: constants.h:270
#define ROP2_AND
Definition: constants.h:268
#define ROP2_XOR
Definition: constants.h:267
BOOL vncwinClipRect(int *x, int *y, int *cx, int *cy)
Definition: vnc.c:102
void vncTransBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy, int bg)
Definition: vnc.c:1082
#define ROP2_COPY
Definition: constants.h:266
_Out_opt_ int * cx
Definition: commctrl.h:570
void unimpl(char *format,...)
Definition: uimain.c:801
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_move_pointer ( int  x,
int  y 
)

Definition at line 368 of file vnc.c.

Referenced by process_pointer_pdu(), and rdp5_process().

369 {
370  // TODO: Is there a way to send x,y even if cursor encoding is active?
371  rfbUndrawCursor(server);
372  server->cursorX = x;
373  server->cursorY = y;
374 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_paint_bitmap ( int  x,
int  y,
int  cx,
int  cy,
int  width,
int  height,
uint8 data 
)

Definition at line 388 of file vnc.c.

Referenced by process_bitmap_updates().

389 {
390  vncBuffer *buf;
392  vncCopyBlitFrom(server, x, y, cx, cy, buf, 0, 0);
393  vncDeleteBuffer(buf);
394 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
void vncCopyBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
Definition: vnc.c:1075
Definition: vnc.h:10
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
GLint GLint GLsizei width
Definition: gl.h:1546
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HBITMAP ui_create_bitmap(int width, int height, uint8 *data)
Definition: vnc.c:377
void vncDeleteBuffer(vncBuffer *b)
Definition: vnc.c:1170
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
_Out_opt_ int * cx
Definition: commctrl.h:570
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_patblt ( uint8  opcode,
int  x,
int  y,
int  cx,
int  cy,
BRUSH brush,
int  bgcolour,
int  fgcolour 
)

Definition at line 600 of file vnc.c.

Referenced by process_patblt(), and ui_triblt().

603 {
604  switch (brush->style)
605  {
606  case 0: /* Solid */
607  switch (opcode)
608  {
609  case ROP2_XOR:
610  {
611  int xx, yy;
612  vncBuffer *fill = vncNewBuffer(cx, cy, 8);
613  for (yy = 0; yy < cy; yy++)
614  for (xx = 0; xx < cx; xx++)
615  vncSetPixel(fill, xx, yy, fgcolour);
616  if (vncwinClipRect(&x, &y, &cx, &cy))
617  vncXorBlitFrom(server, x, y, cx, cy, fill,
618  0, 0);
619  break;
620  }
621 
622  default:
623  if (vncwinClipRect(&x, &y, &cx, &cy))
624  vncSetRect(server, x, y, cx, cy, fgcolour);
625  }
626  break;
627 
628  case 3: /* Pattern */
629  {
630  int xx, yy;
631  vncBuffer *fill;
632  fill = (vncBuffer *) ui_create_glyph(8, 8, brush->pattern);
633 
634  for (yy = 0; yy < 8; yy++)
635  {
636  for (xx = 0; xx < 8; xx++)
637  {
638  vncSetPixel(fill, xx, yy,
639  vncGetPixel(fill, xx,
640  yy) ? fgcolour : bgcolour);
641  }
642  }
643 
644  if (vncwinClipRect(&x, &y, &cx, &cy))
645  {
646  switch (opcode)
647  {
648  case ROP2_COPY:
649  vncCopyBlitFrom(server, x, y, cx, cy, fill,
650  0, 0);
651  break;
652  case ROP2_XOR:
653  vncXorBlitFrom(server, x, y, cx, cy, fill,
654  0, 0);
655  break;
656  default:
657  unimpl("pattern blit (%d,%d) opcode=%d bg=%d fg=%d\n", x, y, opcode, bgcolour, fgcolour);
658  vncCopyBlitFrom(server, x, y, cx, cy, fill,
659  0, 0);
660  break;
661  }
662  }
663 
664  ui_destroy_glyph((HGLYPH) fill);
665  break;
666 
667  }
668  default:
669  unimpl("brush %d\n", brush->style);
670  }
671 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint GLenum GLfloat GLenum GLint GLenum GLsizei GLenum GLboolean GLenum GLdouble GLenum GLfloat GLenum GLenum GLfloat GLenum GLenum GLdouble GLenum GLenum GLint GLenum GLenum GLint GLenum GLuint GLenum GLvoid const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLint GLenum GLint GLenum GLenum GLint GLuint GLdouble GLfloat GLint GLshort GLubyte GLenum GLuint GLenum const GLfloat GLenum const GLint GLenum GLenum const GLfloat GLenum GLenum const GLint GLfloat const GLfloat GLenum opcode
Definition: glfuncs.h:172
void vncXorBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
Definition: vnc.c:1112
void vncCopyBlitFrom(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
Definition: vnc.c:1075
HGLYPH ui_create_glyph(int width, int height, uint8 *data)
Definition: vnc.c:499
Definition: vnc.h:10
void vncSetRect(rfbScreenInfoPtr s, int x, int y, int w, int h, vncPixel c)
Definition: vnc.c:1232
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
void vncSetPixel(vncBuffer *b, int x, int y, vncPixel c)
Definition: vnc.c:1225
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algobase.h:449
#define ROP2_XOR
Definition: constants.h:267
int xx
Definition: npserver.c:29
vncBuffer * vncNewBuffer(int w, int h, int depth)
Definition: vnc.c:990
BOOL vncwinClipRect(int *x, int *y, int *cx, int *cy)
Definition: vnc.c:102
vncPixel vncGetPixel(vncBuffer *b, int x, int y)
Definition: vnc.c:1218
#define ROP2_COPY
Definition: constants.h:266
void ui_destroy_glyph(HGLYPH glyph)
Definition: vnc.c:522
_Out_opt_ int * cx
Definition: commctrl.h:570
void unimpl(char *format,...)
Definition: uimain.c:801
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_rect ( int  x,
int  y,
int  cx,
int  cy,
int  colour 
)

Definition at line 771 of file vnc.c.

Referenced by process_rect(), ui_destblt(), and ui_draw_text().

774 {
775  if (vncwinClipRect(&x, &y, &cx, &cy))
776  {
777  vncSetRect(server, x, y, cx, cy, colour);
778  }
779 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
void vncSetRect(rfbScreenInfoPtr s, int x, int y, int w, int h, vncPixel c)
Definition: vnc.c:1232
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
BOOL vncwinClipRect(int *x, int *y, int *cx, int *cy)
Definition: vnc.c:102
_Out_opt_ int * cx
Definition: commctrl.h:570
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_reset_clip ( void  )

Definition at line 562 of file vnc.c.

Referenced by process_orders().

563 {
564  clipX = 0;
565  clipY = 0;
566  clipW = 64000;
567  clipH = 64000;
568 }
int clipH
Definition: vnc.c:99
int clipY
Definition: vnc.c:99
int clipX
Definition: vnc.c:99
int clipW
Definition: vnc.c:99
void ui_resize_window ( void  )

Definition at line 1359 of file vnc.c.

Referenced by rdp_process_bitmap_caps().

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 }
#define realloc
Definition: debug_ros.c:6
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
int g_height
Definition: uimain.c:43
int g_width
Definition: uimain.c:42
void ui_screenblt ( uint8  opcode,
int  x,
int  y,
int  cx,
int  cy,
int  srcx,
int  srcy 
)

Definition at line 674 of file vnc.c.

Referenced by process_screenblt().

677 {
678  int ox, oy;
679 
680  ox = x;
681  oy = y;
682  if (vncwinClipRect(&x, &y, &cx, &cy))
683  {
684  //if we clipped top or left, we have to adjust srcx,srcy;
685  srcx += x - ox;
686  srcy += y - oy;
687  vncCopyBlit(server, x, y, cx, cy, srcx, srcy);
688  }
689 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
BOOL vncwinClipRect(int *x, int *y, int *cx, int *cy)
Definition: vnc.c:102
void vncCopyBlit(rfbScreenInfoPtr s, int x, int y, int w, int h, int srcx, int srcy)
Definition: vnc.c:1068
_Out_opt_ int * cx
Definition: commctrl.h:570
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
int ui_select ( int  rdpSocket)

Definition at line 342 of file vnc.c.

Referenced by tcp_recv().

343 {
344  fd_set fds;
345  struct timeval tv;
346  int n, m = server->maxFd;
347 
348  if (rdpSocket > m)
349  m = rdpSocket;
350  while (1)
351  {
352  fds = server->allFds;
353  FD_SET(rdpSocket, &fds);
354  tv.tv_sec = defer_time / 1000;
355  tv.tv_usec = (defer_time % 1000) * 1000;
356  n = select(m + 1, &fds, NULL, NULL, &tv);
357  rfbProcessEvents(server, 0);
358  /* if client is gone, close connection */
359  if (!server->clientHead)
360  close(rdpSocket);
361  if (FD_ISSET(rdpSocket, &fds))
362  return 1;
363  }
364  return 0;
365 }
Definition: winsock.h:66
static rfbScreenInfoPtr server
Definition: vnc.c:74
int defer_time
Definition: vnc.c:72
#define FD_SET(fd, set)
Definition: winsock.h:89
GLuint n
Definition: s_context.h:57
#define FD_ISSET(fd, set)
Definition: winsock.h:100
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
smooth NULL
Definition: ftsmooth.c:416
#define close
Definition: acwin.h:74
const GLfloat * m
Definition: glext.h:10848
void ui_set_clip ( int  x,
int  y,
int  cx,
int  cy 
)

Definition at line 553 of file vnc.c.

Referenced by process_orders(), and ui_create_window().

554 {
555  clipX = x;
556  clipY = y;
557  clipW = cx;
558  clipH = cy;
559 }
int clipH
Definition: vnc.c:99
int clipY
Definition: vnc.c:99
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
int clipX
Definition: vnc.c:99
int clipW
Definition: vnc.c:99
_Out_opt_ int * cx
Definition: commctrl.h:570
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void ui_set_colourmap ( HCOLOURMAP  map)

Definition at line 547 of file vnc.c.

Referenced by process_colcache(), and process_palette().

548 {
549  vncSetColourMap(server, map);
550 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
void vncSetColourMap(rfbScreenInfoPtr s, rfbColourMap *m)
Definition: vnc.c:1341
void ui_set_cursor ( HCURSOR  cursor)

Definition at line 479 of file vnc.c.

480 {
481  /* FALSE means: don't delete old cursor */
482  rfbSetCursor(server, (rfbCursorPtr) cursor, FALSE);
483 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define FALSE
Definition: types.h:117
const char cursor[]
Definition: icontest.c:13
void ui_set_null_cursor ( void  )

Definition at line 493 of file vnc.c.

Referenced by process_system_pointer_pdu(), and rdp5_process().

494 {
495  rfbSetCursor(server, 0, FALSE);
496 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define FALSE
Definition: types.h:117
void ui_triblt ( uint8  opcode,
int  x,
int  y,
int  cx,
int  cy,
HBITMAP  src,
int  srcx,
int  srcy,
BRUSH brush,
int  bgcolour,
int  fgcolour 
)

Definition at line 731 of file vnc.c.

735 {
736  /* This is potentially difficult to do in general. Until someone
737  comes up with a more efficient way of doing it I am using cases. */
738 
739  switch (opcode)
740  {
741  case 0x69: /* PDSxxn */
742  ui_memblt(ROP2_XOR, x, y, cx, cy, src, srcx, srcy);
743  ui_patblt(ROP2_NXOR, x, y, cx, cy, brush, bgcolour, fgcolour);
744  break;
745 
746  case 0xb8: /* PSDPxax */
747  ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour);
748  ui_memblt(ROP2_AND, x, y, cx, cy, src, srcx, srcy);
749  ui_patblt(ROP2_XOR, x, y, cx, cy, brush, bgcolour, fgcolour);
750  break;
751 
752  default:
753  unimpl("ui_triblt 1x%x\n", opcode);
754  ui_memblt(ROP2_COPY, x, y, cx, cy, src, srcx, srcy);
755  }
756 
757 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint GLenum GLfloat GLenum GLint GLenum GLsizei GLenum GLboolean GLenum GLdouble GLenum GLfloat GLenum GLenum GLfloat GLenum GLenum GLdouble GLenum GLenum GLint GLenum GLenum GLint GLenum GLuint GLenum GLvoid const GLubyte GLenum GLenum GLenum GLint GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLvoid GLenum GLint GLenum GLint GLenum GLenum GLint GLuint GLdouble GLfloat GLint GLshort GLubyte GLenum GLuint GLenum const GLfloat GLenum const GLint GLenum GLenum const GLfloat GLenum GLenum const GLint GLfloat const GLfloat GLenum opcode
Definition: glfuncs.h:172
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, HBITMAP src, int srcx, int srcy)
Definition: vnc.c:692
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
#define ROP2_AND
Definition: constants.h:268
#define ROP2_XOR
Definition: constants.h:267
void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, BRUSH *brush, int bgcolour, int fgcolour)
Definition: vnc.c:600
#define ROP2_COPY
Definition: constants.h:266
#define ROP2_NXOR
Definition: constants.h:269
_Out_opt_ int * cx
Definition: commctrl.h:570
void unimpl(char *format,...)
Definition: uimain.c:801
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void vncAndBlitFrom ( rfbScreenInfoPtr  s,
int  x,
int  y,
int  w,
int  h,
vncBuffer src,
int  srcx,
int  srcy 
)

Definition at line 1141 of file vnc.c.

Referenced by ui_memblt().

1142 {
1143  int xx, yy;
1144 
1145  vncHideCursor();
1146 
1147  // xsrc,ysrc provide tiling copy support.
1148  for (yy = y; yy < y + h; yy++)
1149  {
1150  int ysrc = srcy + yy - y;
1151  while (ysrc >= src->h)
1152  ysrc -= src->h;
1153  for (xx = x; xx < x + w; xx++)
1154  {
1155  vncPixel p, pp;
1156  int xsrc = srcx + xx - x;
1157  while (xsrc >= src->linew)
1158  xsrc -= src->linew;
1159  p = GETPIXEL(src, xsrc, ysrc);
1160  pp = GETPIXEL(frameBuffer, xx, yy);
1161  // and blit!
1162  SETPIXEL(frameBuffer, xx, yy, p & pp);
1163  }
1164  }
1165 
1166  rfbMarkRectAsModified(s, x, y, x + w, y + h);
1167 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
uint16_t h
Definition: vnc.h:12
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define pp
Definition: hlsl.yy.c:978
#define GETPIXEL(buf, x, y)
Definition: vnc.c:1019
uint16_t linew
Definition: vnc.h:13
int xx
Definition: npserver.c:29
void vncHideCursor()
Definition: vnc.c:85
GLdouble s
Definition: gl.h:2039
unsigned int vncPixel
Definition: vnc.h:8
static vncBuffer * frameBuffer
Definition: vnc.c:75
#define SETPIXEL(buf, x, y, p)
Definition: vnc.c:1021
GLfloat GLfloat p
Definition: glext.h:8902
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void vncCopyBlit ( rfbScreenInfoPtr  s,
int  x,
int  y,
int  w,
int  h,
int  srcx,
int  srcy 
)

Definition at line 1068 of file vnc.c.

Referenced by ui_screenblt().

1069 {
1070  /* LibVNCServer already knows how to copy the data. */
1071  rfbDoCopyRect(s, x, y, x + w, y + h, x - srcx, y - srcy);
1072 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLdouble s
Definition: gl.h:2039
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void vncCopyBlitFrom ( rfbScreenInfoPtr  s,
int  x,
int  y,
int  w,
int  h,
vncBuffer src,
int  srcx,
int  srcy 
)

Definition at line 1075 of file vnc.c.

Referenced by ui_desktop_restore(), ui_draw_glyph(), ui_memblt(), ui_paint_bitmap(), and ui_patblt().

1076 {
1077  vncCopyBlitFromNoEncode(s, x, y, w, h, src, srcx, srcy);
1078  rfbMarkRectAsModified(s, x, y, x + w, y + h);
1079 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
void vncCopyBlitFromNoEncode(rfbScreenInfoPtr s, int x, int y, int w, int h, vncBuffer *src, int srcx, int srcy)
Definition: vnc.c:1025
GLdouble s
Definition: gl.h:2039
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void vncCopyBlitFromNoEncode ( rfbScreenInfoPtr  s,
int  x,
int  y,
int  w,
int  h,
vncBuffer src,
int  srcx,
int  srcy 
)

Definition at line 1025 of file vnc.c.

Referenced by vncCopyBlitFrom().

1027 {
1028  int xx, yy;
1029 
1030  vncHideCursor();
1031 
1032  if (s->serverFormat.bitsPerPixel == src->format->bitsPerPixel
1033  && srcx + w <= src->w && srcy + h <= src->h)
1034  {
1035  //simple copy
1036  uint8_t *srcdata, *dstdata;
1037  srcdata = src->data + (srcy * src->linew + srcx);
1038  dstdata = s->frameBuffer + (y * s->paddedWidthInBytes + x);
1039  for (yy = 0; yy < h; yy++)
1040  {
1041  memcpy(dstdata, srcdata, w);
1042  dstdata += s->paddedWidthInBytes;
1043  srcdata += src->linew;
1044  }
1045  }
1046  else
1047  {
1048  // xsrc,ysrc provide tiling copy support.
1049  for (yy = y; yy < y + h; yy++)
1050  {
1051  int ysrc = srcy + yy - y;
1052  while (ysrc >= src->h)
1053  ysrc -= src->h;
1054  for (xx = x; xx < x + w; xx++)
1055  {
1056  vncPixel p;
1057  int xsrc = srcx + xx - x;
1058  while (xsrc >= src->linew)
1059  xsrc -= src->linew;
1060  p = GETPIXEL(src, xsrc, ysrc);
1061  SETPIXEL(frameBuffer, xx, yy, p);
1062  }
1063  }
1064  }
1065 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
uint16_t h
Definition: vnc.h:12
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define GETPIXEL(buf, x, y)
Definition: vnc.c:1019
uint16_t linew
Definition: vnc.h:13
int xx
Definition: npserver.c:29
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void vncHideCursor()
Definition: vnc.c:85
GLdouble s
Definition: gl.h:2039
unsigned int vncPixel
Definition: vnc.h:8
BYTE uint8_t
Definition: msvideo1.c:66
char * data
Definition: vnc.h:15
static vncBuffer * frameBuffer
Definition: vnc.c:75
#define SETPIXEL(buf, x, y, p)
Definition: vnc.c:1021
GLfloat GLfloat p
Definition: glext.h:8902
INT INT y
Definition: msvc.h:62
rfbPixelFormat * format
Definition: vnc.h:14
INT x
Definition: msvc.h:62
void vncDeleteBuffer ( vncBuffer b)

Definition at line 1170 of file vnc.c.

Referenced by ui_desktop_restore(), ui_destroy_bitmap(), ui_draw_glyph(), ui_paint_bitmap(), and vncNewCursor().

1171 {
1172  if (b->owner)
1173  xfree(b->data);
1174  xfree(b);
1175 }
void xfree(void *mem)
Definition: uimain.c:758
char * data
Definition: vnc.h:15
BOOL owner
Definition: vnc.h:16
void vncDeleteColourMap ( rfbColourMap *  m)

Definition at line 1333 of file vnc.c.

Referenced by ui_destroy_colourmap(), and vncSetColourMap().

1334 {
1335  if (m->data.bytes)
1336  free(m->data.bytes);
1337  m->count = 0;
1338 }
#define free
Definition: debug_ros.c:5
const GLfloat * m
Definition: glext.h:10848
vncBuffer* vncDupBuffer ( vncBuffer b)

Definition at line 1003 of file vnc.c.

Referenced by ui_draw_glyph().

1004 {
1005  vncBuffer *buf = vncNewBuffer(b->w, b->h, b->format->depth);
1006  memcpy(buf->data, b->data, b->linew * b->h * b->format->bitsPerPixel / 8);
1007  return buf;
1008 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
uint16_t h
Definition: vnc.h:12
Definition: vnc.h:10
uint16_t w
Definition: vnc.h:12
uint16_t linew
Definition: vnc.h:13
vncBuffer * vncNewBuffer(int w, int h, int depth)
Definition: vnc.c:990
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char * data
Definition: vnc.h:15
rfbPixelFormat * format
Definition: vnc.h:14
vncPixel vncGetPixel ( vncBuffer b,
int  x,
int  y 
)

Definition at line 1218 of file vnc.c.

Referenced by ui_draw_glyph(), and ui_patblt().

1219 {
1220  unsigned long offset = (x + (y * (b->linew))) * (b->format->bitsPerPixel >> 3);
1221  return ((uint8_t *) (b->data))[offset];
1222 }
GLintptr offset
Definition: glext.h:5920
uint16_t linew
Definition: vnc.h:13
BYTE uint8_t
Definition: msvideo1.c:66
char * data
Definition: vnc.h:15
INT INT y
Definition: msvc.h:62
rfbPixelFormat * format
Definition: vnc.h:14
INT x
Definition: msvc.h:62
vncBuffer* vncGetRect ( rfbScreenInfoPtr  s,
int  x,
int  y,
int  w,
int  h 
)

Definition at line 1272 of file vnc.c.

Referenced by ui_desktop_save(), and ui_destblt().

1273 {
1274  int xx, yy;
1275  vncBuffer *b = vncNewBuffer(w, h, s->serverFormat.depth);
1276 
1277  vncHideCursor();
1278 
1279  if (s->serverFormat.bitsPerPixel == 8)
1280  {
1281  //simple copy
1282  int srcstep, dststep;
1283  char *srcdata, *dstdata;
1284  srcstep = s->paddedWidthInBytes * s->serverFormat.bitsPerPixel / 8;
1285  dststep = w * s->serverFormat.bitsPerPixel / 8;
1286  dstdata = b->data;
1287  srcdata = s->frameBuffer + (y * srcstep + x * s->serverFormat.bitsPerPixel / 8);
1288  for (yy = 0; yy < h; yy++)
1289  {
1290  memcpy(dstdata, srcdata, dststep);
1291  dstdata += dststep;
1292  srcdata += srcstep;
1293  }
1294  }
1295  else
1296  {
1297  for (yy = y; yy < y + h; yy++)
1298  {
1299  for (xx = x; xx < x + w; xx++)
1300  {
1301  SETPIXEL(b, xx - x, yy - y, GETPIXEL(frameBuffer, xx, yy));
1302  }
1303  }
1304  }
1305 
1306  return b;
1307 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
Definition: vnc.h:10
#define GETPIXEL(buf, x, y)
Definition: vnc.c:1019
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
int xx
Definition: npserver.c:29
vncBuffer * vncNewBuffer(int w, int h, int depth)
Definition: vnc.c:990
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void vncHideCursor()
Definition: vnc.c:85
GLdouble s
Definition: gl.h:2039
char * data
Definition: vnc.h:15
static vncBuffer * frameBuffer
Definition: vnc.c:75
#define SETPIXEL(buf, x, y, p)
Definition: vnc.c:1021
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void vncHideCursor ( )

Definition at line 85 of file vnc.c.

Referenced by vncAndBlitFrom(), vncCopyBlitFromNoEncode(), vncGetRect(), vncSetRect(), vncTransBlitFrom(), and vncXorBlitFrom().

86 {
87  if (server->clientHead)
88  rfbUndrawCursor(server);
89 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
void vncKey ( rfbBool  down,
rfbKeySym  keysym,
struct _rfbClientRec *  cl 
)

Definition at line 154 of file vnc.c.

Referenced by ui_create_window().

155 {
156  uint32 ev_time = time(NULL);
157  key_translation tr = { 0, 0 };
158 
159  if (keysym >= FIRST_MODIFIER && keysym <= LAST_MODIFIER)
160  {
161  /* TODO: fake local state */
162  keystate[keysym - FIRST_MODIFIER] = down;
163  }
164 
165  if (down)
166  {
167  /* TODO: fake local state */
168  if (handle_special_keys(keysym, 0, ev_time, True))
169  return;
170 
171  /* TODO: fake local state */
172  tr = xkeymap_translate_key(keysym, 0, 0);
173 
174  if (tr.scancode == 0)
175  return;
176 
177  ensure_remote_modifiers(ev_time, tr);
178 
180  }
181  else
182  {
183  /* todO: fake local state */
184  if (handle_special_keys(keysym, 0, ev_time, False))
185  return;
186 
187  /* todO: fake local state */
188  tr = xkeymap_translate_key(keysym, 0, 0);
189 
190  if (tr.scancode == 0)
191  return;
192 
194  }
195 }
key_translation xkeymap_translate_key(uint32 keysym, unsigned int keycode, unsigned int state)
#define RDP_KEYPRESS
Definition: constants.h:251
unsigned int uint32
Definition: types.h:32
__u16 time
Definition: mkdosfs.c:366
#define down(mutex)
Definition: glue.h:29
RD_BOOL handle_special_keys(uint32 keysym, unsigned int state, uint32 ev_time, RD_BOOL pressed)
smooth NULL
Definition: ftsmooth.c:416
#define LAST_MODIFIER
Definition: vnc.c:131
#define True
Definition: types.h:24
#define False
Definition: types.h:25
void ensure_remote_modifiers(uint32 ev_time, key_translation tr)
void rdp_send_scancode(uint32 time, uint16 flags, uint8 scancode)
uint8 scancode
Definition: types.h:132
#define FIRST_MODIFIER
Definition: vnc.c:130
static BOOL keystate[LAST_MODIFIER-FIRST_MODIFIER]
Definition: vnc.c:133
#define RDP_KEYRELEASE
Definition: constants.h:252
uint8_t vncLookupColour ( rfbColourMap *  colourMap,
uint8_t p 
)

Definition at line 403 of file vnc.c.

Referenced by ui_create_cursor().

404 {
405  uint8_t i, i1 = 0;
406  uint8_t *cm = colourMap->data.bytes;
407  uint32_t m, m1 = abs(cm[0] - p[0]) + abs(cm[1] - p[1]) + abs(cm[2] - p[2]);
408  for (i = 1; i < 255; i++)
409  {
410  m = abs(cm[i * 3] - p[0]) + abs(cm[i * 3 + 1] - p[1]) + abs(cm[i * 3 + 2] - p[2]);
411  if (m < m1)
412  {
413  m1 = m;
414  i1 = i;
415  }
416  }
417  return (i1);
418 }
#define abs(i)
Definition: fconv.c:206
GLenum GLclampf GLint i
Definition: glfuncs.h:14
BYTE uint8_t
Definition: msvideo1.c:66
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint i1
Definition: glfuncs.h:96
UINT32 uint32_t
Definition: types.h:75
CONST GLfloat m[16]
Definition: m_xform.h:144
GLfloat GLfloat p
Definition: glext.h:8902
void vncMouse ( int  buttonMask,
int  x,
int  y,
struct _rfbClientRec *  cl 
)

Definition at line 198 of file vnc.c.

Referenced by ui_create_window().

199 {
200  int b;
201  uint32 ev_time = time(NULL);
202 
204 
205  for (b = 0; b < 3; b++)
206  {
207  int bb = 1 << (b);
208  if (!(lastbuttons & bb) && (buttonMask & bb))
209  {
211  (mouseLookup[b]) | MOUSE_FLAG_DOWN, x, y);
212  }
213  else if ((lastbuttons & bb) && !(buttonMask & bb))
214  {
215  rdp_send_input(ev_time, RDP_INPUT_MOUSE, (mouseLookup[b]), x, y);
216  }
217  }
218  lastbuttons = buttonMask;
219 
220  /* handle cursor */
221  rfbDefaultPtrAddEvent(buttonMask, x, y, cl);
222 }
unsigned int uint32
Definition: types.h:32
int mouseLookup[3]
Definition: vnc.c:95
__u16 time
Definition: mkdosfs.c:366
#define MOUSE_FLAG_DOWN
Definition: constants.h:260
smooth NULL
Definition: ftsmooth.c:416
static int lastbuttons
Definition: vnc.c:128
#define b
Definition: ke_i.h:79
void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1, uint16 param2)
Definition: rdp.c:551
#define MOUSE_FLAG_MOVE
Definition: constants.h:254
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
vncBuffer* vncNewBuffer ( int  w,
int  h,
int  depth 
)

Definition at line 990 of file vnc.c.

Referenced by ui_create_bitmap(), ui_create_glyph(), ui_desktop_restore(), ui_patblt(), vncDupBuffer(), and vncGetRect().

991 {
992  vncBuffer *b = (vncBuffer *) xmalloc(sizeof(vncBuffer));
993  b->format = vncNewFormat(depth);
994  b->data = (void *) xmalloc(w * h * (b->format->bitsPerPixel / 8));
995  b->owner = 1;
996  b->w = w;
997  b->h = h;
998  b->linew = w;
999  return b;
1000 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
uint16_t h
Definition: vnc.h:12
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
void * xmalloc(int size)
Definition: uimain.c:747
Definition: vnc.h:10
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
uint16_t w
Definition: vnc.h:12
uint16_t linew
Definition: vnc.h:13
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
char * data
Definition: vnc.h:15
rfbPixelFormat * vncNewFormat(int depth)
Definition: vnc.c:984
BOOL owner
Definition: vnc.h:16
rfbPixelFormat * format
Definition: vnc.h:14
rfbColourMap* vncNewColourMap ( rfbScreenInfoPtr  s,
int  n 
)

Definition at line 1312 of file vnc.c.

Referenced by ui_create_colourmap().

1313 {
1314  rfbColourMap *m = (rfbColourMap *) xmalloc(sizeof(rfbColourMap));
1315  m->is16 = FALSE;
1316  m->count = n;
1317  m->data.bytes = (uint8_t *) xmalloc(n * 3);
1318  return m;
1319 }
GLuint n
Definition: s_context.h:57
#define FALSE
Definition: types.h:117
void * xmalloc(int size)
Definition: uimain.c:747
BYTE uint8_t
Definition: msvideo1.c:66
const GLfloat * m
Definition: glext.h:10848
CONST GLfloat m[16]
Definition: m_xform.h:144
rfbCursorPtr vncNewCursor ( vncBuffer mask,
vncBuffer pointer,
int  hotx,
int  hoty 
)

Definition at line 1179 of file vnc.c.

1180 {
1181  int i, j, w = (mask->w + 7) / 8, mask_size = w * mask->h,
1182  pointer_size = pointer->w * pointer->h;
1183  rfbCursorPtr c = (rfbCursorPtr) xmalloc(sizeof(rfbCursor));
1184 
1185  if (mask->w != pointer->w || mask->h != pointer->h)
1186  error("ERROR! Mask is %dx%d, Pointer is %dx%d\n",
1187  mask->w, mask->h, pointer->w, pointer->h);
1188 
1189  c->xhot = hotx;
1190  c->yhot = hoty;
1191  c->width = mask->w;
1192  c->height = mask->h;
1193 
1194  c->mask = (char *) xmalloc(mask_size);
1195  for (j = 0; j < c->height; j++)
1196  for (i = 0; i < w; i++)
1197  c->mask[j * w + i] =
1198  reverseByte[((unsigned char *) mask->data)[(j) * w + i]];
1199  vncDeleteBuffer(mask);
1200 
1201  c->source = 0;
1202  c->richSource = (char *) xmalloc(pointer_size);
1203  memcpy(c->richSource, pointer->data, pointer_size);
1204  vncDeleteBuffer(pointer);
1205 
1206  return c;
1207 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define error(str)
Definition: mkdosfs.c:1605
uint16_t h
Definition: vnc.h:12
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void * xmalloc(int size)
Definition: uimain.c:747
uint16_t w
Definition: vnc.h:12
const GLubyte * c
Definition: glext.h:8905
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int pointer_size
Definition: widl.c:148
char * data
Definition: vnc.h:15
static uint8_t reverseByte[0x100]
Definition: vnc.c:76
void vncDeleteBuffer(vncBuffer *b)
Definition: vnc.c:1170
#define c
Definition: ke_i.h:80
rfbPixelFormat* vncNewFormat ( int  depth)

Definition at line 984 of file vnc.c.

Referenced by vncNewBuffer().

985 {
986  return &(vnc_formats[(depth + 1) / 8 - 1]);
987 }
rfbPixelFormat vnc_formats[]
Definition: vnc.c:972
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
void vncPrintStats ( )

Definition at line 1011 of file vnc.c.

1012 {
1013  if (server && server->clientHead)
1014  rfbPrintStats(server->clientHead);
1015 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
void vncSetColourMap ( rfbScreenInfoPtr  s,
rfbColourMap *  m 
)

Definition at line 1341 of file vnc.c.

Referenced by ui_set_colourmap().

1342 {
1343  vncDeleteColourMap(&s->colourMap);
1344  s->colourMap = *m;
1345  rfbSetClientColourMaps(s, 0, 0);
1346 }
GLdouble s
Definition: gl.h:2039
CONST GLfloat m[16]
Definition: m_xform.h:144
void vncDeleteColourMap(rfbColourMap *m)
Definition: vnc.c:1333
void vncSetColourMapEntry ( rfbColourMap *  m,
int  i,
vncPixel  r,
vncPixel  g,
vncPixel  b 
)

Definition at line 1322 of file vnc.c.

Referenced by ui_create_colourmap().

1323 {
1324  if (i < m->count)
1325  {
1326  m->data.bytes[3 * i + 0] = r;
1327  m->data.bytes[3 * i + 1] = g;
1328  m->data.bytes[3 * i + 2] = b;
1329  }
1330 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define b
Definition: ke_i.h:79
GLboolean GLboolean g
Definition: glext.h:6204
GLuint GLuint GLsizei count
Definition: gl.h:1545
const GLfloat * m
Definition: glext.h:10848
void vncSetCursor ( rfbScreenInfoPtr  s,
rfbCursorPtr  c 
)

Definition at line 1211 of file vnc.c.

1212 {
1213  rfbSetCursor(s, c, FALSE);
1214 }
#define FALSE
Definition: types.h:117
const GLubyte * c
Definition: glext.h:8905
GLdouble s
Definition: gl.h:2039
void vncSetPixel ( vncBuffer b,
int  x,
int  y,
vncPixel  c 
)

Definition at line 1225 of file vnc.c.

Referenced by ui_create_glyph(), ui_draw_glyph(), and ui_patblt().

1226 {
1227  unsigned long offset = (x + (y * (b->linew))) * (b->format->bitsPerPixel >> 3);
1228  ((uint8_t *) (b->data))[offset] = c;
1229 }
GLintptr offset
Definition: glext.h:5920
uint16_t linew
Definition: vnc.h:13
const GLubyte * c
Definition: glext.h:8905
BYTE uint8_t
Definition: msvideo1.c:66
char * data
Definition: vnc.h:15
INT INT y
Definition: msvc.h:62
rfbPixelFormat * format
Definition: vnc.h:14
INT x
Definition: msvc.h:62
void vncSetRect ( rfbScreenInfoPtr  s,
int  x,
int  y,
int  w,
int  h,
vncPixel  c 
)

Definition at line 1232 of file vnc.c.

Referenced by ui_patblt(), and ui_rect().

1233 {
1234  int xx, yy;
1235 
1236  if (x + w > s->width)
1237  w = s->width - x;
1238  if (y + h > s->height)
1239  h = s->height - y;
1240  if (w <= 0 || h <= 0)
1241  return;
1242 
1243  vncHideCursor();
1244 
1245  // - Fill the rect in the local framebuffer
1246  if (s->serverFormat.bitsPerPixel == 8)
1247  {
1248  // - Simple 8-bit fill
1249  uint8_t *dstdata;
1250  dstdata = s->frameBuffer + (y * s->paddedWidthInBytes + x);
1251  for (yy = 0; yy < h; yy++)
1252  {
1253  memset(dstdata, c, w);
1254  dstdata += s->paddedWidthInBytes;
1255  }
1256  }
1257  else
1258  {
1259  for (yy = y; yy < y + h; yy++)
1260  {
1261  for (xx = x; xx < x + w; xx++)
1262  {
1263  SETPIXEL(frameBuffer, xx, yy, c);
1264  }
1265  }
1266  }
1267 
1268  rfbMarkRectAsModified(s, x, y, x + w, y + h);
1269 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
const GLubyte * c
Definition: glext.h:8905
int xx
Definition: npserver.c:29
void vncHideCursor()
Definition: vnc.c:85
GLdouble s
Definition: gl.h:2039
BYTE uint8_t
Definition: msvideo1.c:66
static vncBuffer * frameBuffer
Definition: vnc.c:75
#define SETPIXEL(buf, x, y, p)
Definition: vnc.c:1021
INT INT y
Definition: msvc.h:62
#define memset(x, y, z)
Definition: compat.h:39
INT x
Definition: msvc.h:62
void vncTransBlitFrom ( rfbScreenInfoPtr  s,
int  x,
int  y,
int  w,
int  h,
vncBuffer src,
int  srcx,
int  srcy,
int  bg 
)

Definition at line 1082 of file vnc.c.

Referenced by ui_draw_glyph(), and ui_memblt().

1084 {
1085  int xx, yy;
1086 
1087  vncHideCursor();
1088 
1089  // xsrc,ysrc provide tiling copy support.
1090  for (yy = y; yy < y + h; yy++)
1091  {
1092  int ysrc = srcy + yy - y;
1093  while (ysrc >= src->h)
1094  ysrc -= src->h;
1095  for (xx = x; xx < x + w; xx++)
1096  {
1097  vncPixel p;
1098  int xsrc = srcx + xx - x;
1099  while (xsrc >= src->linew)
1100  xsrc -= src->linew;
1101  p = GETPIXEL(src, xsrc, ysrc);
1102  // transparent blit!
1103  if (p != bg)
1104  SETPIXEL(frameBuffer, xx, yy, p);
1105  }
1106  }
1107 
1108  rfbMarkRectAsModified(s, x, y, x + w, y + h);
1109 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
uint16_t h
Definition: vnc.h:12
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define GETPIXEL(buf, x, y)
Definition: vnc.c:1019
uint16_t linew
Definition: vnc.h:13
int xx
Definition: npserver.c:29
void vncHideCursor()
Definition: vnc.c:85
GLdouble s
Definition: gl.h:2039
unsigned int vncPixel
Definition: vnc.h:8
static vncBuffer * frameBuffer
Definition: vnc.c:75
#define SETPIXEL(buf, x, y, p)
Definition: vnc.c:1021
GLfloat GLfloat p
Definition: glext.h:8902
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
BOOL vncwinClipRect ( int x,
int y,
int cx,
int cy 
)

Definition at line 102 of file vnc.c.

Referenced by ui_desktop_restore(), ui_draw_glyph(), ui_memblt(), ui_patblt(), ui_rect(), and ui_screenblt().

103 {
104  if (*x + *cx > clipX + clipW)
105  *cx = clipX + clipW - *x;
106  if (*y + *cy > clipY + clipH)
107  *cy = clipY + clipH - *y;
108  if (*x < clipX)
109  {
110  *cx -= clipX - *x;
111  *x = clipX;
112  }
113  if (*y < clipY)
114  {
115  *cy -= clipY - *y;
116  *y = clipY;
117  }
118  if (*cx < 0 || *cy < 0)
119  *cx = *cy = 0;
120  return (*cx > 0 && *cy > 0 && *x < server->width && *y < server->height);
121 }
int clipH
Definition: vnc.c:99
int clipY
Definition: vnc.c:99
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
int clipX
Definition: vnc.c:99
GLint GLint GLsizei width
Definition: gl.h:1546
int clipW
Definition: vnc.c:99
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
_Out_opt_ int * cx
Definition: commctrl.h:570
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void vncXorBlitFrom ( rfbScreenInfoPtr  s,
int  x,
int  y,
int  w,
int  h,
vncBuffer src,
int  srcx,
int  srcy 
)

Definition at line 1112 of file vnc.c.

Referenced by ui_memblt(), and ui_patblt().

1113 {
1114  int xx, yy;
1115 
1116  vncHideCursor();
1117 
1118  // xsrc,ysrc provide tiling copy support.
1119  for (yy = y; yy < y + h; yy++)
1120  {
1121  int ysrc = srcy + yy - y;
1122  while (ysrc >= src->h)
1123  ysrc -= src->h;
1124  for (xx = x; xx < x + w; xx++)
1125  {
1126  vncPixel p, pp;
1127  int xsrc = srcx + xx - x;
1128  while (xsrc >= src->linew)
1129  xsrc -= src->linew;
1130  p = GETPIXEL(src, xsrc, ysrc);
1131  pp = GETPIXEL(frameBuffer, xx, yy);
1132  // xor blit!
1133  SETPIXEL(frameBuffer, xx, yy, p ^ pp);
1134  }
1135  }
1136 
1137  rfbMarkRectAsModified(s, x, y, x + w, y + h);
1138 }
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
uint16_t h
Definition: vnc.h:12
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define pp
Definition: hlsl.yy.c:978
#define GETPIXEL(buf, x, y)
Definition: vnc.c:1019
uint16_t linew
Definition: vnc.h:13
int xx
Definition: npserver.c:29
void vncHideCursor()
Definition: vnc.c:85
GLdouble s
Definition: gl.h:2039
unsigned int vncPixel
Definition: vnc.h:8
static vncBuffer * frameBuffer
Definition: vnc.c:75
#define SETPIXEL(buf, x, y, p)
Definition: vnc.c:1021
GLfloat GLfloat p
Definition: glext.h:8902
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62
void xwin_toggle_fullscreen ( void  )

Definition at line 124 of file vnc.c.

Referenced by handle_special_keys().

125 {
126 }

Variable Documentation

int clipH

Definition at line 99 of file vnc.c.

Referenced by ui_reset_clip(), ui_set_clip(), and vncwinClipRect().

int clipW

Definition at line 99 of file vnc.c.

Referenced by ui_reset_clip(), ui_set_clip(), and vncwinClipRect().

int clipX

Definition at line 99 of file vnc.c.

Referenced by ui_reset_clip(), ui_set_clip(), and vncwinClipRect().

int clipY

Definition at line 99 of file vnc.c.

Referenced by ui_reset_clip(), ui_set_clip(), and vncwinClipRect().

int defer_time = 5

Definition at line 72 of file vnc.c.

Referenced by ui_create_window(), and ui_select().

BOOL enable_compose = False

Definition at line 82 of file vnc.c.

vncBuffer* frameBuffer = NULL
static

Definition at line 75 of file vnc.c.

int g_display = 0

Definition at line 78 of file vnc.c.

BOOL g_enable_compose = False

Definition at line 77 of file vnc.c.

char g_title[]

Referenced by ui_create_window().

int keylayout
BOOL keystate[LAST_MODIFIER-FIRST_MODIFIER]
static

Definition at line 133 of file vnc.c.

Referenced by get_key_state(), init_keyboard(), and vncKey().

int lastbuttons = 0
static

Definition at line 128 of file vnc.c.

Referenced by vncMouse().

int mouseLookup[3]
Initial value:
= {
}
#define MOUSE_FLAG_BUTTON1
Definition: constants.h:255
#define MOUSE_FLAG_BUTTON3
Definition: constants.h:257
#define MOUSE_FLAG_BUTTON2
Definition: constants.h:256

Definition at line 95 of file vnc.c.

Referenced by vncMouse().

BOOL owncolmap = False

Definition at line 81 of file vnc.c.

uint8_t reverseByte[0x100]
static

Definition at line 76 of file vnc.c.

Referenced by ui_create_glyph(), ui_create_window(), and vncNewCursor().

int rfb_port = 5923

Definition at line 71 of file vnc.c.

Referenced by rdp2vnc_connect(), and ui_create_window().

int rfbClientSocket = 0

Definition at line 73 of file vnc.c.

Referenced by rdp2vnc_connect(), and ui_create_window().

BOOL sendmotion
rfbPixelFormat vnc_formats[]
Initial value:
= {
{8, 8, 1, 0, 7, 7, 3, 0, 3, 6}
,
{16, 16, 1, 1, 31, 63, 31, 0, 5, 10}
,
{32, 24, 1, 1, 255, 255, 255, 0, 8, 16}
,
{32, 32, 1, 1, 2047, 2047, 1023, 0, 11, 22}
}

Definition at line 972 of file vnc.c.

Referenced by vncNewFormat().