Commit 1b9082bc authored by runge's avatar runge

x11vnc: -reflect, -N. -ncache, FINDDISPLAY, FINDCREATEDISPLAY, improvements. ...

x11vnc: -reflect, -N. -ncache, FINDDISPLAY, FINDCREATEDISPLAY, improvements.  MODTWEAK_LOWEST workaround.
parent 1f8da9bd
2007-01-31 Karl Runge <runge@karlrunge.com>
* x11vnc: -reflect reflector/repeater mode with libvncclient.
-ncache tweaks: no kde animations and wm improvements,
fixes to FINDDISPLAY and FINDCREATEDISPLAY login modes,
MODTWEAK_LOWEST envvar for HP-UX keyboard workaround.
-N option for display and rfbport matching.
2007-01-12 Karl Runge <runge@karlrunge.com>
* x11vnc: -N option, more -ncache improvements, kde/gnome.
2007-01-03 Karl Runge <runge@karlrunge.com>
* x11vnc: more -ncache improvements.
......
AM_CFLAGS = -I $(top_srcdir)
LDADD = ../libvncserver/libvncserver.a @WSOCKLIB@
LDADD = ../libvncserver/libvncserver.a ../libvncclient/libvncclient.a @WSOCKLIB@
if OSX
x11vnc_LDFLAGS = -framework ApplicationServices -framework Carbon -framework IOKit -framework Cocoa
......
This diff is collapsed.
......@@ -158,6 +158,9 @@ void clean_up_exit (int ret) {
if (use_solid_bg) {
solid_bg(1);
}
if (ncache || ncache0) {
kde_no_animate(1);
}
X_LOCK;
XTestDiscard_wr(dpy);
#if LIBVNCSERVER_HAVE_LIBXDAMAGE
......@@ -415,6 +418,9 @@ static void interrupted (int sig) {
if (use_solid_bg) {
solid_bg(1);
}
if (ncache || ncache0) {
kde_no_animate(1);
}
stop_stunnel();
if (crash_debug) {
......
......@@ -517,8 +517,9 @@ int run_user_command(char *cmd, rfbClientPtr client, char *mode, char *input,
clean_up_exit(1);
}
rfbLog("running command:\n");
rfbLog(" %s\n", cmd);
if (!quiet) {
fprintf(stderr, "\n %s\n\n", cmd);
}
close_exec_fds();
if (output != NULL) {
......@@ -668,6 +669,9 @@ void client_gone(rfbClientPtr client) {
if (use_solid_bg && client_count == 0) {
solid_bg(1);
}
if ((ncache || ncache0) && client_count == 0) {
kde_no_animate(1);
}
if (client->clientData) {
cd = (ClientData *) client->clientData;
if (cd->ssl_helper_pid > 0) {
......
......@@ -1113,7 +1113,6 @@ static rfbCursorPtr pixels2curs(unsigned long *pixels, int w, int h,
a = 0xff000000 & (*(pixels+i));
a = a >> 24; /* alpha channel */
if (a < (unsigned int) thresh) {
bitmap[i] = ' ';
} else {
......@@ -1256,6 +1255,13 @@ static int get_exact_cursor(int init) {
}
#endif
if (rawfb_vnc_reflect) {
int last_idx = (int) get_cursor_serial(1);
if (last_idx) {
which = last_idx;
}
return which;
}
if (xfixes_present && dpy) {
#if LIBVNCSERVER_HAVE_LIBXFIXES
int last_idx = (int) get_cursor_serial(1);
......@@ -1490,6 +1496,9 @@ int get_which_cursor(void) {
mode = 3;
}
if (rawfb_vnc_reflect && mode > -1) {
return get_exact_cursor(0);
}
if (mode == 3) {
if ((xfixes_present && use_xfixes) || macosx_console) {
if (db) fprintf(stderr, "get_which_cursor call get_exact_cursor\n");
......
This diff is collapsed.
......@@ -2235,6 +2235,7 @@ void initialize_modtweak(void) {
#else
KeySym keysym, *keymap;
int i, j, minkey, maxkey, syms_per_keycode;
int use_lowest_index = 0;
if (use_xkb_modtweak) {
initialize_xkb_modtweak();
......@@ -2247,6 +2248,10 @@ void initialize_modtweak(void) {
RAWFB_RET_VOID
if (getenv("MODTWEAK_LOWEST")) {
use_lowest_index = 1;
}
X_LOCK;
XDisplayKeycodes(dpy, &minkey, &maxkey);
......@@ -2306,6 +2311,9 @@ void initialize_modtweak(void) {
keysym = keymap[ (i - minkey) * syms_per_keycode + j ];
if ( keysym >= ' ' && keysym < 0x100
&& i == XKeysymToKeycode(dpy, keysym) ) {
if (use_lowest_index && keycodes[keysym] != NoSymbol) {
continue;
}
keycodes[keysym] = i;
modifiers[keysym] = j;
}
......@@ -2555,6 +2563,8 @@ static void pipe_keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) {
uinput_key_command(down, keysym, client);
} else if (pipeinput_int == PIPEINPUT_MACOSX) {
macosx_key_command(down, keysym, client);
} else if (pipeinput_int == PIPEINPUT_VNC) {
vnc_reflect_send_key((uint32_t) keysym, down);
}
if (pipeinput_fh == NULL) {
return;
......
......@@ -243,7 +243,7 @@ void macosx_pointer_command(int mask, int x, int y, rfbClientPtr client) {
last_pointer_time = time(NULL);
}
if (last_mask != mask) {
fprintf(stderr, "about to inject mask change %d -> %d: %.4f\n", last_mask, mask, dnowx());
if (0) fprintf(stderr, "about to inject mask change %d -> %d: %.4f\n", last_mask, mask, dnowx());
if (mask) {
int px, py, x, y, w, h;
macosx_click_frame = None;
......@@ -267,7 +267,7 @@ void macosx_pointer_command(int mask, int x, int y, rfbClientPtr client) {
if (ncache > 0) {
/* XXX Y */
int i;
fprintf(stderr, "about to get all windows: %.4f\n", dnowx());
if (0) fprintf(stderr, "about to get all windows: %.4f\n", dnowx());
for (i=0; i < 2; i++) {
macosxCGS_get_all_windows();
fprintf(stderr, "!");
......@@ -275,7 +275,7 @@ fprintf(stderr, "about to get all windows: %.4f\n", dnowx());
break;
}
}
fprintf(stderr, "\ndone: %.4f\n", dnowx());
if (0) fprintf(stderr, "\ndone: %.4f\n", dnowx());
}
}
last_mask = mask;
......
......@@ -35,7 +35,7 @@ void macosxCG_key_inject(int down, unsigned int keysym);
CGDirectDisplayID displayID = NULL;
extern void macosx_log(char *);
extern int collect_macosx_damage(int x_in, int y_in, int w_in, int h_in, int call);
extern int collect_non_X_xdamage(int x_in, int y_in, int w_in, int h_in, int call);
static void macosxCG_callback(CGRectCount n, const CGRect *rects, void *dum) {
int i, db = 0;
......@@ -43,7 +43,7 @@ static void macosxCG_callback(CGRectCount n, const CGRect *rects, void *dum) {
if (!dum) {}
for (i=0; i < (int) n; i++) {
if (db > 1) fprintf(stderr, " : %g %g - %g %g\n", rects[i].origin.x, rects[i].origin.y, rects[i].size.width, rects[i].size.height);
collect_macosx_damage( (int) rects[i].origin.x, (int) rects[i].origin.y,
collect_non_X_xdamage( (int) rects[i].origin.x, (int) rects[i].origin.y,
(int) rects[i].size.width, (int) rects[i].size.height, 1);
}
}
......
......@@ -177,7 +177,7 @@ int macosxCGS_follow_animation_win(int win, int idx, int grow) {
macwins[idx].height = h;
}
fprintf(stderr, " chase: %03dx%03d+%03d+%03d %d\n", w, h, x, y, win);
if (0) fprintf(stderr, " chase: %03dx%03d+%03d+%03d %d\n", w, h, x, y, win);
if (x == xp && y == yp && w == wp && h == hp) {
reps++;
if (reps >= 2) {
......@@ -398,20 +398,20 @@ if (db) fprintf(stderr, "cnt: %d err: %d\n", (int) _wins_mapped_cnt, err);
;
} else if ( !(prev & is_mapped) && (curr & is_mapped)) {
/* MapNotify */
fprintf(stderr, "MapNotify: %d/%d %d %.4f tot=%d\n", prev, curr, win, dnowx(), totcnt);
if (0) fprintf(stderr, "MapNotify: %d/%d %d %.4f tot=%d\n", prev, curr, win, dnowx(), totcnt);
macosx_add_mapnotify(win, macwins[i].level, 1);
if (0) macosxCGS_follow_animation_win(win, i, 1);
} else if ( !(curr & is_mapped) && (prev & is_mapped)) {
/* UnmapNotify */
fprintf(stderr, "UnmapNotify: %d/%d %d %.4f A tot=%d\n", prev, curr, win, dnowx(), totcnt);
if (0) fprintf(stderr, "UnmapNotify: %d/%d %d %.4f A tot=%d\n", prev, curr, win, dnowx(), totcnt);
macosx_add_mapnotify(win, macwins[i].level, 0);
} else if ( !(prev & is_exist) && (curr & is_exist)) {
/* CreateNotify */
fprintf(stderr, "CreateNotify:%d/%d %d %.4f whist: %d/%d 0x%x tot=%d\n", prev, curr, win, dnowx(), whist_prv, whist_idx, win, totcnt);
if (0) fprintf(stderr, "CreateNotify:%d/%d %d %.4f whist: %d/%d 0x%x tot=%d\n", prev, curr, win, dnowx(), whist_prv, whist_idx, win, totcnt);
macosx_add_create(win, macwins[i].level);
if (curr & is_mapped) {
fprintf(stderr, "MapNotify: %d/%d %d %.4f tot=%d\n", prev, curr, win, dnowx(), totcnt);
if (0) fprintf(stderr, "MapNotify: %d/%d %d %.4f tot=%d\n", prev, curr, win, dnowx(), totcnt);
macosx_add_mapnotify(win, macwins[i].level, 1);
}
}
......@@ -425,24 +425,24 @@ if (db) fprintf(stderr, "cnt: %d err: %d\n", (int) _wins_mapped_cnt, err);
if (1) {
;
} else if (curr & is_clipped) {
fprintf(stderr, "VisibNotify: %d/%d %d OBS tot=%d\n", prev, curr, win, totcnt);
if (0) fprintf(stderr, "VisibNotify: %d/%d %d OBS tot=%d\n", prev, curr, win, totcnt);
nv_win[nv] = win;
nv_lvl[nv] = macwins[i].level;
nv_vis[nv++] = 1;
} else {
fprintf(stderr, "VisibNotify: %d/%d %d UNOBS tot=%d\n", prev, curr, win, totcnt);
if (0) fprintf(stderr, "VisibNotify: %d/%d %d UNOBS tot=%d\n", prev, curr, win, totcnt);
nv_win[nv] = win;
nv_lvl[nv] = macwins[i].level;
nv_vis[nv++] = 0;
}
} else {
if ( !(prev & is_clipped) && (curr & is_clipped) ) {
fprintf(stderr, "VisibNotify: %d/%d %d OBS tot=%d\n", prev, curr, win, totcnt);
if (0) fprintf(stderr, "VisibNotify: %d/%d %d OBS tot=%d\n", prev, curr, win, totcnt);
nv_win[nv] = win;
nv_lvl[nv] = macwins[i].level;
nv_vis[nv++] = 1;
} else if ( (prev & is_clipped) && !(curr & is_clipped) ) {
fprintf(stderr, "VisibNotify: %d/%d %d UNOBS tot=%d\n", prev, curr, win, totcnt);
if (0) fprintf(stderr, "VisibNotify: %d/%d %d UNOBS tot=%d\n", prev, curr, win, totcnt);
nv_win[nv] = win;
nv_lvl[nv] = macwins[i].level;
nv_vis[nv++] = 0;
......@@ -466,11 +466,11 @@ if (db) fprintf(stderr, "cnt: %d err: %d\n", (int) _wins_mapped_cnt, err);
prev = whist[whist_prv][win];
if (!(curr & is_exist) && (prev & is_exist)) {
if (prev & is_mapped) {
fprintf(stderr, "UnmapNotify: %d/%d %d %.4f B tot=%d\n", prev, curr, win, dnowx(), totcnt);
if (0) fprintf(stderr, "UnmapNotify: %d/%d %d %.4f B tot=%d\n", prev, curr, win, dnowx(), totcnt);
macosx_add_mapnotify(win, lvl, 0);
}
/* DestroyNotify */
fprintf(stderr, "DestroNotify:%d/%d %d %.4f tot=%d\n", prev, curr, win, dnowx(), totcnt);
if (0) fprintf(stderr, "DestroNotify:%d/%d %d %.4f tot=%d\n", prev, curr, win, dnowx(), totcnt);
macosx_add_destroy(win, lvl);
}
}
......
--- vnc_unixsrc.orig/vncviewer/desktop.c 2004-05-28 13:29:29.000000000 -0400
+++ vnc_unixsrc/vncviewer/desktop.c 2006-07-27 11:30:01.000000000 -0400
+++ vnc_unixsrc/vncviewer/desktop.c 2007-01-13 13:59:51.000000000 -0500
@@ -50,6 +50,30 @@
},
};
......@@ -63,7 +63,7 @@
/*
* DesktopInitAfterRealization does things which require the X windows to
* exist. It creates some GCs and sets the dot cursor.
@@ -460,3 +463,69 @@
@@ -460,3 +463,70 @@
break;
}
}
......@@ -74,7 +74,8 @@
+ } else {
+ if (image && image->data) {
+ free(image->data);
+ XDestroyImage(image);
+ /* see manpage XDestroyImage may also free data, so we skip and have a tiny leak instead */
+ if (0) XDestroyImage(image);
+ image = NULL;
+ }
+ }
......
......@@ -9,6 +9,7 @@
int debug = 0;
char *use_dpy = NULL; /* -display */
int display_N = 0;
char *auth_file = NULL; /* -auth/-xauth */
char *visual_str = NULL; /* -visual */
int set_visual_str_to_something = 0;
......@@ -216,6 +217,8 @@ int ncache0 = 0;
int ncache_copyrect = 0;
int ncache_wf_raises = 1;
int ncache_dt_change = 1;
int ncache_keep_anims = 0;
int ncache_old_wm = 0;
int macosx_ncache_macmenu = 0;
int ncache_beta_tester = 0;
......
......@@ -9,6 +9,7 @@
extern int debug;
extern char *use_dpy;
extern int display_N;
extern char *auth_file;
extern char *visual_str;
extern int set_visual_str_to_something;
......@@ -163,6 +164,8 @@ extern int ncache_wf_raises;
extern int ncache_dt_change;
extern int ncache_pad;
extern int ncache_xrootpmap;
extern int ncache_keep_anims;
extern int ncache_old_wm;
extern int macosx_ncache_macmenu;
extern int ncache_beta_tester;
......
......@@ -5,8 +5,9 @@
#define ICON_MODE_SOCKS 16
/* had lw=3 for a long time */
#ifndef WIREFRAME_PARMS
#define WIREFRAME_PARMS "0xff,3,0,32+8+8+8,all,0.15+0.30+5.0+0.125"
#define WIREFRAME_PARMS "0xff,2,0,32+8+8+8,all,0.15+0.30+5.0+0.125"
#endif
#ifndef SCROLL_COPYRECT_PARMS
......@@ -40,6 +41,7 @@
#define PIPEINPUT_CONSOLE 0x2
#define PIPEINPUT_UINPUT 0x3
#define PIPEINPUT_MACOSX 0x4
#define PIPEINPUT_VNC 0x5
#define MAX_BUTTONS 5
......
......@@ -558,6 +558,8 @@ static void pipe_pointer(int mask, int x, int y, rfbClientPtr client) {
uinput_pointer_command(mask, x, y, client);
} else if (pipeinput_int == PIPEINPUT_MACOSX) {
macosx_pointer_command(mask, x, y, client);
} else if (pipeinput_int == PIPEINPUT_VNC) {
vnc_reflect_send_pointer(x, y, mask);
}
if (pipeinput_fh == NULL) {
return;
......@@ -679,6 +681,8 @@ void pointer(int mask, int x, int y, rfbClientPtr client) {
got_user_input++;
got_pointer_input++;
last_pointer_client = client;
last_pointer_time = dnow();
last_event = last_input = last_pointer_input = time(NULL);
}
if (input.motion) {
/* raw_fb hack track button state */
......@@ -994,6 +998,9 @@ if (0) fprintf(stderr, "initialize_pipeinput: %s -- %s\n", pipeinput_str, p);
} else if (strstr(p, "MACOSX") == p) {
pipeinput_int = PIPEINPUT_MACOSX;
return;
} else if (strstr(p, "VNC") == p) {
pipeinput_int = PIPEINPUT_VNC;
return;
}
set_child_info();
......
......@@ -2790,7 +2790,6 @@ char *process_remote_cmd(char *cmd, int stringonly) {
if (orig != ncache_xrootpmap) {
do_new_fb(1);
}
} else if (!strcmp(p, "noncache_no_rootpixmap")) {
int orig = ncache_xrootpmap;
if (query) {
......@@ -2813,6 +2812,38 @@ char *process_remote_cmd(char *cmd, int stringonly) {
set_ncache_xrootpmap();
}
} else if (!strcmp(p, "ncache_keep_anims")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, ncache_keep_anims);
goto qry;
}
kde_no_animate(0);
ncache_keep_anims = 1;
rfbLog("remote_cmd: set -ncache_keep_anims\n");
} else if (!strcmp(p, "noncache_keep_anims")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, !ncache_keep_anims);
goto qry;
}
ncache_keep_anims = 0;
kde_no_animate(1);
rfbLog("remote_cmd: disabled -ncache_keep_anims\n");
} else if (!strcmp(p, "ncache_old_wm")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, ncache_old_wm);
goto qry;
}
ncache_old_wm = 1;
rfbLog("remote_cmd: set -ncache_old_wm\n");
} else if (!strcmp(p, "noncache_old_wm")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, !ncache_old_wm);
goto qry;
}
ncache_old_wm = 0;
rfbLog("remote_cmd: disabled -ncache_old_wm\n");
} else if (!strcmp(p, "ncache")) {
if (query) {
snprintf(buf, bufn, "ans=%s:%d", p, !!ncache);
......
......@@ -3065,11 +3065,15 @@ int scan_for_updates(int count_only) {
/* first pass collecting DAMAGE events: */
#ifdef MACOSX
if (macosx_console) {
collect_macosx_damage(-1, -1, -1, -1, 0);
collect_non_X_xdamage(-1, -1, -1, -1, 0);
} else
#endif
{
collect_xdamage(scan_count, 0);
if (rawfb_vnc_reflect) {
collect_non_X_xdamage(-1, -1, -1, -1, 0);
} else {
collect_xdamage(scan_count, 0);
}
}
}
}
......@@ -3100,7 +3104,11 @@ int scan_for_updates(int count_only) {
} else
#endif
{
collect_xdamage(scan_count, 1);
if (rawfb_vnc_reflect) {
;
} else {
collect_xdamage(scan_count, 1);
}
}
}
if (count_only) {
......
This diff is collapsed.
......@@ -23,7 +23,14 @@ extern void initialize_screen(int *argc, char **argv, XImage *fb);
extern void set_vnc_desktop_name(void);
extern void announce(int lport, int ssl, char *iface);
extern char *vnc_reflect_guess(char *str, char **raw_fb_addr);
extern void vnc_reflect_process_client(void);
extern rfbBool vnc_reflect_send_pointer(int x, int y, int mask);
extern rfbBool vnc_reflect_send_key(uint32_t key, rfbBool down);
extern rfbBool vnc_reflect_send_cuttext(char *str, int len);
extern int rawfb_reset;
extern int rawfb_dev_video;
extern int rawfb_vnc_reflect;
#endif /* _X11VNC_SCREEN_H */
......@@ -67,7 +67,10 @@ static int dt_cmd(char *cmd) {
set_env("DISPLAY", DisplayString(dpy));
}
rfbLog("running command:\n %s\n", cmd);
rfbLog("running command:\n");
if (!quiet) {
fprintf(stderr, "\n %s\n\n", cmd);
}
usr_bin_path(0);
close_exec_fds();
rc = system(cmd);
......@@ -96,7 +99,10 @@ static char *cmd_output(char *cmd) {
return "";
}
rfbLog("running pipe:\n %s\n", cmd);
rfbLog("running pipe:\n");
if (!quiet) {
fprintf(stderr, "\n %s\n\n", cmd);
}
usr_bin_path(0);
close_exec_fds();
p = popen(cmd, "r");
......@@ -113,6 +119,28 @@ static char *cmd_output(char *cmd) {
return(output);
}
static char *last_color = NULL;
unsigned long get_pixel(char *color) {
#if NO_X11
return 0;
#else
XColor cdef;
Colormap cmap;
unsigned long pixel = BlackPixel(dpy, scr);
if (depth > 8 || strcmp(color, solid_default)) {
cmap = DefaultColormap (dpy, scr);
if (XParseColor(dpy, cmap, color, &cdef) &&
XAllocColor(dpy, cmap, &cdef)) {
pixel = cdef.pixel;
} else {
rfbLog("error parsing/allocing color: %s\n", color);
}
}
return pixel;
#endif
}
XImage *solid_root(char *color) {
#if NO_X11
RAWFB_RET_VOID
......@@ -126,7 +154,7 @@ XImage *solid_root(char *color) {
GC gc;
XSetWindowAttributes swa;
Visual visual;
unsigned long mask, pixel;
static unsigned long mask, pixel = 0;
XColor cdef;
Colormap cmap;
......@@ -148,8 +176,6 @@ XImage *solid_root(char *color) {
InputOutput, &visual, mask, &swa);
if (! color) {
/* restore the root window from the XImage snapshot */
pixmap = XCreatePixmap(dpy, window, wdpy_x, wdpy_y, depth);
if (! image) {
/* whoops */
......@@ -158,6 +184,8 @@ XImage *solid_root(char *color) {
return NULL;
}
/* restore the root window from the XImage snapshot */
pixmap = XCreatePixmap(dpy, window, wdpy_x, wdpy_y, depth);
/* draw the image to a pixmap: */
gcv.function = GXcopy;
......@@ -215,16 +243,7 @@ XImage *solid_root(char *color) {
}
/* use black for low colors or failure */
pixel = BlackPixel(dpy, scr);
if (depth > 8 || strcmp(color, solid_default)) {
cmap = DefaultColormap (dpy, scr);
if (XParseColor(dpy, cmap, color, &cdef) &&
XAllocColor(dpy, cmap, &cdef)) {
pixel = cdef.pixel;
} else {
rfbLog("error parsing/allocing color: %s\n", color);
}
}
pixel = get_pixel(color);
rfbLog("setting solid background...\n");
XSetWindowBackground(dpy, window, pixel);
......@@ -593,6 +612,100 @@ static void solid_gnome(char *color) {
#endif /* NO_X11 */
}
static char *dcop_session(void) {
#if NO_X11
RAWFB_RET("");
return "";
#else
char list_sessions[] = "dcop --user '%s' --list-sessions";
int len;
char *cmd, *host, *user = NULL;
char *out, *p, *ds, *dsn = NULL, *sess = NULL, *sess2 = NULL;
RAWFB_RET("");
if (getenv("SESSION_MANAGER")) {
return "";
}
user = get_user_name();
if (strstr(user, "'") != NULL) {
rfbLog("invalid user: %s\n", user);
free(user);
return "";
}
len = strlen(list_sessions) + strlen(user) + 1;
cmd = (char *) malloc(len);
sprintf(cmd, list_sessions, user);
out = strdup(cmd_output(cmd));
free(cmd);
free(user);
ds = DisplayString(dpy);
if (!ds || !strcmp(ds, "")) {
ds = getenv("DISPLAY");
}
if (!ds) {
ds = ":0";
}
ds = strdup(ds);
dsn = strchr(ds, ':');
if (dsn) {
*dsn = '_';
} else {
free(ds);
ds = strdup("_0");
dsn = ds;
}
host = this_host();
p = strtok(out, "\n");
while (p) {
char *q = strstr(p, ".DCOP");
if (q == NULL) {
;
} else if (host) {
if (strstr(q, host)) {
if(strstr(p, dsn)) {
sess = strdup(q);
break;
} else {
if (sess2) {
free(sess2);
}
sess2 = strdup(q);
}
}
} else {
if(strstr(p, dsn)) {
sess = strdup(q);
break;
}
}
p = strtok(NULL, "\n");
}
free(ds);
free(out);
if (!sess && sess2) {
sess = sess2;
}
if (!sess || strchr(sess, '\'')) {
if (sess) free(sess);
sess = strdup("--all-sessions");
} else {
len = strlen("--session ") + 2 + strlen(sess) + 1;
cmd = (char *) malloc(len);
sprintf(cmd, "--session '%s'", sess);
free(sess);
sess = cmd;
}
return sess;
#endif
}
static void solid_kde(char *color) {
#if NO_X11
RAWFB_RET_VOID
......@@ -600,12 +713,12 @@ static void solid_kde(char *color) {
return;
#else
char set_color[] =
"dcop --user '%s' kdesktop KBackgroundIface setColor '%s' 1";
"dcop --user '%s' %s kdesktop KBackgroundIface setColor '%s' 1";
char bg_off[] =
"dcop --user '%s' kdesktop KBackgroundIface setBackgroundEnabled 0";
"dcop --user '%s' %s kdesktop KBackgroundIface setBackgroundEnabled 0";
char bg_on[] =
"dcop --user '%s' kdesktop KBackgroundIface setBackgroundEnabled 1";
char *cmd, *user = NULL;
"dcop --user '%s' %s kdesktop KBackgroundIface setBackgroundEnabled 1";
char *cmd, *user = NULL, *sess;
int len;
RAWFB_RET_VOID
......@@ -617,13 +730,19 @@ static void solid_kde(char *color) {
return;
}
set_env("DISPLAY", DisplayString(dpy));
if (! color) {
len = strlen(bg_on) + strlen(user) + 1;
sess = dcop_session();
len = strlen(bg_on) + strlen(user) + strlen(sess) + 1;
cmd = (char *) malloc(len);
sprintf(cmd, bg_on, user);
sprintf(cmd, bg_on, user, sess);
dt_cmd(cmd);
free(cmd);
free(user);
free(sess);
return;
}
......@@ -633,21 +752,134 @@ static void solid_kde(char *color) {
return;
}
len = strlen(set_color) + strlen(user) + strlen(color) + 1;
sess = dcop_session();
len = strlen(set_color) + strlen(user) + strlen(sess) + strlen(color) + 1;
cmd = (char *) malloc(len);
sprintf(cmd, set_color, user, color);
sprintf(cmd, set_color, user, sess, color);
dt_cmd(cmd);
free(cmd);
len = strlen(bg_off) + strlen(user) + 1;
len = strlen(bg_off) + strlen(user) + strlen(sess) + 1;
cmd = (char *) malloc(len);
sprintf(cmd, bg_off, user);
sprintf(cmd, bg_off, user, sess);
dt_cmd(cmd);
free(cmd);
free(user);
#endif /* NO_X11 */
}
void kde_no_animate(int restore) {
#if NO_X11
if (!restore) {}
RAWFB_RET_VOID
return;
#else
char query_setting[] =
"kreadconfig --file kwinrc --group Windows --key AnimateMinimize";
char kwinrc_off[] =
"kwriteconfig --file kwinrc --group Windows --key AnimateMinimize --type bool false";
char kwinrc_on[] =
"kwriteconfig --file kwinrc --group Windows --key AnimateMinimize --type bool true";
char kwin_reconfigure[] =
"dcop --user '%s' %s kwin KWinInterface reconfigure";
char *cmd, *cmd2, *out, *user = NULL, *sess;
int len;
static int anim_state = 1;
RAWFB_RET_VOID
if (ncache_keep_anims) {
return;
}
if (restore) {
if (anim_state == 1) {
return;
}
user = get_user_name();
if (strstr(user, "'") != NULL) {
rfbLog("invalid user: %s\n", user);
free(user);
return;
}
sess = dcop_session();
len = strlen(kwin_reconfigure) + strlen(user) + strlen(sess) + 1;
cmd = (char *) malloc(len);
sprintf(cmd, kwin_reconfigure, user, sess);
rfbLog("\n");
rfbLog("Restoring KDE kwinrc settings.\n");
rfbLog("\n");
dt_cmd(cmd);
free(cmd);
free(user);
free(sess);
anim_state = 1;
return;
} else {
if (anim_state == 0) {
return;
}
anim_state = 0;
}
user = get_user_name();
if (strstr(user, "'") != NULL) {
rfbLog("invalid user: %s\n", user);
free(user);
return;
}
out = cmd_output(query_setting);
if (!out || strstr(out, "false")) {
rfbLog("\n");
rfbLog("********************************************************\n");
rfbLog("KDE kwinrc AnimateMinimize is false. Good.\n");
rfbLog("********************************************************\n");
rfbLog("\n");
free(user);
return;
}
rfbLog("\n");
rfbLog("********************************************************\n");
rfbLog("To improve the -ncache client-side caching performance\n");
rfbLog("temporarily setting KDE kwinrc AnimateMinimize to false.\n");
rfbLog("It will be reset for the next session or when VNC client\n");
rfbLog("disconnects. Or you can use the Control Center GUI to\n");
rfbLog("change it now (toggle its setting a few times):\n");
rfbLog(" Desktop -> Window Behavior -> Moving\n");
rfbLog("********************************************************\n");
rfbLog("\n");
set_env("DISPLAY", DisplayString(dpy));
sess = dcop_session();
len = strlen(kwin_reconfigure) + strlen(user) + strlen(sess) + 1;
cmd = (char *) malloc(len);
sprintf(cmd, kwin_reconfigure, user, sess);
len = 1 + strlen(kwinrc_off) + 2 + strlen(cmd) + 2 + strlen("sleep 5") + 2 + strlen(kwinrc_on) + 3 + 1;
cmd2 = (char *) malloc(len);
sprintf(cmd2, "(%s; %s; sleep 5; %s) &", kwinrc_off, cmd, kwinrc_on);
dt_cmd(cmd2);
free(cmd);
free(cmd2);
free(user);
free(sess);
#endif /* NO_X11 */
}
void gnome_no_animate(void) {
;
}
char *guess_desktop(void) {
#if NO_X11
RAWFB_RET("root")
......@@ -710,6 +942,42 @@ char *guess_desktop(void) {
#endif /* NO_X11 */
}
XImage *solid_image(char *color) {
#if NO_X11
RAWFB_RET(NULL)
return NULL;
#else
XImage *image = NULL;
unsigned long pixel = 0;
int x, y;
RAWFB_RET(NULL)
if (!color) {
color = last_color;
}
if (!color) {
return NULL;
}
image = XGetImage(dpy, rootwin, 0, 0, wdpy_x, wdpy_y, AllPlanes,
ZPixmap);
if (!image) {
return NULL;
}
pixel = get_pixel(color);
for (y=0; y<wdpy_y; y++) {
for (x=0; x<wdpy_x; x++) {
XPutPixel(image, x, y, pixel);
}
}
return image;
#endif /* NO_X11 */
}
void solid_bg(int restore) {
static int desktop = -1;
static int solid_on = 0;
......@@ -770,6 +1038,11 @@ void solid_bg(int restore) {
color = solid_default;
}
}
if (last_color) {
free(last_color);
}
last_color = strdup(color);
if (!strcmp(dtname, "gnome")) {
desktop = 1;
solid_gnome(color);
......
......@@ -4,7 +4,11 @@
/* -- solid.h -- */
extern char *guess_desktop(void);
extern unsigned long get_pixel(char *color);
extern XImage *solid_image(char *color);
extern void solid_bg(int restore);
extern XImage *solid_root(char *color);
extern void kde_no_animate(int restore);
extern void gnome_no_animate(void);
#endif /* _X11VNC_SOLID_H */
This diff is collapsed.
......@@ -135,6 +135,7 @@ Clients
Displays
=D display:
=F auth:
=S reflect:
=D desktop:
=D rfbport:
=0 gui:
......@@ -369,6 +370,7 @@ Tuning
ncache_no_moveraise
ncache_no_dtchange
ncache_no_rootpixmap
ncache_keep_anims
=A ncache_reset_rootpixmap
=GAL LOFF
--
......
......@@ -146,6 +146,7 @@ char gui_code[] = "";
"Displays\n"
" =D display:\n"
" =F auth:\n"
" =S reflect:\n"
" =D desktop:\n"
" =D rfbport:\n"
" =0 gui:\n"
......@@ -380,6 +381,7 @@ char gui_code[] = "";
" ncache_no_moveraise\n"
" ncache_no_dtchange\n"
" ncache_no_rootpixmap\n"
" ncache_keep_anims\n"
" =A ncache_reset_rootpixmap\n"
" =GAL LOFF\n"
" --\n"
......
......@@ -62,7 +62,7 @@ void unixpw_keystroke(rfbBool down, rfbKeySym keysym, int init);
void unixpw_accept(char *user);
void unixpw_deny(void);
void unixpw_msg(char *msg, int delay);
int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size);
int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size, int nodisp);
int crypt_verify(char *user, char *pass);
int cmd_verify(char *user, char *pass);
......@@ -552,7 +552,7 @@ int cmd_verify(char *user, char *pass) {
}
}
int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size) {
int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size, int nodisp) {
#ifndef UNIXPW_SU
return 0;
#else
......@@ -624,6 +624,7 @@ int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size) {
return 0;
}
if (db) fprintf(stderr, "cmd is: %s\n", cmd);
if (db) fprintf(stderr, "slave is: %s fd=%d\n", slave, fd);
if (fd < 0) {
......@@ -729,10 +730,19 @@ int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size) {
set_env("LC_ALL", "C");
set_env("LANG", "C");
set_env("SHELL", "/bin/sh");
if (!cmd && getenv("DISPLAY")) {
if (nodisp) {
/* this will cause timeout problems with pam_xauth */
char *s = getenv("DISPLAY");
if (s) *(s-2) = '_'; /* quite... */
int k;
for (k=0; k<3; k++) {
if (getenv("DISPLAY")) {
char *s = getenv("DISPLAY");
if (s) *(s-2) = '_'; /* quite... */
}
if (getenv("XAUTHORITY")) {
char *s = getenv("XAUTHORITY");
if (s) *(s-2) = '_'; /* quite... */
}
}
}
/* synchronize with parent: */
......@@ -874,6 +884,7 @@ int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size) {
return 0;
}
if (db > 2) fprintf(stderr, "\nsending passwd: %s\n", pass);
usleep(100 * 1000);
if (slow_pw) {
unsigned int k;
......@@ -899,6 +910,7 @@ int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size) {
drain_size = *rbuf_size;
rsize = 0;
}
if (db) fprintf(stderr, "\ndraining:\n");
for (i = 0; i< drain_size; i++) {
int n;
......@@ -907,12 +919,13 @@ int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size) {
n = read(fd, cbuf, 1);
if (n < 0 && errno == EINTR) {
if (db) fprintf(stderr, "\nEINTR n=%d i=%d --", n, i);
i--;
if (i < 0) i = 0;
continue;
}
if (db) fprintf(stderr, "%s", cbuf);
if (db) fprintf(stderr, "\nn=%d i=%d errno=%d %.6f '%s'", n, i, errno, dnowx(), cbuf);
if (n <= 0) {
break;
......@@ -921,6 +934,7 @@ int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size) {
rbuf[rsize++] = cbuf[0];
}
}
if (db && rbuf) fprintf(stderr, "\nrbuf: '%s'\n", rbuf);
if (rbuf && *rbuf_size > 0) {
char *s = rbuf;
......@@ -961,7 +975,7 @@ int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size) {
free(p);
}
if (db) fprintf(stderr, "\n");
if (db) fprintf(stderr, "\n--\n");
alarm(0);
signal(SIGALRM, SIG_DFL);
......@@ -1042,7 +1056,7 @@ if (db) fprintf(stderr, "unixpw_verify: '%s' '%s'\n", user, db > 1 ? pass : "***
ok = 0;
}
} else {
if (su_verify(user, pass, NULL, NULL, NULL)) {
if (su_verify(user, pass, NULL, NULL, NULL, 1)) {
rfbLog("unixpw_verify: su_verify login for '%s'"
" succeeded.\n", user);
ok = 1;
......
......@@ -9,7 +9,7 @@ extern void unixpw_keystroke(rfbBool down, rfbKeySym keysym, int init);
extern void unixpw_accept(char *user);
extern void unixpw_deny(void);
extern void unixpw_msg(char *msg, int delay);
extern int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size);
extern int su_verify(char *user, char *pass, char *cmd, char *rbuf, int *rbuf_size, int nodisp);
extern int crypt_verify(char *user, char *pass);
extern int cmd_verify(char *user, char *pass);
......
......@@ -1241,6 +1241,10 @@ int wait_for_client(int *argc, char** argv, int http) {
return 0;
}
if (getenv("WAIT_FOR_CLIENT_DB")) {
db = 1;
}
for (i=0; i < *argc; i++) {
if (!strcmp(argv[i], "-desktop")) {
dt = 1;
......@@ -1435,6 +1439,7 @@ int wait_for_client(int *argc, char** argv, int http) {
char line2[16384];
char *q;
int n;
int nodisp = 0;
memset(line1, 0, 1024);
memset(line2, 0, 16384);
......@@ -1447,9 +1452,10 @@ int wait_for_client(int *argc, char** argv, int http) {
rfbLogPerror("mkstemp");
clean_up_exit(1);
}
chmod(tmp, 0644);
write(tmp_fd, find_display, strlen(find_display));
close(tmp_fd);
chmod(tmp, 0644);
nodisp = 1;
if (strstr(cmd, "FINDCREATEDISPLAY") == cmd) {
char *opts = strchr(cmd, '-');
......@@ -1487,10 +1493,10 @@ if (db) fprintf(stderr, "create_cmd: %s\n", create_cmd);
if (keep_unixpw_user && keep_unixpw_pass) {
n = 18000;
res = su_verify(keep_unixpw_user,
keep_unixpw_pass, cmd, line, &n);
keep_unixpw_pass, cmd, line, &n, nodisp);
}
if (db) write(2, line, n); write(2, "\n", 1);
if (db) {fprintf(stderr, "line: "); write(2, line, n); write(2, "\n", 1); fprintf(stderr, "res=%d n=%d\n", res, n);}
if (! res && create_cmd) {
FILE *mt = fopen(tmp, "w");
......@@ -1506,7 +1512,7 @@ if (db) write(2, line, n); write(2, "\n", 1);
/* if not root, run as the other user... */
n = 18000;
res = su_verify(keep_unixpw_user,
keep_unixpw_pass, create_cmd, line, &n);
keep_unixpw_pass, create_cmd, line, &n, nodisp);
/*if (1) fprintf(stderr, "line: '%s'\n", line); */
} else {
......@@ -1576,8 +1582,8 @@ if (db) fprintf(stderr, "line1: '%s'\n", line1);
line2[i] = q[k+j];
i++;
}
write(2, line, 100);
fprintf(stderr, "\n");
if (db) write(2, line, 100);
if (db) fprintf(stderr, "\n");
} else {
FILE *p;
int rc;
......@@ -1641,6 +1647,7 @@ fprintf(stderr, "\n");
}
}
if (db) fprintf(stderr, "line1=%s\n", line1);
if (strstr(line1, "DISPLAY=") != line1) {
rfbLog("wait_for_client: bad reply '%s'\n", line1);
......@@ -1648,6 +1655,7 @@ fprintf(stderr, "\n");
clean_up_exit(1);
}
if (strstr(line1, ",VT=")) {
int vt;
char *t = strstr(line1, ",VT=");
......@@ -1660,6 +1668,41 @@ fprintf(stderr, "\n");
system(chvt);
sleep(2);
}
} else if (strstr(line1, ",XPID=")) {
int i, pvt, vt = -1;
char *t = strstr(line1, ",XPID=");
pvt = atoi(t + strlen(",XPID="));
*t = '\0';
if (pvt > 0) {
for (i=3; i <= 10; i++) {
int k;
char proc[100];
char buf[100];
sprintf(proc, "/proc/%d/fd/%d", pvt, i);
if (db) fprintf(stderr, "%d -- %s\n", i, proc);
for (k=0; k < 100; k++) {
buf[k] = '\0';
}
if (readlink(proc, buf, 100) != -1) {
buf[100-1] = '\0';
if (db) fprintf(stderr, "%d -- %s -- %s\n", i, proc, buf);
if (strstr(buf, "/dev/tty") == buf) {
vt = atoi(buf + strlen("/dev/tty"));
if (vt > 0) {
break;
}
}
}
}
}
if (7 <= vt && vt <= 128) {
char chvt[100];
sprintf(chvt, "chvt %d >/dev/null 2>/dev/null &", vt);
rfbLog("running: %s\n", chvt);
system(chvt);
sleep(2);
}
}
use_dpy = strdup(line1 + strlen("DISPLAY="));
......
This diff is collapsed.
......@@ -287,6 +287,8 @@ char *this_host(void) {
if (gethostname(host, MAXN) == 0) {
host[MAXN-1] = '\0';
return strdup(host);
} else if (UT.nodename) {
return strdup(UT.nodename);
}
#endif
return NULL;
......
This diff is collapsed.
......@@ -582,6 +582,14 @@ static void watch_loop(void) {
}
}
if (rawfb_vnc_reflect) {
static time_t lastone = 0;
if (time(NULL) > lastone + 10) {
lastone = time(NULL);
vnc_reflect_process_client();
}
}
if (! screen || ! screen->clientHead) {
/* waiting for a client */
if (first_conn_timeout) {
......@@ -633,6 +641,10 @@ static void watch_loop(void) {
}
if (unixpw_in_progress) continue;
if (rawfb_vnc_reflect) {
vnc_reflect_process_client();
}
dtime0(&tm);
if (use_snapfb) {
int t, tries = 3;
......@@ -1072,7 +1084,7 @@ static void quick_pw(char *str) {
exit(1);
}
} else {
if (su_verify(p, q+1, NULL, NULL, NULL)) {
if (su_verify(p, q+1, NULL, NULL, NULL, 1)) {
fprintf(stdout, "Y %s\n", p);
exit(0);
} else {
......@@ -1461,7 +1473,7 @@ char msg[] =
"perhaps even report back your observations. However, if you do not want\n"
"to test or use the feature, run x11vnc like this:\n"
"\n"
" x11vnc -ncache 0 ...\n"
" x11vnc -noncache ...\n"
"\n"
"Your current setting is: -ncache %d\n"
"\n"
......@@ -1517,6 +1529,7 @@ int main(int argc, char* argv[]) {
int got_rfbwait = 0;
int got_httpdir = 0, try_http = 0;
int waited_for_client = 0;
int orig_use_xdamage = use_xdamage;
XImage *fb0 = NULL;
/* used to pass args we do not know about to rfbGetScreen(): */
......@@ -1644,6 +1657,13 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(arg, "-auth") || !strcmp(arg, "-xauth")) {
CHECK_ARGC
auth_file = strdup(argv[++i]);
} else if (!strcmp(arg, "-N")) {
display_N = 1;
} else if (!strcmp(arg, "-reflect")) {
CHECK_ARGC
raw_fb_str = (char *) malloc(4 + strlen(argv[i]) + 1);
sprintf(raw_fb_str, "vnc:%s", argv[++i]);
shared = 1;
} else if (!strcmp(arg, "-id") || !strcmp(arg, "-sid")) {
CHECK_ARGC
if (!strcmp(arg, "-sid")) {
......@@ -1716,6 +1736,8 @@ int main(int argc, char* argv[]) {
got_noviewonly = 1;
} else if (!strcmp(arg, "-shared")) {
shared = 1;
} else if (!strcmp(arg, "-noshared")) {
shared = 0;
} else if (!strcmp(arg, "-once")) {
connect_once = 1;
got_connect_once = 1;
......@@ -2159,21 +2181,27 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(arg, "-nodragging")) {
show_dragging = 0;
#ifndef NO_NCACHE
} else if (!strcmp(arg, "-ncache")) {
} else if (!strcmp(arg, "-ncache") || !strcmp(arg, "-nc")) {
CHECK_ARGC
ncache = atoi(argv[++i]);
if (ncache % 2 != 0) {
ncache++;
}
} else if (!strcmp(arg, "-ncache_cr")) {
} else if (!strcmp(arg, "-noncache") || !strcmp(arg, "-nonc")) {
ncache = 0;
} else if (!strcmp(arg, "-ncache_cr") || !strcmp(arg, "-nc_cr")) {
ncache_copyrect = 1;
} else if (!strcmp(arg, "-ncache_no_moveraise")) {
} else if (!strcmp(arg, "-ncache_no_moveraise") || !strcmp(arg, "-nc_no_moveraise")) {
ncache_wf_raises = 1;
} else if (!strcmp(arg, "-ncache_no_dtchange")) {
} else if (!strcmp(arg, "-ncache_no_dtchange") || !strcmp(arg, "-nc_no_dtchange")) {
ncache_dt_change = 0;
} else if (!strcmp(arg, "-ncache_no_rootpixmap")) {
} else if (!strcmp(arg, "-ncache_no_rootpixmap") || !strcmp(arg, "-nc_no_rootpixmap")) {
ncache_xrootpmap = 0;
} else if (!strcmp(arg, "-ncache_pad")) {
} else if (!strcmp(arg, "-ncache_keep_anims") || !strcmp(arg, "-nc_keep_anims")) {
ncache_keep_anims = 1;
} else if (!strcmp(arg, "-ncache_old_wm") || !strcmp(arg, "-nc_old_wm")) {
ncache_old_wm = 1;
} else if (!strcmp(arg, "-ncache_pad") || !strcmp(arg, "-nc_pad")) {
CHECK_ARGC
ncache_pad = atoi(argv[++i]);
#endif
......@@ -2281,6 +2309,8 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(arg, "-debug_keyboard")
|| !strcmp(arg, "-dk")) {
debug_keyboard++;
} else if (!strcmp(arg, "-debug_xdamage")) {
debug_xdamage++;
} else if (!strcmp(arg, "-defer")) {
CHECK_ARGC
defer_update = atoi(argv[++i]);
......@@ -2375,6 +2405,9 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(arg, "-rawfb")) {
CHECK_ARGC
raw_fb_str = strdup(argv[++i]);
if (strstr(raw_fb_str, "vnc:") == raw_fb_str) {
shared = 1;
}
} else if (!strcmp(arg, "-freqtab")) {
CHECK_ARGC
freqtab = strdup(argv[++i]);
......@@ -2527,6 +2560,7 @@ int main(int argc, char* argv[]) {
}
}
orig_use_xdamage = use_xdamage;
if (getenv("X11VNC_LOOP_MODE")) {
if (bg) {
......@@ -3067,6 +3101,34 @@ int main(int argc, char* argv[]) {
initialize_allowed_input();
if (display_N && !got_rfbport) {
char *ud = use_dpy;
if (ud == NULL) {
ud = getenv("DISPLAY");
}
if (ud && strstr(ud, "cmd=") == NULL) {
char *p;
ud = strdup(ud);
p = strrchr(ud, ':');
if (p) {
int N;
char *q = strchr(p, '.');
if (q) {
*q = '\0';
}
N = atoi(p+1);
if (argc_vnc+1 < argc_vnc_max) {
char Nstr[16];
sprintf(Nstr, "%d", (5900 + N) % 65536);
argv_vnc[argc_vnc++] = strdup("-rfbport");
argv_vnc[argc_vnc++] = strdup(Nstr);
got_rfbport = 1;
}
}
free(ud);
}
}
if (users_list && strstr(users_list, "lurk=")) {
if (use_dpy) {
rfbLog("warning: -display does not make sense in "
......@@ -3094,6 +3156,7 @@ int main(int argc, char* argv[]) {
dpy = XOpenDisplay_wr("");
}
#ifdef MACOSX
if (! dpy && ! raw_fb_str) {
raw_fb_str = strdup("console");
......@@ -3497,21 +3560,29 @@ int main(int argc, char* argv[]) {
raw_fb_pass_go_and_collect_200_dollars:
#ifdef MACOSX
if (! dpy) {
if (! dpy || raw_fb_str) {
int doit = 0;
/* XXX this needs improvement (esp. for remote control) */
if (! raw_fb_str || strstr(raw_fb_str, "console") == raw_fb_str) {
#ifdef MACOSX
doit = 1;
#endif
}
if (raw_fb_str && strstr(raw_fb_str, "vnc") == raw_fb_str) {
doit = 1;
}
if (doit) {
if (! multiple_cursors_mode) {
multiple_cursors_mode = strdup("most");
}
initialize_cursors_mode();
use_xdamage = orig_use_xdamage;
if (use_xdamage) {
xdamage_present = 1;
initialize_xdamage();
}
}
}
#endif
if (! dt) {
static char str[] = "-desktop";
......
......@@ -137,6 +137,7 @@
/* these are for delaying features: */
#define xxNO_SSL_OR_UNIXPW
#define xxNO_NCACHE
#define NO_NCACHE
/*
* Beginning of support for small binary footprint build for embedded
......
......@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.8.4 lastmod: 2007-01-10";
char lastmod[] = "0.8.4 lastmod: 2007-01-31";
/* X display info */
......@@ -110,14 +110,14 @@ int scale_cursor_numer = 0, scale_cursor_denom = 0;
/* size of the basic tile unit that is polled for changes: */
int tile_x = 32;
int tile_y = 32;
int ntiles, ntiles_x, ntiles_y;
int ntiles, ntiles_x = 0, ntiles_y = 0;
/* arrays that indicate changed or checked tiles. */
unsigned char *tile_has_diff = NULL, *tile_tried = NULL, *tile_copied = NULL;
unsigned char *tile_has_xdamage_diff = NULL, *tile_row_has_xdamage_diff = NULL;
/* times of recent events */
time_t last_event, last_input = 0, last_client = 0;
time_t last_event = 0, last_input = 0, last_client = 0;
time_t last_local_input = 0;
time_t last_keyboard_input = 0, last_pointer_input = 0;
time_t last_fb_bytes_sent = 0;
......
......@@ -8,6 +8,7 @@
#if LIBVNCSERVER_HAVE_LIBXDAMAGE
Damage xdamage = 0;
#endif
#ifndef XDAMAGE
#define XDAMAGE 1
#endif
......@@ -30,7 +31,7 @@ int XD_skip = 0, XD_tot = 0, XD_des = 0; /* for stats */
void add_region_xdamage(sraRegionPtr new_region);
void clear_xdamage_mark_region(sraRegionPtr markregion, int flush);
int collect_macosx_damage(int x_in, int y_in, int w_in, int h_in, int call);
int collect_non_X_xdamage(int x_in, int y_in, int w_in, int h_in, int call);
int collect_xdamage(int scancnt, int call);
int xdamage_hint_skip(int y);
void initialize_xdamage(void);
......@@ -118,6 +119,11 @@ static void record_desired_xdamage_rect(int x, int y, int w, int h) {
xdamage_direct_count++;
X_LOCK;
} else {
if (ntiles_x == 0 || ntiles_y == 0) {
/* too early. */
return;
}
nt_x1 = nfix( (x)/tile_x, ntiles_x);
nt_x2 = nfix((x+w)/tile_x, ntiles_x);
nt_y1 = nfix( (y)/tile_y, ntiles_y);
......@@ -217,7 +223,7 @@ void clear_xdamage_mark_region(sraRegionPtr markregion, int flush) {
#endif
}
int collect_macosx_damage(int x_in, int y_in, int w_in, int h_in, int call) {
int collect_non_X_xdamage(int x_in, int y_in, int w_in, int h_in, int call) {
sraRegionPtr tmpregion;
sraRegionPtr reg;
static int rect_count = 0;
......@@ -227,7 +233,7 @@ int collect_macosx_damage(int x_in, int y_in, int w_in, int h_in, int call) {
double tm, dt;
int x, y, w, h, x2, y2;
if (call && debug_xdamage > 1) fprintf(stderr, "collect_macosx_damage: %d %d %d %d - %d / %d\n", x_in, y_in, w_in, h_in, call, use_xdamage);
if (call && debug_xdamage > 1) fprintf(stderr, "collect_non_X_xdamage: %d %d %d %d - %d / %d\n", x_in, y_in, w_in, h_in, call, use_xdamage);
if (! use_xdamage) {
return 0;
......@@ -248,6 +254,9 @@ if (call && debug_xdamage > 1) fprintf(stderr, "collect_macosx_damage: %d %d %d
sraRgnMakeEmpty(reg);
}
} else {
if (xdamage_ticker < 0) {
xdamage_ticker = 0;
}
reg = xdamage_regions[xdamage_ticker];
}
if (reg == NULL) {
......@@ -315,7 +324,7 @@ if (call && debug_xdamage > 1) fprintf(stderr, "collect_macosx_damage: %d %d %d
dt = dtime(&tm);
if ((debug_tiles > 1 && ecount) || (debug_tiles && ecount > 200)
|| debug_xdamage > 1) {
fprintf(stderr, "collect_macosx_damage(%d): %.4f t: %.4f ev/dup/accept"
fprintf(stderr, "collect_non_X_xdamage(%d): %.4f t: %.4f ev/dup/accept"
"/direct %d/%d/%d/%d\n", call, dt, tm - x11vnc_start, ecount,
dcount, ccount, xdamage_direct_count);
}
......@@ -389,6 +398,9 @@ int collect_xdamage(int scancnt, int call) {
sraRgnMakeEmpty(reg);
}
} else {
if (xdamage_ticker < 0) {
xdamage_ticker = 0;
}
reg = xdamage_regions[xdamage_ticker];
}
if (reg == NULL) {
......
......@@ -19,7 +19,7 @@ extern int XD_skip, XD_tot, XD_des;
extern void add_region_xdamage(sraRegionPtr new_region);
extern void clear_xdamage_mark_region(sraRegionPtr markregion, int flush);
extern int collect_macosx_damage(int x_in, int y_in, int w_in, int h_in, int call);
extern int collect_non_X_xdamage(int x_in, int y_in, int w_in, int h_in, int call);
extern int collect_xdamage(int scancnt, int call);
extern int xdamage_hint_skip(int y);
extern void initialize_xdamage(void);
......
......@@ -1152,6 +1152,7 @@ void check_xevents(int reset) {
#endif /* NO_X11 */
}
extern int rawfb_vnc_reflect;
/*
* hook called when a VNC client sends us some "XCut" text (rfbClientCutText).
*/
......@@ -1188,6 +1189,11 @@ void xcut_receive(char *text, int len, rfbClientPtr cl) {
}
#endif
if (rawfb_vnc_reflect) {
vnc_reflect_send_cuttext(text, len);
return;
}
RAWFB_RET_VOID
#if NO_X11
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment