Commit 596331a5 authored by runge's avatar runge

x11vnc: Use opengl to read screen on macosx. non-deprecated macosx interfaces for input injection.

parent 0c03b989
......@@ -90,6 +90,7 @@ AH_TEMPLATE(HAVE_LINUX_FB_H, [linux fb device build environment present])
AH_TEMPLATE(HAVE_LINUX_INPUT_H, [linux/input.h present])
AH_TEMPLATE(HAVE_LINUX_UINPUT_H, [linux uinput device build environment present])
AH_TEMPLATE(HAVE_MACOSX_NATIVE_DISPLAY, [build MacOS X native display support])
AH_TEMPLATE(HAVE_MACOSX_OPENGL_H, [MacOS X OpenGL present])
AC_ARG_WITH(xkeyboard,
[ --without-xkeyboard disable xkeyboard extension support],,)
......@@ -399,6 +400,10 @@ if test "x$with_macosx_native" != "xno"; then
AC_DEFINE(HAVE_MACOSX_NATIVE_DISPLAY)
fi
# Check for OS X opengl header
AC_CHECK_HEADER(OpenGL/OpenGL.h,
[AC_DEFINE(HAVE_MACOSX_OPENGL_H) HAVE_MACOSX_OPENGL_H="true"],,)
AH_TEMPLATE(HAVE_AVAHI, [Avahi/mDNS client build environment present])
AC_ARG_WITH(avahi,
[ --without-avahi disable support for Avahi/mDNS]
......@@ -429,6 +434,9 @@ fi
fi
# end x11vnc only.
# only used in x11vnc/Makefile.am but needs to always be defined:
AM_CONDITIONAL(OSX_OPENGL, test "$HAVE_MACOSX_OPENGL_H" = "true")
# Checks for libraries.
if test ! -z "$with_system_libvncserver" -a "x$with_system_libvncserver" != "xno"; then
......
2010-12-29 Karl Runge <runge@karlrunge.com>
* x11vnc: Use opengl to read screen on macosx. Experimental
use of non-deprecated macosx interfaces for input injection.
Fix cursors for 64bit macosx. Add -unixsock option. Work around
grep issue on OpenBSD in create_display.
2010-12-21 Karl Runge <runge@karlrunge.com>
* x11vnc: Add RELEASE-NOTES. Call shutdown_uinput() when exiting.
Free some minor memory. Do not use GetMainDevice() on macosx.
......
......@@ -5,7 +5,15 @@ LDADD = ../libvncserver/libvncserver.la ../libvncclient/libvncclient.la @WSOCKLI
endif
if OSX
x11vnc_LDFLAGS = -framework ApplicationServices -framework Carbon -framework IOKit -framework Cocoa
FRAMEWORKS = -framework ApplicationServices -framework Carbon -framework IOKit -framework Cocoa
if OSX_OPENGL
FRAMEWORKS += -framework OpenGL
if HAVE_X11
GL = /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
FRAMEWORKS += -dylib_file $(GL):$(GL)
endif
endif
x11vnc_LDFLAGS = $(FRAMEWORKS)
x11vnc_CFLAGS = -ObjC
endif
......@@ -23,7 +31,7 @@ LD_CYGIPC=-lcygipc
endif
bin_PROGRAMS=x11vnc
x11vnc_SOURCES = 8to24.c appshare.c avahi.c cleanup.c connections.c cursor.c gui.c help.c inet.c keyboard.c linuxfb.c macosx.c macosxCG.c macosxCGP.c macosxCGS.c options.c pm.c pointer.c rates.c remote.c scan.c screen.c selection.c solid.c sslcmds.c sslhelper.c uinput.c unixpw.c user.c userinput.c util.c v4l.c win_utils.c x11vnc.c x11vnc_defs.c xdamage.c xevents.c xinerama.c xkb_bell.c xrandr.c xrecord.c xwrappers.c 8to24.h allowed_input_t.h avahi.h blackout_t.h cleanup.h connections.h cursor.h enc.h enums.h gui.h help.h inet.h keyboard.h linuxfb.h macosx.h macosxCG.h macosxCGP.h macosxCGS.h nox11.h nox11_funcs.h options.h params.h pm.h pointer.h rates.h remote.h scan.h screen.h scrollevent_t.h selection.h solid.h sslcmds.h sslhelper.h ssltools.h tkx11vnc.h uinput.h unixpw.h user.h userinput.h util.h v4l.h win_utils.h winattr_t.h x11vnc.h xdamage.h xevents.h xinerama.h xkb_bell.h xrandr.h xrecord.h xwrappers.h
x11vnc_SOURCES = 8to24.c appshare.c avahi.c cleanup.c connections.c cursor.c gui.c help.c inet.c keyboard.c linuxfb.c macosx.c macosxCG.c macosxCGP.c macosxCGS.c macosx_opengl.c options.c pm.c pointer.c rates.c remote.c scan.c screen.c selection.c solid.c sslcmds.c sslhelper.c uinput.c unixpw.c user.c userinput.c util.c v4l.c win_utils.c x11vnc.c x11vnc_defs.c xdamage.c xevents.c xinerama.c xkb_bell.c xrandr.c xrecord.c xwrappers.c 8to24.h allowed_input_t.h avahi.h blackout_t.h cleanup.h connections.h cursor.h enc.h enums.h gui.h help.h inet.h keyboard.h linuxfb.h macosx.h macosxCG.h macosxCGP.h macosxCGS.h macosx_opengl.h nox11.h nox11_funcs.h options.h params.h pm.h pointer.h rates.h remote.h scan.h screen.h scrollevent_t.h selection.h solid.h sslcmds.h sslhelper.h ssltools.h tkx11vnc.h uinput.h unixpw.h user.h userinput.h util.h v4l.h win_utils.h winattr_t.h x11vnc.h xdamage.h xevents.h xinerama.h xkb_bell.h xrandr.h xrecord.h xwrappers.h
if HAVE_SYSTEM_LIBVNCSERVER
INCLUDES_LIBVNCSERVER = @SYSTEM_LIBVNCSERVER_CFLAGS@
......
This diff is collapsed.
......@@ -399,7 +399,6 @@ if (db) fprintf(stderr, "out avahi_reset\n");
}
static void avahi_timeout (int sig) {
int i;
rfbLog("sig: %d, avahi_cleanup timed out.\n", sig);
exit(1);
}
......
......@@ -190,6 +190,15 @@ void clean_up_exit(int ret) {
shutdown_uinput();
if (unix_sock) {
if (unix_sock_fd >= 0) {
rfbLog("deleting unix sock: %s\n", unix_sock);
close(unix_sock_fd);
unix_sock_fd = -1;
unlink(unix_sock);
}
}
if (! dpy) { /* raw_rb hack */
if (rm_flagfile) {
unlink(rm_flagfile);
......
......@@ -93,6 +93,7 @@ void adjust_grabs(int grab, int quiet);
void check_new_clients(void);
int accept_client(rfbClientPtr client);
void check_ipv6_listen(long usec);
void check_unix_sock(long usec);
int run_user_command(char *cmd, rfbClientPtr client, char *mode, char *input,
int len, FILE *output);
int check_access(char *addr);
......@@ -1837,6 +1838,69 @@ void check_ipv6_listen(long usec) {
if (usec) {}
}
void check_unix_sock(long usec) {
fd_set fds;
struct timeval tv;
int nfds, csock = -1;
rfbClientPtr cl;
int nmax = 0;
char *name;
if (!unix_sock || unix_sock_fd < 0) {
return;
}
FD_ZERO(&fds);
if (unix_sock_fd >= 0) {
FD_SET(unix_sock_fd, &fds);
nmax = unix_sock_fd;
}
tv.tv_sec = 0;
tv.tv_usec = 0;
nfds = select(nmax+1, &fds, NULL, NULL, &tv);
if (nfds <= 0) {
return;
}
if (unix_sock_fd >= 0 && FD_ISSET(unix_sock_fd, &fds)) {
csock = accept_unix(unix_sock_fd);
if (csock < 0) {
return;
}
if (fcntl(csock, F_SETFL, O_NONBLOCK) < 0) {
rfbLogPerror("check_unix_sock: fcntl");
close(csock);
return;
}
/* rfbNewClient() will screw us with setsockopt TCP_NODELAY...
you need to comment out in libvncserver/rfbserver.c:
rfbLogPerror("setsockopt failed");
close(sock);
return NULL;
*/
cl = rfbNewClient(screen, csock);
if (cl == NULL) {
close(csock);
return;
}
name = strdup(unix_sock);
if (name) {
if (cl->host) {
free(cl->host);
}
cl->host = name;
rfbLog("unix sock client: %s\n", name);
}
}
}
/*
* For the -connect <file> option: periodically read the file looking for
* a connect string. If one is found set client_connect to it.
......
......@@ -69,6 +69,7 @@ extern void adjust_grabs(int grab, int quiet);
extern void check_new_clients(void);
extern int accept_client(rfbClientPtr client);
extern void check_ipv6_listen(long usec);
extern void check_unix_sock(long usec);
extern int run_user_command(char *cmd, rfbClientPtr client, char *mode, char *input,
int len, FILE *output);
extern int check_access(char *addr);
......
......@@ -810,6 +810,20 @@ void print_help(int mode) {
" IPv6: if IPv6 is supported, this option automatically\n"
" implies the IPv6 loopback address '::1' as well.\n"
"\n"
"-unixsock str Listen on the unix socket (AF_UNIX) 'str'\n"
" for connections. This mode is for either local\n"
" connections or a tunnel endpoint where one wants the\n"
" file permission of the unix socket file to determine\n"
" what can connect to it. (This currently requires an\n"
" edit to libvnserver/rfbserver.c: comment out lines 310\n"
" and 311, 'close(sock)' and 'return NULL' in rfbserver.c\n"
" after the setsockopt() call.) Note that to disable all\n"
" tcp listening ports specify '-rfbport 0' and should be\n"
" useful with this mode. Example:\n"
" mkdir ~/s; chmod 700 ~/s;\n"
" x11vnc -unixsock ~/s/mysock -rfbport 0 ...\n"
" The SSVNC unix vncviewer can connect to unix sockets.\n"
"\n"
#if X11VNC_IPV6
"-listen6 str When in IPv6 listen mode \"-6\", listen only on the\n"
" network interface with address \"str\". It also works\n"
......@@ -4851,6 +4865,42 @@ void print_help(int mode) {
" because they have animated fades, etc.)\n"
"-macuskbd For the native MacOSX server, use the original\n"
" keystroke insertion code based on a US keyboard.\n"
"-macnoopengl For the native MacOSX server, do not use OpenGL for\n"
" screen capture, but rather use the original, deprecated\n"
" raw memory access method: addr = CGDisplayBaseAddress().\n"
"-macnorawfb For the native MacOSX server, disable the raw memory\n"
" address screen capture method.\n"
"\n"
" MACOSX NOTE: There are some deprecated MacOSX interfaces\n"
" to inject keyboard and mouse events and the raw memory\n"
" access method is deprecated as well (however, OpenGL\n"
" will be preferred if available because it is faster.)\n"
" One can force not using any deprecated interfaces at\n"
" compile time by setting -DX11VNC_MACOSX_NO_DEPRECATED=1\n"
" in CPPFLAGS. Or to turn them off one by one:\n"
" -DX11VNC_MACOSX_NO_DEPRECATED_LOCALEVENTS=1,\n"
" -DX11VNC_MACOSX_NO_DEPRECATED_POSTEVENTS=1 or\n"
" -DX11VNC_MACOSX_NO_DEPRECATED_FRAMEBUFFER=1\n"
" At run time, for testing and workarounds, one can\n"
" disable them by using:\n"
" -env X11VNC_MACOSX_NO_DEPRECATED=1\n"
" -env X11VNC_MACOSX_NO_DEPRECATED_LOCALEVENTS=1\n"
" -env X11VNC_MACOSX_NO_DEPRECATED_POSTEVENTS=1 or\n"
" -env X11VNC_MACOSX_NO_DEPRECATED_FRAMEBUFFER=1\n"
" Note: When doing either of these for the mouse input\n"
" not everything works currently, e.g. double clicks and\n"
" wireframing. Also, screen resolution and pixel depth\n"
" changes will not be automatically detected unless the\n"
" deprecated framebuffer interfaces are allowed.\n"
"\n"
" Conversely, if you are compiling on an\n"
" older machine that does not have some of\n"
" the newer interfaces, you may need to specify\n"
" -DX11VNC_MACOSX_NO_CGEVENTCREATESCROLLWHEELEVENT\n"
" -DX11VNC_MACOSX_NO_CGEVENTCREATEMOUSEEVENT or\n"
" -DX11VNC_MACOSX_NO_CGEVENTCREATEKEYBOARDEVENT. Use\n"
" -DX11VNC_MACOSX_USE_GETMAINDEVICE to regain the very\n"
" old QuickDraw GetMainDevice() interface (rare...)\n"
"\n"
"-gui [gui-opts] Start up a simple tcl/tk gui based on the remote\n"
" control options -remote/-query described below.\n"
......
......@@ -57,6 +57,8 @@ int have_ssh_env(void);
char *ipv6_getnameinfo(struct sockaddr *paddr, int addrlen);
char *ipv6_getipaddr(struct sockaddr *paddr, int addrlen);
int listen6(int port);
int listen_unix(char *file);
int accept_unix(int s);
int connect_tcp(char *host, int port);
int listen_tcp(int port, in_addr_t iface, int try6);
......@@ -652,6 +654,62 @@ int listen6(int port) {
#endif
}
#ifdef LIBVNCSERVER_HAVE_SYS_SOCKET_H
#include <sys/un.h>
#endif
int listen_unix(char *file) {
#if !defined(AF_UNIX) || !defined(LIBVNCSERVER_HAVE_SYS_SOCKET_H)
if (sock) {}
return -1;
#else
int s, len;
struct sockaddr_un saun;
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
rfbLogPerror("listen_unix: socket");
return -1;
}
saun.sun_family = AF_UNIX;
strcpy(saun.sun_path, file);
unlink(file);
len = sizeof(saun.sun_family) + strlen(saun.sun_path);
if (bind(s, (struct sockaddr *)&saun, len) < 0) {
rfbLogPerror("listen_unix: bind");
close(s);
return -1;
}
if (listen(s, 32) < 0) {
rfbLogPerror("listen_unix: listen");
close(s);
return -1;
}
rfbLog("listening on unix socket: %s fd=%d\n", file, s);
return s;
#endif
}
int accept_unix(int s) {
#if !defined(AF_UNIX) || !defined(LIBVNCSERVER_HAVE_SYS_SOCKET_H)
if (s) {}
return -1;
#else
int fd, fromlen;
struct sockaddr_un fsaun;
fd = accept(s, (struct sockaddr *)&fsaun, &fromlen);
if (fd < 0) {
rfbLogPerror("accept_unix: accept");
return -1;
}
return fd;
#endif
}
int connect_tcp(char *host, int port) {
double t0 = dnow();
int fd = -1;
......
......@@ -52,6 +52,8 @@ extern int have_ssh_env(void);
extern char *ipv6_getnameinfo(struct sockaddr *paddr, int addrlen);
extern char *ipv6_getipaddr(struct sockaddr *paddr, int addrlen);
extern int listen6(int port);
extern int listen_unix(char *file);
extern int accept_unix(int s);
extern int connect_tcp(char *host, int port);
extern int listen_tcp(int port, in_addr_t iface, int try6);
......
......@@ -149,8 +149,6 @@ int macosx_checkevent(XEvent *ev) {
}
int dragum(void) {return 1;}
#else
void macosx_event_loop(void) {
......@@ -162,6 +160,12 @@ char *macosx_get_fb_addr(void) {
return macosxCG_get_fb_addr();
}
int macosx_opengl_get_width(void);
int macosx_opengl_get_height(void);
int macosx_opengl_get_bpp(void);
int macosx_opengl_get_bps(void);
int macosx_opengl_get_spp(void);
char *macosx_console_guess(char *str, int *fd) {
char *q, *in = strdup(str);
char *atparms = NULL, *file = NULL;
......@@ -200,12 +204,22 @@ char *macosx_console_guess(char *str, int *fd) {
int w, h, b, bps, dep;
unsigned long rm = 0, gm = 0, bm = 0;
if (macosx_read_opengl) {
w = macosx_opengl_get_width();
h = macosx_opengl_get_height();
b = macosx_opengl_get_bpp();
bps = macosx_opengl_get_bps();
dep = macosx_opengl_get_spp() * bps;
} else {
w = macosxCG_CGDisplayPixelsWide();
h = macosxCG_CGDisplayPixelsHigh();
b = macosxCG_CGDisplayBitsPerPixel();
bps = macosxCG_CGDisplayBitsPerSample();
dep = macosxCG_CGDisplaySamplesPerPixel() * bps;
}
rm = (1 << bps) - 1;
gm = (1 << bps) - 1;
......@@ -223,8 +237,7 @@ char *macosx_console_guess(char *str, int *fd) {
/* @66666x66666x32:0xffffffff:... */
atparms = (char *) malloc(200);
sprintf(atparms, "%dx%dx%d:%lx/%lx/%lx",
w, h, b, rm, gm, bm);
sprintf(atparms, "%dx%dx%d:%lx/%lx/%lx", w, h, b, rm, gm, bm);
}
if (atparms) {
int gw, gh, gb;
......@@ -303,7 +316,7 @@ void macosx_pointer_command(int mask, int x, int y, rfbClientPtr client) {
if (0) fprintf(stderr, "about to get all windows: %.4f\n", dnowx());
for (i=0; i < 2; i++) {
macosxCGS_get_all_windows();
fprintf(stderr, "!");
if (0) fprintf(stderr, "!");
if (macosx_checkevent(NULL)) {
break;
}
......@@ -340,7 +353,7 @@ void macosx_key_command(rfbBool down, rfbKeySym keysym, rfbClientPtr client) {
}
init_key_table();
macosxCG_key_inject((int) down, (unsigned int) keysym);
macosxCG_keysym_inject((int) down, (unsigned int) keysym);
}
extern void macosxGCS_poll_pb(void);
......
This diff is collapsed.
......@@ -51,7 +51,7 @@ extern void macosxCG_pointer_inject(int mask, int x, int y);
extern int macosxCG_get_cursor_pos(int *x, int *y);
extern int macosxCG_get_cursor(void);
extern void macosxCG_init_key_table(void);
extern void macosxCG_key_inject(int down, unsigned int keysym);
extern void macosxCG_keysym_inject(int down, unsigned int keysym);
extern void macosxCG_keycode_inject(int down, int keycode);
extern void macosxCG_refresh_callback_off(void);
......
/*
Copyright (C) 2002-2010 Karl J. Runge <runge@karlrunge.com>
All rights reserved.
This file is part of x11vnc.
x11vnc is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
x11vnc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with x11vnc; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
or see <http://www.gnu.org/licenses/>.
In addition, as a special exception, Karl J. Runge
gives permission to link the code of its release of x11vnc with the
OpenSSL project's "OpenSSL" library (or with modified versions of it
that use the same license as the "OpenSSL" library), and distribute
the linked executables. You must obey the GNU General Public License
in all respects for all of the code used other than "OpenSSL". If you
modify this file, you may extend this exception to your version of the
file, but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version.
*/
/* -- macosx_opengl.c -- */
#if (defined(__MACH__) && defined(__APPLE__))
#include <CoreFoundation/CoreFoundation.h>
#include <ApplicationServices/ApplicationServices.h>
#include <rfb/rfb.h>
#if LIBVNCSERVER_HAVE_MACOSX_OPENGL_H
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#endif
extern int macosx_no_opengl, macosx_read_opengl;
extern CGDirectDisplayID displayID;
static CGLContextObj glContextObj;
int macosx_opengl_width = 0;
int macosx_opengl_height = 0;
int macosx_opengl_bpp = 0;
int macosx_opengl_get_width(void) {
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
return (int) viewport[2];
}
int macosx_opengl_get_height(void) {
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
return (int) viewport[3];
}
int macosx_opengl_get_bpp(void) {
return 32;
}
int macosx_opengl_get_bps(void) {
return 8;
}
int macosx_opengl_get_spp(void) {
return 3;
}
void macosx_opengl_init(void) {
CGLPixelFormatObj pixelFormatObj;
GLint numPixelFormats;
CGLPixelFormatAttribute attribs[] = {
kCGLPFAFullScreen,
kCGLPFADisplayMask,
0,
0
};
if (macosx_no_opengl) {
return;
}
attribs[2] = CGDisplayIDToOpenGLDisplayMask(displayID);
CGLChoosePixelFormat(attribs, &pixelFormatObj, &numPixelFormats);
if (pixelFormatObj == NULL) {
rfbLog("macosx_opengl_init: CGLChoosePixelFormat failed. Not using OpenGL.\n");
return;
}
CGLCreateContext(pixelFormatObj, NULL, &glContextObj);
CGLDestroyPixelFormat(pixelFormatObj);
if (glContextObj == NULL) {
rfbLog("macosx_opengl_init: CGLCreateContext failed. Not using OpenGL.\n");
return;
}
CGLSetCurrentContext(glContextObj);
CGLSetFullScreen(glContextObj);
macosx_opengl_width = macosx_opengl_get_width();
macosx_opengl_height = macosx_opengl_get_height();
macosx_opengl_bpp = macosx_opengl_get_bpp();
glFinish();
glPixelStorei(GL_PACK_ALIGNMENT, 4);
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
rfbLog("macosx_opengl_init: Using OpenGL for screen capture.\n");
macosx_read_opengl = 1;
}
void macosx_opengl_fini(void) {
if (!macosx_read_opengl) {
return;
}
CGLSetCurrentContext(NULL);
CGLClearDrawable(glContextObj);
CGLDestroyContext(glContextObj);
}
void macosx_copy_opengl(char *dest, int x, int y, unsigned int w, unsigned int h) {
int yflip = macosx_opengl_height - y - h;
CGLSetCurrentContext(glContextObj);
glReadPixels((GLint) x, (GLint) yflip, (int) w, (int) h,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, dest);
if (h > 1) {
static char *pbuf = NULL;
static int buflen = 0;
int top = 0, bot = h - 1, rowlen = w * macosx_opengl_bpp/8;
char *ptop, *pbot;
if (rowlen > buflen || buflen == 0) {
buflen = rowlen + 128;
if (pbuf) {
free(pbuf);
}
pbuf = (char *) malloc(buflen);
}
while (top < bot) {
ptop = dest + top * rowlen;
pbot = dest + bot * rowlen;
memcpy(pbuf, ptop, rowlen);
memcpy(ptop, pbot, rowlen);
memcpy(pbot, pbuf, rowlen);
top++;
bot--;
}
}
}
#else
#endif /* __APPLE__ */
/*
Copyright (C) 2002-2010 Karl J. Runge <runge@karlrunge.com>
All rights reserved.
This file is part of x11vnc.
x11vnc is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
x11vnc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with x11vnc; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
or see <http://www.gnu.org/licenses/>.
In addition, as a special exception, Karl J. Runge
gives permission to link the code of its release of x11vnc with the
OpenSSL project's "OpenSSL" library (or with modified versions of it
that use the same license as the "OpenSSL" library), and distribute
the linked executables. You must obey the GNU General Public License
in all respects for all of the code used other than "OpenSSL". If you
modify this file, you may extend this exception to your version of the
file, but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version.
*/
#ifndef _X11VNC_MACOSX_OPENGL_H
#define _X11VNC_MACOSX_OPENGL_H
/* -- macosx_opengl.h -- */
extern void macosx_opengl_init(void);
#endif /* _X11VNC_MACOSX_OPENGL_H */
......@@ -134,6 +134,8 @@ int no_external_cmds = 1; /* cannot be turned back on. */
char *allowed_external_cmds = NULL;
int started_as_root = 0;
int host_lookup = 1;
char *unix_sock = NULL;
int unix_sock_fd = -1;
#if X11VNC_LISTEN6
int ipv6_listen = 1; /* -6 / -no6 */
int got_ipv6_listen = 1;
......@@ -217,6 +219,10 @@ int macosx_console = 0;
int macosx_swap23 = 1;
int macosx_resize = 1;
int macosx_icon_anim_time = 450;
int macosx_no_opengl = 0;
int macosx_no_rawfb = 0;
int macosx_read_opengl = 0;
int macosx_read_rawfb = 0;
unsigned long subwin = 0x0; /* -id, -sid */
int subwin_wait_mapped = 0;
......
......@@ -115,6 +115,8 @@ extern int no_external_cmds;
extern char *allowed_external_cmds;
extern int started_as_root;
extern int host_lookup;
extern char *unix_sock;
extern int unix_sock_fd;
extern int ipv6_listen;
extern int got_ipv6_listen;
extern int ipv6_listen_fd;
......@@ -184,6 +186,10 @@ extern int macosx_console;
extern int macosx_swap23;
extern int macosx_resize;
extern int macosx_icon_anim_time;
extern int macosx_no_opengl;
extern int macosx_no_rawfb;
extern int macosx_read_opengl;
extern int macosx_read_rawfb;
extern unsigned long subwin;
extern int subwin_wait_mapped;
......
......@@ -240,6 +240,13 @@ void initialize_speeds(void) {
if (! speeds_read_rate) {
int n = 0;
double dt, timer;
#ifdef MACOSX
if (macosx_console && macosx_read_opengl && fullscreen) {
copy_image(fullscreen, 0, 0, 0, 0);
usleep(10 * 1000);
}
#endif
dtime0(&timer);
if (fullscreen) {
copy_image(fullscreen, 0, 0, 0, 0);
......
......@@ -1028,6 +1028,11 @@ void do_new_fb(int reset_mem) {
settle_clients(1);
}
#ifdef MACOSX
if (macosx_console) {
macosxCG_fini();
}
#endif
if (reset_mem == 1) {
/* reset_mem == 2 is a hack for changing users... */
clean_shm(0);
......@@ -3196,6 +3201,9 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
if (screen && http_dir) {
http_connections(1);
}
if (unix_sock) {
unix_sock_fd = listen_unix(unix_sock);
}
} else {
/* set set frameBuffer member below. */
rfbLog("rfbNewFramebuffer(0x%x, 0x%x, %d, %d, %d, %d, %d)\n",
......
......@@ -1010,12 +1010,20 @@ char find_display[] =
" else\n"
" skip=\":$skip\"\n"
" fi\n"
" skip2=`echo \"$skip\" | sed -e 's/\\.[0-9][0-9]*$//'`\n"
"\n"
" if echo \"$skip\" | grep \":$dtry1\\>\" > /dev/null; then\n"
" mat=1\n"
" break\n"
" elif echo \"$skip\" | grep \":$dtry2\\>\" > /dev/null; then\n"
" mat=1\n"
" break\n"
" elif [ \"X$skip2\" = \"X:$dtry1\" ]; then\n"
" mat=1\n"
" break\n"
" elif [ \"X$skip2\" = \"X:$dtry2\" ]; then\n"
" mat=1\n"
" break\n"
" fi\n"
" done\n"
" if [ \"X$X11VNC_SKIP_DISPLAY_NEGATE\" = \"X\" ]; then\n"
......@@ -2402,14 +2410,24 @@ char create_display[] =
"\n"
" if echo \"$curr_try\" | grep -i '^Xdummy\\>' > /dev/null; then\n"
" try_Xdummy\n"
" elif echo \"$curr_try\" | grep -i '^Xdummy$' > /dev/null; then\n"
" try_Xdummy\n"
" elif echo \"$curr_try\" | grep -i '^Xvfb\\>' > /dev/null; then\n"
" try_Xvfb\n"
" elif echo \"$curr_try\" | grep -i '^Xvfb$' > /dev/null; then\n"
" try_Xvfb\n"
" elif echo \"$curr_try\" | grep -i '^Xvnc\\>' > /dev/null; then\n"
" try_Xvnc\n"
" elif echo \"$curr_try\" | grep -i '^Xvnc$' > /dev/null; then\n"
" try_Xvnc\n"
" elif echo \"$curr_try\" | grep -i '^Xsrv\\>' > /dev/null; then\n"
" try_Xsrv\n"
" elif echo \"$curr_try\" | grep -i '^Xsrv$' > /dev/null; then\n"
" try_Xsrv\n"
" elif echo \"$curr_try\" | grep -i '^X\\>' > /dev/null; then\n"
" try_X\n"
" elif echo \"$curr_try\" | grep -i '^X$' > /dev/null; then\n"
" try_X\n"
" fi\n"
" if [ \"X$result\" = \"X1\" ]; then\n"
" echo \"DISPLAY=:$N\"\n"
......
......@@ -594,6 +594,9 @@ int rfbPE(long usec) {
if (ipv6_listen) {
check_ipv6_listen(usec);
}
if (unix_sock) {
check_unix_sock(usec);
}
if (check_rate != 0) {
if (check_rate < 0) {
if (getenv("CHECK_RATE")) {
......@@ -713,9 +716,31 @@ char *choose_title(char *display) {
if (display == NULL) {
display = getenv("DISPLAY");
}
#ifdef MACOSX
if (display == NULL || strstr(display, "/tmp/") == display) {
char *u = get_user_name();
char *th = this_host();
if (strlen(u) > MAXN/4) {
u = "someone";
}
strcpy(title, u);
if (th == NULL && UT.nodename) {
th = UT.nodename;
}
if (th) {
strcat(title, "@");
strncat(title, th, MAXN - strlen(title));
}
return title;
}
#endif
if (display == NULL) {
return title;
}
/* use display: */
title[0] = '\0';
if (display[0] == ':') {
char *th = this_host();
......
......@@ -2,7 +2,7 @@
.TH X11VNC "1" "December 2010" "x11vnc " "User Commands"
.SH NAME
x11vnc - allow VNC connections to real X11 displays
version: 0.9.13, lastmod: 2010-12-21
version: 0.9.13, lastmod: 2010-12-27
.SH SYNOPSIS
.B x11vnc
[OPTION]...
......@@ -879,6 +879,22 @@ or plan to use remote control: \fB-R\fR connect:host), use
IPv6: if IPv6 is supported, this option automatically
implies the IPv6 loopback address '::1' as well.
.PP
\fB-unixsock\fR \fIstr\fR
.IP
Listen on the unix socket (AF_UNIX) 'str'
for connections. This mode is for either local
connections or a tunnel endpoint where one wants the
file permission of the unix socket file to determine
what can connect to it. (This currently requires an
edit to libvnserver/rfbserver.c: comment out lines 310
and 311, 'close(sock)' and 'return NULL' in rfbserver.c
after the setsockopt() call.) Note that to disable all
tcp listening ports specify '-rfbport 0' and should be
useful with this mode. Example:
mkdir ~/s; chmod 700 ~/s;
x11vnc \fB-unixsock\fR ~/s/mysock \fB-rfbport\fR 0 ...
The SSVNC unix vncviewer can connect to unix sockets.
.PP
\fB-listen6\fR \fIstr\fR
.IP
When in IPv6 listen mode "-6", listen only on the
......@@ -5500,6 +5516,48 @@ because they have animated fades, etc.)
For the native MacOSX server, use the original
keystroke insertion code based on a US keyboard.
.PP
\fB-macnoopengl\fR
.IP
For the native MacOSX server, do not use OpenGL for
screen capture, but rather use the original, deprecated
raw memory access method: addr = CGDisplayBaseAddress().
.PP
\fB-macnorawfb\fR
.IP
For the native MacOSX server, disable the raw memory
address screen capture method.
.IP
MACOSX NOTE: There are some deprecated MacOSX interfaces
to inject keyboard and mouse events and the raw memory
access method is deprecated as well (however, OpenGL
will be preferred if available because it is faster.)
One can force not using any deprecated interfaces at
compile time by setting \fB-DX11VNC_MACOSX_NO_DEPRECATED=1\fR
in CPPFLAGS. Or to turn them off one by one:
\fB-DX11VNC_MACOSX_NO_DEPRECATED_LOCALEVENTS=1,\fR
\fB-DX11VNC_MACOSX_NO_DEPRECATED_POSTEVENTS=1\fR or
\fB-DX11VNC_MACOSX_NO_DEPRECATED_FRAMEBUFFER=1\fR
At run time, for testing and workarounds, one can
disable them by using:
\fB-env\fR X11VNC_MACOSX_NO_DEPRECATED=1
\fB-env\fR X11VNC_MACOSX_NO_DEPRECATED_LOCALEVENTS=1
\fB-env\fR X11VNC_MACOSX_NO_DEPRECATED_POSTEVENTS=1 or
\fB-env\fR X11VNC_MACOSX_NO_DEPRECATED_FRAMEBUFFER=1
Note: When doing either of these for the mouse input
not everything works currently, e.g. double clicks and
wireframing. Also, screen resolution and pixel depth
changes will not be automatically detected unless the
deprecated framebuffer interfaces are allowed.
.IP
Conversely, if you are compiling on an
older machine that does not have some of
the newer interfaces, you may need to specify
\fB-DX11VNC_MACOSX_NO_CGEVENTCREATESCROLLWHEELEVENT\fR
\fB-DX11VNC_MACOSX_NO_CGEVENTCREATEMOUSEEVENT\fR or
\fB-DX11VNC_MACOSX_NO_CGEVENTCREATEKEYBOARDEVENT.\fR Use
\fB-DX11VNC_MACOSX_USE_GETMAINDEVICE\fR to regain the very
old QuickDraw GetMainDevice() interface (rare...)
.PP
\fB-gui\fR \fI[gui-opts]\fR
.IP
Start up a simple tcl/tk gui based on the remote
......
......@@ -2026,7 +2026,6 @@ static void check_guess_auth_file(void) {
}
}
extern int dragum(void);
extern int is_decimal(char *);
int main(int argc, char* argv[]) {
......@@ -2530,9 +2529,17 @@ int main(int argc, char* argv[]) {
got_localhost = 1;
continue;
}
if (!strcmp(arg, "-unixsock")) {
CHECK_ARGC
unix_sock = strdup(argv[++i]);
continue;
}
if (!strcmp(arg, "-listen6")) {
CHECK_ARGC
#if X11VNC_IPV6
listen_str6 = strdup(argv[++i]);
#else
++i;
#endif
continue;
}
......@@ -3931,6 +3938,14 @@ int main(int argc, char* argv[]) {
macosx_us_kbd = 1;
continue;
}
if (!strcmp(arg, "-macnoopengl")) {
macosx_no_opengl = 1;
continue;
}
if (!strcmp(arg, "-macnorawfb")) {
macosx_no_rawfb = 1;
continue;
}
if (!strcmp(arg, "-gui")) {
launch_gui = 1;
if (i < argc-1) {
......@@ -5775,7 +5790,7 @@ int main(int argc, char* argv[]) {
waitms = 5;
}
if (!quiet) {
rfbLog("fast read: reset wait ms to: %d\n", waitms);
rfbLog("fast read: reset -wait ms to: %d\n", waitms);
}
}
if (! got_deferupdate && ! got_defer) {
......@@ -5788,7 +5803,7 @@ int main(int argc, char* argv[]) {
if (screen) {
screen->deferUpdateTime = defer_update;
}
rfbLog("fast read: reset defer ms to: %d\n", defer_update);
rfbLog("fast read: reset -defer ms to: %d\n", defer_update);
}
}
}
......@@ -5816,6 +5831,20 @@ int main(int argc, char* argv[]) {
}
}
}
#ifdef MACOSX
if (remote_cmd || query_cmd) {
;
} else if (macosx_console) {
double dt = dnow();
copy_screen();
dt = dnow() - dt;
rfbLog("macosx_console: copied screen in %.3f sec %.1f MB/sec\n",
dt, dpy_x * dpy_y * bpp / (1e+6 * 8 * dt));
}
#endif
if (! quiet) {
rfbLog("screen setup finished.\n");
if (SHOW_NO_PASSWORD_WARNING && !nopw) {
......
......@@ -135,6 +135,16 @@ so, delete this exception statement from your version.
*
* -DX11VNC_MACOSX_USE_GETMAINDEVICE use deprecated GetMainDevice on macosx
*
* -DX11VNC_MACOSX_NO_DEPRECATED_LOCALEVENTS={0,1}
* -DX11VNC_MACOSX_NO_DEPRECATED_POSTEVENTS={0,1}
* -DX11VNC_MACOSX_NO_DEPRECATED_FRAMEBUFFER={0,1}
*
* or for all:
*
* -DX11VNC_MACOSX_NO_DEPRECATED=1
*
* env. var. of the same names as above can be set to imply true.
*
* Set these in CPPFLAGS before running configure. E.g.:
*
* % env CPPFLAGS="-DFOREVER -DREMOTE_CONTROL=0" ./configure
......@@ -248,6 +258,30 @@ so, delete this exception statement from your version.
#define REMOTE_CONTROL 0
#endif
#ifndef X11VNC_MACOSX_NO_DEPRECATED_LOCALEVENTS
#if X11VNC_MACOSX_NO_DEPRECATED
#define X11VNC_MACOSX_NO_DEPRECATED_LOCALEVENTS 1
#else
#define X11VNC_MACOSX_NO_DEPRECATED_LOCALEVENTS 0
#endif
#endif
#ifndef X11VNC_MACOSX_NO_DEPRECATED_POSTEVENTS
#if X11VNC_MACOSX_NO_DEPRECATED
#define X11VNC_MACOSX_NO_DEPRECATED_POSTEVENTS 1
#else
#define X11VNC_MACOSX_NO_DEPRECATED_POSTEVENTS 0
#endif
#endif
#ifndef X11VNC_MACOSX_NO_DEPRECATED_FRAMEBUFFER
#if X11VNC_MACOSX_NO_DEPRECATED
#define X11VNC_MACOSX_NO_DEPRECATED_FRAMEBUFFER 1
#else
#define X11VNC_MACOSX_NO_DEPRECATED_FRAMEBUFFER 0
#endif
#endif
/*
* Not recommended unless you know what you are getting into, but if you
* define the HARDWIRE_PASSWD or HARDWIRE_VIEWPASSWD variables here or in
......
......@@ -47,7 +47,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.9.13 lastmod: 2010-12-21";
char lastmod[] = "0.9.13 lastmod: 2010-12-27";
/* X display info */
......
......@@ -681,12 +681,23 @@ static void copy_raw_fb_24_to_32(XImage *dest, int x, int y, unsigned int w,
}
}
#ifdef MACOSX
void macosx_copy_opengl(char *, int, int, unsigned int, unsigned int);
#endif
void copy_raw_fb(XImage *dest, int x, int y, unsigned int w, unsigned int h) {
char *src, *dst;
unsigned int line;
int pixelsize = bpp/8;
static int db = -1;
#ifdef MACOSX
if (macosx_console && macosx_read_opengl) {
macosx_copy_opengl(dest->data, x, y, w, h);
return;
}
#endif
if (xform24to32) {
copy_raw_fb_24_to_32(dest, x, y, w, h);
return;
......
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