blob: 8234affeac4a4d4c537d08911ff48a3b6fa0fb4a [file] [log] [blame]
San Mehata430b2b2014-09-23 08:30:51 -07001/*
2 Copyright (C) 2002-2010 Karl J. Runge <runge@karlrunge.com>
3 All rights reserved.
4
5This file is part of x11vnc.
6
7x11vnc is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or (at
10your option) any later version.
11
12x11vnc is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with x11vnc; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
20or see <http://www.gnu.org/licenses/>.
21
22In addition, as a special exception, Karl J. Runge
23gives permission to link the code of its release of x11vnc with the
24OpenSSL project's "OpenSSL" library (or with modified versions of it
25that use the same license as the "OpenSSL" library), and distribute
26the linked executables. You must obey the GNU General Public License
27in all respects for all of the code used other than "OpenSSL". If you
28modify this file, you may extend this exception to your version of the
29file, but you are not obligated to do so. If you do not wish to do
30so, delete this exception statement from your version.
31*/
32
33/* -- x11vnc_defs.c -- */
34
35#include "x11vnc.h"
36
37int overlay_present = 0;
38
39int xrandr_base_event_type = 0;
40
41int xfixes_base_event_type = 0;
42int xtest_base_event_type = 0;
43#if LIBVNCSERVER_HAVE_LIBXTRAP
44XETC *trap_ctx = NULL;
45#endif
46int xtrap_base_event_type = 0;
47int xdamage_base_event_type = 0;
48
49/* date +'lastmod: %Y-%m-%d' */
50char lastmod[] = "0.9.13 lastmod: 2010-12-27";
51
52/* X display info */
53
54Display *dpy = NULL; /* the single display screen we connect to */
55int scr = 0;
56char *xauth_raw_data = NULL;
57int xauth_raw_len = 0;
58Window window = None, rootwin = None; /* polled window, root window (usu. same) */
59Visual *default_visual = NULL; /* the default visual (unless -visual) */
60int bpp = 0, depth = 0;
61int indexed_color = 0;
62int dpy_x = 0, dpy_y = 0; /* size of display */
63int fb_x = 0, fb_y = 0, fb_b = 0; /* fb size and bpp guesses at display */
64int off_x, off_y; /* offsets for -sid */
65int wdpy_x, wdpy_y; /* for actual sizes in case of -clip */
66int cdpy_x, cdpy_y, coff_x, coff_y; /* the -clip params */
67int button_mask = 0; /* button state and info */
68int button_mask_prev = 0;
69int num_buttons = -1;
70
71long xselectinput_rootwin = 0;
72
73unsigned int display_button_mask = 0;
74unsigned int display_mod_mask = 0;
75
76/* image structures */
77XImage *scanline = NULL;
78XImage *fullscreen = NULL;
79XImage **tile_row = NULL; /* for all possible row runs */
80XImage *snaprect = NULL; /* for XShmGetImage (fs_factor) */
81XImage *snap = NULL; /* the full snap fb */
82XImage *raw_fb_image = NULL; /* the raw fb */
83
84/* corresponding shm structures */
85XShmSegmentInfo scanline_shm;
86XShmSegmentInfo fullscreen_shm;
87XShmSegmentInfo *tile_row_shm; /* for all possible row runs */
88XShmSegmentInfo snaprect_shm;
89
90/* rfb screen info */
91rfbScreenInfoPtr screen = NULL;
92char *rfb_desktop_name = NULL;
93char *http_dir = NULL;
94char vnc_desktop_name[256];
95char *main_fb = NULL; /* our copy of the X11 fb */
96char *rfb_fb = NULL; /* same as main_fb unless transformation */
97char *fake_fb = NULL; /* used under -padgeom */
98char *snap_fb = NULL; /* used under -snapfb */
99char *cmap8to24_fb = NULL; /* used under -8to24 */
100char *rot_fb = NULL;
101char *raw_fb = NULL; /* when used should be main_fb */
102char *raw_fb_addr = NULL;
103int raw_fb_offset = 0;
104int raw_fb_shm = 0;
105int raw_fb_mmap = 0;
106int raw_fb_seek = 0;
107int raw_fb_fd = -1;
108int raw_fb_back_to_X = 0; /* kludge for testing rawfb -> X */
109
110int raw_fb_native_bpp = 0;
111int raw_fb_expand_bytes = 1;
112unsigned long raw_fb_native_red_mask = 0, raw_fb_native_green_mask = 0, raw_fb_native_blue_mask = 0;
113unsigned short raw_fb_native_red_max = 0, raw_fb_native_green_max = 0, raw_fb_native_blue_max = 0;
114unsigned short raw_fb_native_red_shift = 0, raw_fb_native_green_shift = 0, raw_fb_native_blue_shift = 0;
115
116int rfb_bytes_per_line = 0;
117int main_bytes_per_line = 0;
118int rot_bytes_per_line = 0;
119unsigned long main_red_mask = 0, main_green_mask = 0, main_blue_mask = 0;
120unsigned short main_red_max = 0, main_green_max = 0, main_blue_max = 0;
121unsigned short main_red_shift = 0, main_green_shift = 0, main_blue_shift = 0;
122
123int raw_fb_bytes_per_line = 0;
124
125/* scaling parameters */
126char *scale_str = NULL;
127double scale_fac_x = 1.0;
128double scale_fac_y = 1.0;
129int scaling = 0;
130int scaling_blend = 1; /* for no blending option (very course) */
131int scaling_nomult4 = 0; /* do not require width = n * 4 */
132int scaling_pad = 0; /* pad out scaled sizes to fit denominator */
133int scaling_interpolate = 0; /* use interpolation scheme when shrinking */
134int scaled_x = 0, scaled_y = 0; /* dimensions of scaled display */
135int scale_numer = 0, scale_denom = 0; /* n/m */
136char *rotating_str = NULL;
137int rotating = 0;
138int rotating_same = 0;
139int rotating_cursors = 0;
140
141/* scale cursor */
142char *scale_cursor_str = NULL;
143double scale_cursor_fac_x = 1.0;
144double scale_cursor_fac_y = 1.0;
145int scaling_cursor = 0;
146int scaling_cursor_blend = 1;
147int scaling_cursor_interpolate = 0;
148int scale_cursor_numer = 0, scale_cursor_denom = 0;
149
150/* size of the basic tile unit that is polled for changes: */
151int tile_x = 32;
152int tile_y = 32;
153int ntiles, ntiles_x = 0, ntiles_y = 0;
154
155/* arrays that indicate changed or checked tiles. */
156unsigned char *tile_has_diff = NULL, *tile_tried = NULL, *tile_copied = NULL;
157unsigned char *tile_has_xdamage_diff = NULL, *tile_row_has_xdamage_diff = NULL;
158
159/* times of recent events */
160time_t last_event = 0, last_input = 0, last_client = 0, last_open_xdisplay = 0;
161time_t last_local_input = 0;
162time_t last_keyboard_input = 0, last_pointer_input = 0;
163time_t last_fb_bytes_sent = 0;
164double last_keyboard_time = 0.0;
165double last_pointer_time = 0.0;
166double last_pointer_click_time = 0.0;
167double last_pointer_motion_time = 0.0;
168double last_key_to_button_remap_time = 0.0;
169double last_copyrect = 0.0;
170double last_copyrect_fix = 0.0;
171double last_wireframe = 0.0;
172double servertime_diff = 0.0;
173double x11vnc_start = 0.0;
174double x11vnc_current = 0.0;
175double g_now = 0.0;
176
177double last_get_wm_frame_time = 0.0;
178Window last_get_wm_frame = None;
179double last_bs_restore = 0.0;
180double last_su_restore = 0.0;
181double last_bs_save = 0.0;
182double last_su_save = 0.0;
183
184int hack_val = 0;
185
186/* last client to move pointer */
187rfbClientPtr last_pointer_client = NULL;
188rfbClientPtr latest_client = NULL;
189double last_client_gone = 0.0;
190double last_new_client = 0.0;
191
192int waited_for_client = 0;
193int findcreatedisplay = 0;
194char *terminal_services_daemon = NULL;
195
196int client_count = 0;
197int clients_served = 0;
198int client_normal_count = 0;
199
200/* more transient kludge variables: */
201int cursor_x = 0, cursor_y = 0; /* x and y from the viewer(s) */
202int button_change_x = 0, button_change_y = 0;
203int got_user_input = 0;
204int got_pointer_input = 0;
205int got_local_pointer_input = 0;
206int got_pointer_calls = 0;
207int got_keyboard_input = 0;
208int got_keyboard_calls = 0;
209int urgent_update = 0;
210int last_keyboard_keycode = 0;
211rfbBool last_rfb_down = FALSE;
212rfbBool last_rfb_key_accepted = FALSE;
213rfbKeySym last_rfb_keysym = 0;
214double last_rfb_keytime = 0.0;
215double last_rfb_key_injected = 0.0;
216double last_rfb_ptr_injected = 0.0;
217int fb_copy_in_progress = 0;
218int drag_in_progress = 0;
219int shut_down = 0;
220int do_copy_screen = 0;
221time_t damage_time = 0;
222int damage_delay = 0;
223
224int program_pid = 0;
225char *program_name = NULL;
226char *program_cmdline = NULL;
227
228struct utsname UT;
229
230