1
#ifndef _X11VNC_X11VNC_H
2
#define _X11VNC_X11VNC_H
6
* These ' -- filename.[ch] -- ' comments represent a partial cleanup:
7
* they are an odd way to indicate how this huge file would be split up
8
* someday into multiple files.
10
* The primary reason we have not broken up this file is for user
11
* convenience: those wanting to use the latest version download a single
12
* file, x11vnc.c, and off they go...
15
/****************************************************************************/
17
/* Standard includes and libvncserver */
21
#include <sys/utsname.h>
23
/* to avoid select() compiler warning */
34
#include <rfb/rfbregion.h>
37
/* we can now build under --without-x: */
38
#if LIBVNCSERVER_HAVE_X11
42
#include <X11/Xutil.h>
44
#include <X11/keysym.h>
45
#include <X11/Xatom.h>
53
#include <rfb/keysym.h>
57
/****************************************************************************/
61
* Build-time customization via CPPFLAGS.
63
* Summary of options to include in CPPFLAGS for custom builds:
65
* -DVNCSHARED to have the vnc display shared by default.
66
* -DFOREVER to have -forever on by default.
67
* -DNOREPEAT=0 to have -repeat on by default.
68
* -DXINERAMA=0 to have -noxinerama on by default.
69
* -DADDKEYSYMS=0 to have -noadd_keysyms the default.
71
* -DREMOTE_DEFAULT=0 to disable remote-control on by default (-yesremote).
72
* -DREMOTE_CONTROL=0 to disable remote-control mechanism completely.
73
* -DEXTERNAL_COMMANDS=0 to disable the running of all external commands.
74
* -DTIGHTFILEXFER=0 disable tightfilexfer.
76
* -DHARDWIRE_PASSWD=... hardwired passwords, quoting necessary.
77
* -DHARDWIRE_VIEWPASSWD=...
78
* -DNOPW=1 make -nopw the default (skip warning)
79
* -DUSEPW=1 make -usepw the default
80
* -DPASSWD_REQUIRED=1 exit unless a password is supplied.
81
* -DPASSWD_UNLESS_NOPW=1 exit unless a password is supplied and no -nopw.
83
* -DCURSOR_DRAG=1 to have -cursor_drag as the default.
84
* -DWIREFRAME=0 to have -nowireframe as the default.
85
* -DWIREFRAME_COPYRECT=0 to have -nowirecopyrect as the default.
86
* -DWIREFRAME_PARMS=... set default -wirecopyrect parameters.
87
* -DSCROLL_COPYRECT=0 to have -noscrollcopyrect as the default.
88
* -DSCROLL_COPYRECT_PARMS=... set default -scrollcopyrect parameters.
89
* -DSCALING_COPYRECT=0
90
* -DXDAMAGE=0 to have -noxdamage as the default.
91
* -DSKIPDUPS=0 to have -noskip_dups as the default or vice versa.
93
* -DPOINTER_MODE_DEFAULT={0,1,2,3,4} set default -pointer_mode.
94
* -DBOLDLY_CLOSE_DISPLAY=0 to not close X DISPLAY under -rawfb.
95
* -DSMALL_FOOTPRINT=1 for smaller binary size (no help, no gui, etc)
96
* use 2 or 3 for even smaller footprint.
97
* -DNOGUI do not include the gui tkx11vnc.
98
* -DSKIP_HELP=1 smaller.
99
* -DSKIP_XKB=1 a little smaller.
100
* -DSKIP_8to24=1 a little smaller.
101
* -DPOLL_8TO24_DELAY=N
102
* -DDEBUG_XEVENTS=1 enable printout for X events.
104
* Set these in CPPFLAGS before running configure. E.g.:
106
* % env CPPFLAGS="-DFOREVER -DREMOTE_CONTROL=0" ./configure
111
* This can be used to disable the remote control mechanism.
113
#ifndef REMOTE_CONTROL
114
#define REMOTE_CONTROL 1
129
#ifndef PASSWD_REQUIRED
130
#define PASSWD_REQUIRED 0
133
#ifndef PASSWD_UNLESS_NOPW
134
#define PASSWD_UNLESS_NOPW 0
137
/* these are for delaying features: */
138
#define xxNO_SSL_OR_UNIXPW
142
* Beginning of support for small binary footprint build for embedded
143
* systems, PDA's etc. It currently just cuts out the low-hanging
144
* fruit (large text passages). Set to 2, 3 to cut out some of the
145
* more esoteric extensions. More tedious is to modify LDFLAGS in the
146
* Makefile to not link against the extension libraries... but that
147
* should be done too (manually for now).
149
* If there is interest more of the bloat can be removed... Currently
150
* these shrink the binary from 1100K to about 600K.
152
#ifndef SMALL_FOOTPRINT
153
#define SMALL_FOOTPRINT 0
173
#if (SMALL_FOOTPRINT > 1)
176
#undef LIBVNCSERVER_HAVE_LIBXINERAMA
177
#undef LIBVNCSERVER_HAVE_LIBXFIXES
178
#undef LIBVNCSERVER_HAVE_LIBXDAMAGE
181
#define LIBVNCSERVER_HAVE_LIBXINERAMA 0
182
#define LIBVNCSERVER_HAVE_LIBXFIXES 0
183
#define LIBVNCSERVER_HAVE_LIBXDAMAGE 0
186
#if (SMALL_FOOTPRINT > 2)
187
#undef LIBVNCSERVER_HAVE_UTMPX_H
188
#undef LIBVNCSERVER_HAVE_PWD_H
189
#undef REMOTE_CONTROL
190
#define LIBVNCSERVER_HAVE_UTMPX_H 0
191
#define LIBVNCSERVER_HAVE_PWD_H 0
192
#define REMOTE_CONTROL 0
196
* Not recommended unless you know what you are getting into, but if you
197
* define the HARDWIRE_PASSWD or HARDWIRE_VIEWPASSWD variables here or in
198
* CPPFLAGS you can set a default -passwd and -viewpasswd string values,
199
* perhaps this would be better than nothing on an embedded system, etc.
200
* These default values will be overridden by the command line.
201
* We don't even give an example ;-)
204
/****************************************************************************/
206
/* Extensions and related includes: */
208
#if LIBVNCSERVER_HAVE_XSHM
209
# if defined(__hpux) && defined(__ia64) /* something weird on hp/itanic */
210
# undef _INCLUDE_HPUX_SOURCE
214
#include <X11/extensions/XShm.h>
219
#if LIBVNCSERVER_HAVE_XTEST
220
#include <X11/extensions/XTest.h>
222
extern int xtest_base_event_type;
224
#if LIBVNCSERVER_HAVE_LIBXTRAP
227
#include <X11/extensions/xtraplib.h>
228
#include <X11/extensions/xtraplibp.h>
229
extern XETC *trap_ctx;
231
extern int xtrap_base_event_type;
233
#if LIBVNCSERVER_HAVE_RECORD
234
#include <X11/Xproto.h>
235
#include <X11/extensions/record.h>
238
#if LIBVNCSERVER_HAVE_XKEYBOARD
239
#include <X11/XKBlib.h>
242
#if LIBVNCSERVER_HAVE_LIBXINERAMA
243
#include <X11/extensions/Xinerama.h>
246
#if LIBVNCSERVER_HAVE_SYS_SOCKET_H
247
#include <sys/socket.h>
255
#if LIBVNCSERVER_HAVE_NETINET_IN_H
256
#include <netinet/in.h>
257
#include <netinet/tcp.h>
258
#include <arpa/inet.h>
261
#if LIBVNCSERVER_HAVE_PWD_H
265
#if LIBVNCSERVER_HAVE_SYS_WAIT_H
266
#include <sys/wait.h>
268
#if LIBVNCSERVER_HAVE_UTMPX_H
272
#if LIBVNCSERVER_HAVE_MMAP
273
#include <sys/mman.h>
277
* overlay/multi-depth screen reading support
278
* undef SOLARIS_OVERLAY or IRIX_OVERLAY if there are problems building.
282
#if defined (__SVR4) && defined (__sun)
284
# ifdef LIBVNCSERVER_HAVE_SOLARIS_XREADSCREEN
285
# define SOLARIS_OVERLAY
290
#ifdef SOLARIS_OVERLAY
291
#include <X11/extensions/transovl.h>
297
# ifdef LIBVNCSERVER_HAVE_IRIX_XREADDISPLAY
298
# define IRIX_OVERLAY
304
* For reference, the OS header defines:
305
__SVR4 && __sun is solaris
313
(defined(__MACH__) && defined(__APPLE__))
316
#if (defined(__MACH__) && defined(__APPLE__))
322
#include <X11/extensions/readdisplay.h>
325
extern int overlay_present;
327
#if LIBVNCSERVER_HAVE_LIBXRANDR
328
#include <X11/extensions/Xrandr.h>
330
extern int xrandr_base_event_type;
332
#if LIBVNCSERVER_HAVE_LIBXFIXES
333
#include <X11/extensions/Xfixes.h>
335
extern int xfixes_base_event_type;
337
#if LIBVNCSERVER_HAVE_LIBXDAMAGE
338
#include <X11/extensions/Xdamage.h>
340
extern int xdamage_base_event_type;
342
#define RAWFB_RET(y) if (raw_fb && ! dpy) return y;
343
#define RAWFB_RET_VOID if (raw_fb && ! dpy) return;
345
extern char lastmod[];
349
extern Display *dpy; /* the single display screen we connect to */
351
extern char *xauth_raw_data;
352
extern int xauth_raw_len;
353
extern Window window, rootwin; /* polled window, root window (usu. same) */
354
extern Visual *default_visual; /* the default visual (unless -visual) */
355
extern int bpp, depth;
356
extern int indexed_color;
357
extern int dpy_x, dpy_y; /* size of display */
358
extern int fb_x, fb_y, fb_b; /* fb size and bpp guesses at display */
359
extern int off_x, off_y; /* offsets for -sid */
360
extern int wdpy_x, wdpy_y; /* for actual sizes in case of -clip */
361
extern int cdpy_x, cdpy_y, coff_x, coff_y; /* the -clip params */
362
extern int button_mask; /* button state and info */
363
extern int button_mask_prev;
364
extern int num_buttons;
366
extern long xselectinput_rootwin;
368
extern unsigned int display_button_mask;
369
extern unsigned int display_mod_mask;
371
/* image structures */
372
extern XImage *scanline;
373
extern XImage *fullscreen;
374
extern XImage **tile_row; /* for all possible row runs */
375
extern XImage *snaprect; /* for XShmGetImage (fs_factor) */
376
extern XImage *snap; /* the full snap fb */
377
extern XImage *raw_fb_image; /* the raw fb */
379
#if !LIBVNCSERVER_HAVE_XSHM
381
* for simplicity, define this struct since we'll never use them
382
* under using_shm = 0.
385
int shmid; char *shmaddr; Bool readOnly;
389
/* corresponding shm structures */
390
extern XShmSegmentInfo scanline_shm;
391
extern XShmSegmentInfo fullscreen_shm;
392
extern XShmSegmentInfo *tile_row_shm; /* for all possible row runs */
393
extern XShmSegmentInfo snaprect_shm;
395
/* rfb screen info */
396
extern rfbScreenInfoPtr screen;
397
extern char *rfb_desktop_name;
398
extern char *http_dir;
399
extern char vnc_desktop_name[];
400
extern char *main_fb; /* our copy of the X11 fb */
401
extern char *rfb_fb; /* same as main_fb unless transformation */
402
extern char *fake_fb; /* used under -padgeom */
403
extern char *snap_fb; /* used under -snapfb */
404
extern char *cmap8to24_fb; /* used under -8to24 */
405
extern char *rot_fb; /* used under -rotate */
407
extern char *raw_fb_addr;
408
extern int raw_fb_offset;
409
extern int raw_fb_shm;
410
extern int raw_fb_mmap;
411
extern int raw_fb_seek;
412
extern int raw_fb_fd;
413
extern int raw_fb_back_to_X;
415
extern int rfb_bytes_per_line;
416
extern int main_bytes_per_line;
417
extern int rot_bytes_per_line;
418
extern unsigned long main_red_mask, main_green_mask, main_blue_mask;
419
extern unsigned short main_red_max, main_green_max, main_blue_max;
420
extern unsigned short main_red_shift, main_green_shift, main_blue_shift;
422
extern int raw_fb_bytes_per_line; /* of actual raw region we poll, not our raw_fb */
424
/* scaling parameters */
425
extern char *scale_str;
426
extern double scale_fac;
428
extern int scaling_blend; /* for no blending option (very course) */
429
extern int scaling_nomult4; /* do not require width = n * 4 */
430
extern int scaling_pad; /* pad out scaled sizes to fit denominator */
431
extern int scaling_interpolate; /* use interpolation scheme when shrinking */
432
extern int scaled_x, scaled_y; /* dimensions of scaled display */
433
extern int scale_numer, scale_denom; /* n/m */
434
extern char *rotating_str;
436
extern int rotating_same;
437
extern int rotating_cursors;
440
extern char *scale_cursor_str;
441
extern double scale_cursor_fac;
442
extern int scaling_cursor;
443
extern int scaling_cursor_blend;
444
extern int scaling_cursor_interpolate;
445
extern int scale_cursor_numer, scale_cursor_denom;
447
/* size of the basic tile unit that is polled for changes: */
450
extern int ntiles, ntiles_x, ntiles_y;
452
/* arrays that indicate changed or checked tiles. */
453
extern unsigned char *tile_has_diff, *tile_tried, *tile_copied;
454
extern unsigned char *tile_has_xdamage_diff, *tile_row_has_xdamage_diff;
456
/* times of recent events */
457
extern time_t last_event, last_input, last_client;
458
extern time_t last_keyboard_input, last_pointer_input;
459
extern time_t last_local_input;
460
extern time_t last_fb_bytes_sent;
461
extern double last_keyboard_time;
462
extern double last_pointer_time;
463
extern double last_pointer_click_time;
464
extern double last_pointer_motion_time;
465
extern double last_key_to_button_remap_time;
466
extern double last_copyrect;
467
extern double last_copyrect_fix;
468
extern double last_wireframe;
469
extern double servertime_diff;
470
extern double x11vnc_start;
471
extern double x11vnc_current;
474
extern double last_get_wm_frame_time;
475
extern Window last_get_wm_frame;
476
extern double last_bs_restore;
477
extern double last_su_restore;
478
extern double last_bs_save;
479
extern double last_su_save;
483
/* last client to move pointer */
484
extern rfbClientPtr last_pointer_client;
485
extern rfbClientPtr latest_client;
486
extern double last_client_gone;
488
extern int waited_for_client;
489
extern int findcreatedisplay;
490
extern char *terminal_services_daemon;
492
extern int client_count;
493
extern int clients_served;
495
/* more transient kludge variables: */
496
extern int cursor_x, cursor_y; /* x and y from the viewer(s) */
497
extern int button_change_x, button_change_y;
498
extern int got_user_input;
499
extern int got_pointer_input;
500
extern int got_local_pointer_input;
501
extern int got_pointer_calls;
502
extern int got_keyboard_input;
503
extern int got_keyboard_calls;
504
extern int urgent_update;
505
extern int last_keyboard_keycode;
506
extern rfbBool last_rfb_down;
507
extern rfbBool last_rfb_key_accepted;
508
extern rfbKeySym last_rfb_keysym;
509
extern double last_rfb_keytime;
510
extern int fb_copy_in_progress;
511
extern int drag_in_progress;
512
extern int shut_down;
513
extern int do_copy_screen;
514
extern time_t damage_time;
515
extern int damage_delay;
517
extern int program_pid;
518
extern char *program_name;
519
extern char *program_cmdline;
521
extern struct utsname UT;
523
typedef struct hint {
524
/* location x, y, height, and width of a change-rectangle */
525
/* (grows as adjacent horizontal tiles are glued together) */
529
/* struct with client specific data: */
531
typedef struct _ClientData {
543
pid_t ssl_helper_pid;
545
int had_cursor_shape_updates;
546
int had_cursor_pos_updates;
549
double send_cmp_rate;
550
double send_raw_rate;
557
extern void nox11_exit(int rc);
564
#endif /* _X11VNC_X11VNC_H */