summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpascalek2009-01-04 17:05:54 (GMT)
committercvs2git2012-06-24 12:13:13 (GMT)
commit35c3e6ff4be7e97614ca79808005c2f99f3982ed (patch)
tree8128003979a64b37d3457e0f50d586552488a8c0
parent2a28c9f70ae0174a1ff824a152ecd98f84c64b41 (diff)
downloadvnc-35c3e6ff4be7e97614ca79808005c2f99f3982ed.zip
vnc-35c3e6ff4be7e97614ca79808005c2f99f3982ed.tar.gz
- initial revision
Changed files: vnc-24bit.patch -> 1.1 vnc-Makefile.am -> 1.1 vnc-allocate.patch -> 1.1 vnc-always_use_fb.patch -> 1.1 vnc-autotools-compile.patch -> 1.1 vnc-autotools.patch -> 1.1 vnc-bounds.patch -> 1.1 vnc-clipboard.patch -> 1.1 vnc-gcc43.patch -> 1.1 vnc-includes.patch -> 1.1 vnc-manminor.patch -> 1.1 vnc-mieq.patch -> 1.1 vnc-paint.patch -> 1.1 vnc-privates.patch -> 1.1 vnc-rh212985.patch -> 1.1 vnc-scrollbars.patch -> 1.1 vnc-selections.patch -> 1.1 vnc-viewerIPv6.patch -> 1.1 vnc-vsnprintf.patch -> 1.1 vnc-xorg.patch -> 1.1
-rw-r--r--vnc-24bit.patch42
-rw-r--r--vnc-Makefile.am60
-rw-r--r--vnc-allocate.patch28
-rw-r--r--vnc-always_use_fb.patch210
-rw-r--r--vnc-autotools-compile.patch11
-rw-r--r--vnc-autotools.patch427
-rw-r--r--vnc-bounds.patch55
-rw-r--r--vnc-clipboard.patch18
-rw-r--r--vnc-gcc43.patch35
-rw-r--r--vnc-includes.patch41
-rw-r--r--vnc-manminor.patch25
-rw-r--r--vnc-mieq.patch690
-rw-r--r--vnc-paint.patch109
-rw-r--r--vnc-privates.patch122
-rw-r--r--vnc-rh212985.patch33
-rw-r--r--vnc-scrollbars.patch69
-rw-r--r--vnc-selections.patch78
-rw-r--r--vnc-viewerIPv6.patch181
-rw-r--r--vnc-vsnprintf.patch20
-rw-r--r--vnc-xorg.patch65
20 files changed, 2319 insertions, 0 deletions
diff --git a/vnc-24bit.patch b/vnc-24bit.patch
new file mode 100644
index 0000000..549cf25
--- /dev/null
+++ b/vnc-24bit.patch
@@ -0,0 +1,42 @@
+--- vnc-4_1_2-unixsrc/unix/xc/programs/Xserver/vnc/Xvnc/xvnc.cc.24bit 2007-06-07 17:27:46.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/xc/programs/Xserver/vnc/Xvnc/xvnc.cc 2007-06-07 17:29:01.000000000 +0200
+@@ -762,7 +762,7 @@ static Bool vfbScreenInit(int index, Scr
+
+ miSetPixmapDepths();
+
+- switch (pvfb->bitsPerPixel)
++ switch (pvfb->depth)
+ {
+ case 8:
+ miSetVisualTypesAndMasks (8, 1 << PseudoColor, 8, PseudoColor, 0, 0, 0);
+@@ -771,6 +771,9 @@ static Bool vfbScreenInit(int index, Scr
+ case 16:
+ miSetVisualTypesAndMasks (16, 1 << TrueColor, 8, TrueColor, 0xf800, 0x07e0, 0x001f);
+ break;
++ case 24:
++ miSetVisualTypesAndMasks (24, 1 << TrueColor, 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff);
++ break;
+ case 32:
+ miSetVisualTypesAndMasks (32, 1 << TrueColor , 8, TrueColor, 0xff000000, 0x00ff0000, 0x0000ff00);
+ break;
+@@ -778,15 +781,17 @@ static Bool vfbScreenInit(int index, Scr
+ return FALSE;
+ }
+
+- if (!fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+- dpi, dpi, pvfb->paddedWidth, pvfb->bitsPerPixel))
+- return FALSE;
++ ret =fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
++ dpi, dpi, pvfb->paddedWidth, pvfb->bitsPerPixel);
+
+ #ifdef RENDER
+ if (ret && Render)
+ fbPictureInit(pScreen, 0, 0);
+ #endif /* RENDER */
+
++ if (!ret)
++ return FALSE;
++
+ pScreen->InstallColormap = vfbInstallColormap;
+ pScreen->UninstallColormap = vfbUninstallColormap;
+ pScreen->ListInstalledColormaps = vfbListInstalledColormaps;
diff --git a/vnc-Makefile.am b/vnc-Makefile.am
new file mode 100644
index 0000000..e310ac9
--- /dev/null
+++ b/vnc-Makefile.am
@@ -0,0 +1,60 @@
+LIB_DIR=$(top_srcdir)/../../common
+BIN_DIR=$(top_srcdir)/..
+
+RFB_LIBS=$(LIB_DIR)/rfb/librfb.la
+
+noinst_LTLIBRARIES = libvnccommon.la
+
+libvnccommon_la_SOURCES = vncExtInit.cc vncHooks.cc XserverDesktop.cc
+
+libvnccommon_la_CPPFLAGS = -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
+ -DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(LIB_DIR) \
+ -I$(BIN_DIR)/vncconfig -DGC_HAS_COMPOSITE_CLIP $(XVNC_CPPFLAGS) \
+ -I$(includedir)/pixman-1
+
+bin_PROGRAMS = Xvnc
+
+Xvnc_SOURCES = xvnc.cc $(top_srcdir)/Xext/dpmsstubs.c \
+ $(top_srcdir)/Xi/stubs.c $(top_srcdir)/mi/miinitext.c \
+ $(top_srcdir)/fb/fbcmap_mi.c
+
+nodist_Xvnc_SOURCES = fbrop.h fb.h pixman.h
+
+Xvnc_CPPFLAGS = $(XVNC_CPPFLAGS) -DNO_HW_ONLY_EXTS -DNO_MODULE_EXTS \
+ -DXFree86Server -DVENDOR_RELEASE="$(VENDOR_RELEASE)" \
+ -DVENDOR_STRING="\"$(VENDOR_STRING)\"" -I$(LIB_DIR) \
+ -I$(top_srcdir)/include -I$(includedir)/pixman-1
+
+Xvnc_LDADD = $(XVNC_LIBS) libvnccommon.la $(RFB_LIBS) \
+ $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lX11
+
+Xvnc_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+
+libvnc_la_LTLIBRARIES = libvnc.la
+libvnc_ladir = $(moduledir)/extensions
+
+libvnc_la_SOURCES = xf86vncModule.cc
+
+libvnc_la_CPPFLAGS = $(XVNC_CPPFLAGS) -I$(LIB_DIR) \
+ -I$(top_srcdir)/hw/xfree86/common \
+ -I$(top_srcdir)/hw/xfree86/os-support \
+ -I$(top_srcdir)/hw/xfree86/os-support/bus \
+ -DXFree86Module -DXFree86LOADER -DIN_MODULE \
+ -I$(includedir)/pixman-1
+
+libvnc_la_LDFLAGS = -module -avoid-version
+
+libvnc_la_LIBADD = libvnccommon.la $(RFB_LIBS)
+
+# C++ hacks
+BUILT_SOURCES = $(nodist_Xvnc_SOURCES)
+
+fb.h: $(top_srcdir)/fb/fb.h
+ cat $(top_srcdir)/fb/fb.h | sed -e 's,and,c_and,' -e 's,xor,c_xor,' > $(srcdir)/fb.h
+
+pixman.h: $(includedir)/pixman-1/pixman.h
+ cat $(includedir)/pixman-1/pixman.h | sed 's/xor/c_xor/' > $(srcdir)/pixman.h
+
+fbrop.h: $(top_srcdir)/fb/fbrop.h
+ cat $(top_srcdir)/fb/fbrop.h | sed -e 's,and,c_and,' -e 's,xor,c_xor,' > $(srcdir)/fbrop.h
+
diff --git a/vnc-allocate.patch b/vnc-allocate.patch
new file mode 100644
index 0000000..a73a73b
--- /dev/null
+++ b/vnc-allocate.patch
@@ -0,0 +1,28 @@
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc.allocate vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc.allocate 2008-02-25 16:38:37.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc 2008-02-25 16:54:48.000000000 +0100
+@@ -536,9 +536,9 @@ static void vfbInstallColormap(ColormapP
+ swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue);
+ swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries);
+
+- ppix = (Pixel *)ALLOCATE_LOCAL(entries * sizeof(Pixel));
+- prgb = (xrgb *)ALLOCATE_LOCAL(entries * sizeof(xrgb));
+- defs = (xColorItem *)ALLOCATE_LOCAL(entries * sizeof(xColorItem));
++ ppix = (Pixel *)xalloc(entries * sizeof(Pixel));
++ prgb = (xrgb *)xalloc(entries * sizeof(xrgb));
++ defs = (xColorItem *)xalloc(entries * sizeof(xColorItem));
+
+ for (i = 0; i < entries; i++) ppix[i] = i;
+ /* XXX truecolor */
+@@ -553,9 +553,9 @@ static void vfbInstallColormap(ColormapP
+ }
+ (*pmap->pScreen->StoreColors)(pmap, entries, defs);
+
+- DEALLOCATE_LOCAL(ppix);
+- DEALLOCATE_LOCAL(prgb);
+- DEALLOCATE_LOCAL(defs);
++ xfree(ppix);
++ xfree(prgb);
++ xfree(defs);
+ }
+ }
diff --git a/vnc-always_use_fb.patch b/vnc-always_use_fb.patch
new file mode 100644
index 0000000..b9e49d0
--- /dev/null
+++ b/vnc-always_use_fb.patch
@@ -0,0 +1,210 @@
+--- vnc-4_1_2-unixsrc/unix/xc/programs/Xserver/vnc/Xvnc/xvnc.cc.always_use_fb 2007-03-05 14:03:21.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/xc/programs/Xserver/vnc/Xvnc/xvnc.cc 2007-03-05 14:10:57.000000000 +0100
+@@ -33,27 +33,28 @@
+ #include <network/TcpSocket.h>
+ #include "vncExtInit.h"
+
++#ifdef HAVE_DIX_CONFIG_H
++#include <dix-config.h>
++#endif
++
+ extern "C" {
+ #define class c_class
+ #define public c_public
++#define new c_new
+ #ifdef WIN32
+ #include <X11/Xwinsock.h>
+ #endif
+ #include <stdio.h>
+-#include "X11/X.h"
++#include <X11/X.h>
+ #define NEED_EVENTS
+-#include "X11/Xproto.h"
+-#include "X11/Xos.h"
++#include <X11/Xproto.h>
++#include <X11/Xos.h>
+ #include "scrnintstr.h"
+ #include "servermd.h"
+-#ifdef VNC_USE_FB
+ #include "fb.h"
+-#else
+-#define PSZ 8
+-#include "cfb.h"
+-#endif
+ #include "mi.h"
+-#include "mibstore.h"
++#include "micmap.h"
++#include "miline.h"
+ #include "colormapst.h"
+ #include "gcstruct.h"
+ #include "input.h"
+@@ -66,24 +67,12 @@
+ #endif
+ #include <X11/XWDFile.h>
+ #include "dix.h"
+-#include "miline.h"
+ #include "inputstr.h"
+ #include "keysym.h"
+ extern int defaultColorVisualClass;
++#undef new
+ #undef class
+ #undef public
+-#ifndef VNC_USE_FB
+- extern Bool cfb16ScreenInit(ScreenPtr, pointer, int, int, int, int, int);
+- extern Bool cfb32ScreenInit(ScreenPtr, pointer, int, int, int, int, int);
+- extern Bool cfb16CreateGC(GCPtr);
+- extern Bool cfb32CreateGC(GCPtr);
+- extern void cfb16GetSpans(DrawablePtr, int, DDXPointPtr, int*, int, char*);
+- extern void cfb32GetSpans(DrawablePtr, int, DDXPointPtr, int*, int, char*);
+- extern void cfb16GetImage(DrawablePtr, int, int, int, int, unsigned int,
+- unsigned long, char*);
+- extern void cfb32GetImage(DrawablePtr, int, int, int, int, unsigned int,
+- unsigned long, char*);
+-#endif
+ }
+
+ #define XVNCVERSION "Free Edition 4.1.2"
+@@ -502,67 +491,6 @@
+ }
+ #endif
+
+-#ifndef VNC_USE_FB
+-static Bool vfbMultiDepthCreateGC(GCPtr pGC)
+-{
+- switch (vfbBitsPerPixel(pGC->depth))
+- {
+- case 1: return mfbCreateGC (pGC);
+- case 8: return cfbCreateGC (pGC);
+- case 16: return cfb16CreateGC (pGC);
+- case 32: return cfb32CreateGC (pGC);
+- default: return FALSE;
+- }
+-}
+-
+-static void vfbMultiDepthGetSpans(
+- DrawablePtr pDrawable, /* drawable from which to get bits */
+- int wMax, /* largest value of all *pwidths */
+- register DDXPointPtr ppt, /* points to start copying from */
+- int *pwidth, /* list of number of bits to copy */
+- int nspans, /* number of scanlines to copy */
+- char *pdstStart) /* where to put the bits */
+-{
+- switch (pDrawable->bitsPerPixel) {
+- case 1:
+- mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+- break;
+- case 8:
+- cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+- break;
+- case 16:
+- cfb16GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+- break;
+- case 32:
+- cfb32GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+- break;
+- }
+- return;
+-}
+-
+-static void
+-vfbMultiDepthGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
+- unsigned int format, unsigned long planeMask,
+- char *pdstLine)
+-{
+- switch (pDrawable->bitsPerPixel)
+- {
+- case 1:
+- mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+- break;
+- case 8:
+- cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+- break;
+- case 16:
+- cfb16GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+- break;
+- case 32:
+- cfb32GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+- break;
+- }
+-}
+-#endif
+-
+ static ColormapPtr InstalledMaps[MAXSCREENS];
+
+ static int vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
+@@ -832,44 +760,32 @@
+ defaultColorVisualClass
+ = (pvfb->bitsPerPixel > 8) ? TrueColor : PseudoColor;
+
+-#ifdef VNC_USE_FB
+- if (!fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+- dpi, dpi, pvfb->paddedWidth, pvfb->bitsPerPixel))
+- return FALSE;
++ miSetPixmapDepths();
+
+-#ifdef RENDER
+- if (ret && Render)
+- fbPictureInit(pScreen, 0, 0);
+-#endif /* RENDER */
+-#else /* VNC_USE_FB */
+ switch (pvfb->bitsPerPixel)
+ {
+- case 1:
+- ret = mfbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+- dpi, dpi, pvfb->paddedWidth);
+- break;
+ case 8:
+- ret = cfbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+- dpi, dpi, pvfb->paddedWidth);
++ miSetVisualTypesAndMasks (8, 1 << PseudoColor, 8, PseudoColor, 0, 0, 0);
++
+ break;
+ case 16:
+- ret = cfb16ScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+- dpi, dpi, pvfb->paddedWidth);
++ miSetVisualTypesAndMasks (16, 1 << TrueColor, 8, TrueColor, 0xf800, 0x07e0, 0x001f);
+ break;
+ case 32:
+- ret = cfb32ScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
+- dpi, dpi, pvfb->paddedWidth);
++ miSetVisualTypesAndMasks (32, 1 << TrueColor , 8, TrueColor, 0xff000000, 0x00ff0000, 0x0000ff00);
+ break;
+ default:
+ return FALSE;
+ }
+
+- if (!ret) return FALSE;
++ if (!fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
++ dpi, dpi, pvfb->paddedWidth, pvfb->bitsPerPixel))
++ return FALSE;
+
+- pScreen->CreateGC = vfbMultiDepthCreateGC;
+- pScreen->GetImage = vfbMultiDepthGetImage;
+- pScreen->GetSpans = vfbMultiDepthGetSpans;
+-#endif
++#ifdef RENDER
++ if (ret && Render)
++ fbPictureInit(pScreen, 0, 0);
++#endif /* RENDER */
+
+ pScreen->InstallColormap = vfbInstallColormap;
+ pScreen->UninstallColormap = vfbUninstallColormap;
+@@ -915,18 +831,7 @@
+ }
+ }
+
+-#ifdef VNC_USE_FB
+ ret = fbCreateDefColormap(pScreen);
+-#else
+- if (pvfb->bitsPerPixel == 1)
+- {
+- ret = mfbCreateDefColormap(pScreen);
+- }
+- else
+- {
+- ret = cfbCreateDefColormap(pScreen);
+- }
+-#endif
+
+ miSetZeroLineBias(pScreen, pvfb->lineBias);
+
diff --git a/vnc-autotools-compile.patch b/vnc-autotools-compile.patch
new file mode 100644
index 0000000..523d878
--- /dev/null
+++ b/vnc-autotools-compile.patch
@@ -0,0 +1,11 @@
+--- vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx.autotools-compile 2007-02-15 18:56:52.000000000 +0100
++++ vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx 2007-02-15 18:57:21.000000000 +0100
+@@ -42,7 +42,7 @@
+ #include <rfb/LogWriter.h>
+
+ #ifndef VNC_SOCKLEN_T
+-#define VNC_SOCKLEN_T int
++#define VNC_SOCKLEN_T socklen_t
+ #endif
+
+ #ifndef INADDR_NONE
diff --git a/vnc-autotools.patch b/vnc-autotools.patch
new file mode 100644
index 0000000..22acf91
--- /dev/null
+++ b/vnc-autotools.patch
@@ -0,0 +1,427 @@
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/common/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,5 @@
++SUBDIRS = \
++ rdr \
++ network \
++ Xregion \
++ rfb
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/common/rfb/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,138 @@
++lib_LTLIBRARIES = librfb.la
++
++librfb_la_SOURCES = \
++ Blacklist.cxx \
++ Blacklist.h \
++ CConnection.cxx \
++ CConnection.h \
++ CMsgHandler.cxx \
++ CMsgHandler.h \
++ CMsgReader.cxx \
++ CMsgReader.h \
++ CMsgReaderV3.cxx \
++ CMsgReaderV3.h \
++ CMsgWriter.cxx \
++ CMsgWriter.h \
++ CMsgWriterV3.cxx \
++ CMsgWriterV3.h \
++ ColourCube.h \
++ ColourMap.h \
++ ComparingUpdateTracker.cxx \
++ ComparingUpdateTracker.h \
++ Configuration.cxx \
++ Configuration.h \
++ ConnParams.cxx \
++ ConnParams.h \
++ CSecurity.h \
++ CSecurityNone.h \
++ CSecurityVncAuth.cxx \
++ CSecurityVncAuth.h \
++ Cursor.cxx \
++ Cursor.h \
++ Decoder.cxx \
++ Decoder.h \
++ d3des.c \
++ d3des.h \
++ Encoder.cxx \
++ Encoder.h \
++ encodings.cxx \
++ encodings.h \
++ Exception.h \
++ hextileConstants.h \
++ hextileDecode.h \
++ HextileDecoder.cxx \
++ HextileDecoder.h \
++ hextileEncode.h \
++ HextileEncoder.cxx \
++ HextileEncoder.h \
++ Hostname.h \
++ HTTPServer.cxx \
++ HTTPServer.h \
++ ImageGetter.h \
++ InputHandler.h \
++ KeyRemapper.cxx \
++ KeyRemapper.h \
++ keysymdef.h \
++ Logger.cxx \
++ Logger_file.cxx \
++ Logger_file.h \
++ Logger.h \
++ Logger_stdio.cxx \
++ Logger_stdio.h \
++ LogWriter.cxx \
++ LogWriter.h \
++ msgTypes.h \
++ Password.cxx \
++ Password.h \
++ PixelBuffer.cxx \
++ PixelBuffer.h \
++ PixelFormat.cxx \
++ PixelFormat.h \
++ Pixel.h \
++ RawDecoder.cxx \
++ RawDecoder.h \
++ RawEncoder.cxx \
++ RawEncoder.h \
++ Rect.h \
++ Region.cxx \
++ Region.h \
++ rreDecode.h \
++ RREDecoder.cxx \
++ RREDecoder.h \
++ rreEncode.h \
++ RREEncoder.cxx \
++ RREEncoder.h \
++ SConnection.cxx \
++ SConnection.h \
++ SDesktop.h \
++ secTypes.cxx \
++ secTypes.h \
++ ServerCore.cxx \
++ ServerCore.h \
++ SMsgHandler.cxx \
++ SMsgHandler.h \
++ SMsgReader.cxx \
++ SMsgReader.h \
++ SMsgReaderV3.cxx \
++ SMsgReaderV3.h \
++ SMsgWriter.cxx \
++ SMsgWriter.h \
++ SMsgWriterV3.cxx \
++ SMsgWriterV3.h \
++ SSecurityFactoryStandard.cxx \
++ SSecurityFactoryStandard.h \
++ SSecurity.h \
++ SSecurityNone.h \
++ SSecurityVncAuth.cxx \
++ SSecurityVncAuth.h \
++ Threading.h \
++ Timer.cxx \
++ Timer.h \
++ TransImageGetter.cxx \
++ TransImageGetter.h \
++ transInitTempl.h \
++ transTempl.h \
++ TrueColourMap.h \
++ UpdateTracker.cxx \
++ UpdateTracker.h \
++ UserPasswdGetter.h \
++ util.cxx \
++ util.h \
++ VNCSConnectionST.cxx \
++ VNCSConnectionST.h \
++ VNCServer.h \
++ VNCServerST.cxx \
++ VNCServerST.h \
++ zrleDecode.h \
++ ZRLEDecoder.cxx \
++ ZRLEDecoder.h \
++ zrleEncode.h \
++ ZRLEEncoder.cxx \
++ ZRLEEncoder.h
++
++librfb_la_LIBADD = \
++ $(top_srcdir)/network/libnetwork.la \
++ $(top_srcdir)/rdr/librdr.la \
++ $(top_srcdir)/Xregion/libXregion.la
++
++librfb_la_CPPFLAGS = -I$(top_srcdir)/../common
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/common/rdr/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,34 @@
++noinst_LTLIBRARIES = librdr.la
++
++librdr_la_SOURCES = \
++ Exception.cxx \
++ FdInStream.h \
++ FixedMemOutStream.h \
++ HexOutStream.cxx \
++ InStream.h \
++ OutStream.h \
++ SubstitutingInStream.h \
++ ZlibInStream.h \
++ Exception.h \
++ FdOutStream.cxx \
++ HexInStream.cxx \
++ HexOutStream.h \
++ MemInStream.h \
++ RandomStream.cxx \
++ types.h \
++ ZlibOutStream.cxx \
++ FdInStream.cxx \
++ FdOutStream.h \
++ HexInStream.h \
++ InStream.cxx \
++ MemOutStream.h \
++ RandomStream.h \
++ ZlibInStream.cxx \
++ ZlibOutStream.h
++
++librdr_la_LIBADD = \
++ -lz
++
++AM_CPPFLAGS = \
++ -I$(top_srcdir)/../common \
++ -I$(top_srcdir)/tx
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/common/configure.ac 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,42 @@
++# -*- Autoconf -*-
++# Process this file with autoconf to produce a configure script.
++
++AC_PREREQ(2.61)
++AC_INIT([vnc-libs], 4.1.3, [bugzilla.redhat.com])
++#AC_CONFIG_HEADER([config.h])
++AM_INIT_AUTOMAKE([-Wall -Werror foreign])
++
++# Checks for programs.
++AC_PROG_CXX
++AC_PROG_CC
++AC_PROG_LIBTOOL
++
++# Checks for libraries.
++
++# Checks for header files.
++AC_HEADER_STDC
++AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h unistd.h])
++
++# Checks for typedefs, structures, and compiler characteristics.
++AC_HEADER_STDBOOL
++AC_C_CONST
++AC_C_INLINE
++AC_TYPE_SIZE_T
++AC_HEADER_TIME
++AC_STRUCT_TM
++
++# Checks for library functions.
++AC_FUNC_ERROR_AT_LINE
++AC_FUNC_MEMCMP
++AC_FUNC_SELECT_ARGTYPES
++AC_TYPE_SIGNAL
++AC_FUNC_STRFTIME
++AC_FUNC_VPRINTF
++AC_CHECK_FUNCS([ftime gethostbyname getpass gettimeofday inet_ntoa memchr memmove memset select socket strcasecmp strchr strerror strncasecmp])
++
++AC_CONFIG_FILES([Makefile
++ Xregion/Makefile
++ network/Makefile
++ rdr/Makefile
++ rfb/Makefile])
++AC_OUTPUT
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/common/Xregion/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,6 @@
++noinst_LTLIBRARIES = libXregion.la
++
++libXregion_la_SOURCES = \
++ Region.c \
++ region.h \
++ Xregion.h
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/common/network/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,8 @@
++noinst_LTLIBRARIES = libnetwork.la
++
++libnetwork_la_CPPFLAGS = -DHAVE_GETADDRINFO -I$(top_srcdir)/../common
++
++libnetwork_la_SOURCES = \
++ Socket.h \
++ TcpSocket.cxx \
++ TcpSocket.h
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/unix/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,6 @@
++SUBDIRS = \
++ tx \
++ vncpasswd \
++ vncviewer \
++ vncconfig \
++ x0vncserver
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/unix/tx/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,25 @@
++noinst_LTLIBRARIES = libtx.la
++
++libtx_la_SOURCES = \
++ TXButton.h \
++ TXDialog.h \
++ TXEntry.h \
++ TXCheckbox.h \
++ TXImage.cxx \
++ TXImage.h \
++ TXLabel.h \
++ TXMenu.cxx \
++ TXMenu.h \
++ TXMsgBox.h \
++ TXScrollbar.cxx \
++ TXScrollbar.h \
++ TXViewport.cxx \
++ TXViewport.h \
++ TXWindow.cxx \
++ TXWindow.h
++
++AM_CPPFLAGS = \
++ -I$(top_srcdir)/../common/
++
++libtx_la_LIBADD = \
++ -lX11
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/unix/vncpasswd/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,10 @@
++bin_PROGRAMS = vncpasswd
++
++vncpasswd_SOURCES = \
++ vncpasswd.cxx
++
++AM_CPPFLAGS = \
++ -I$(top_srcdir)/../common
++
++vncpasswd_LDADD = \
++ $(top_srcdir)/../common/rfb/librfb.la
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/unix/vncconfig/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,17 @@
++bin_PROGRAMS = vncconfig
++
++vncconfig_SOURCES = \
++ buildtime.c \
++ QueryConnectDialog.cxx \
++ QueryConnectDialog.h \
++ vncconfig.cxx \
++ vncExt.c \
++ vncExt.h
++
++AM_CPPFLAGS = \
++ -I$(top_srcdir)/../common \
++ -I$(top_srcdir)/tx
++
++vncconfig_LDADD = \
++ $(top_srcdir)/../common/rfb/librfb.la \
++ $(top_srcdir)/tx/libtx.la
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/unix/configure.ac 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,52 @@
++# -*- Autoconf -*-
++# Process this file with autoconf to produce a configure script.
++
++AC_PREREQ(2.61)
++AC_INIT([vnc], 4.1.3, [bugzilla.redhat.com])
++AC_CONFIG_SRCDIR([x0vncserver/buildtime.c])
++#AC_CONFIG_HEADER([config.h])
++AM_INIT_AUTOMAKE([-Wall -Werror foreign])
++
++# Checks for programs.
++AC_PROG_CXX
++AC_PROG_CC
++AC_PROG_LIBTOOL
++
++# Checks for libraries.
++
++# Checks for header files.
++AC_PATH_X
++AC_HEADER_STDC
++AC_HEADER_SYS_WAIT
++AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h sys/time.h termios.h unistd.h])
++
++# Checks for typedefs, structures, and compiler characteristics.
++AC_HEADER_STDBOOL
++AC_C_CONST
++AC_C_INLINE
++AC_C_RESTRICT
++AC_TYPE_SIZE_T
++AC_HEADER_TIME
++
++# Checks for library functions.
++AC_FUNC_ERROR_AT_LINE
++AC_FUNC_FORK
++AC_FUNC_LSTAT
++AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
++AC_FUNC_MALLOC
++AC_FUNC_MEMCMP
++AC_FUNC_REALLOC
++AC_FUNC_SELECT_ARGTYPES
++AC_TYPE_SIGNAL
++AC_FUNC_STAT
++AC_FUNC_VPRINTF
++AC_FUNC_WAIT3
++AC_CHECK_FUNCS([memset mkdir select setenv strchr strdup strerror strspn strtol])
++
++AC_CONFIG_FILES([Makefile
++ tx/Makefile
++ vncconfig/Makefile
++ vncpasswd/Makefile
++ vncviewer/Makefile
++ x0vncserver/Makefile])
++AC_OUTPUT
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/unix/vncviewer/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,24 @@
++bin_PROGRAMS = vncviewer
++
++vncviewer_SOURCES = \
++ AboutDialog.h \
++ buildtime.c \
++ CConn.cxx \
++ CConn.h \
++ DesktopWindow.cxx \
++ DesktopWindow.h \
++ InfoDialog.h \
++ OptionsDialog.h \
++ parameters.h \
++ PasswdDialog.h \
++ ServerDialog.h \
++ vncviewer.cxx
++
++AM_CPPFLAGS = \
++ -I$(top_srcdir)/../common \
++ -I$(top_srcdir)/tx
++
++vncviewer_LDADD = \
++ $(top_srcdir)/../common/rfb/librfb.la \
++ $(top_srcdir)/tx/libtx.la \
++ -lXext
+--- /dev/null 2007-02-16 09:39:42.585819347 +0100
++++ vnc-4_1_2-unixsrc/unix/x0vncserver/Makefile.am 2007-02-16 09:51:11.000000000 +0100
+@@ -0,0 +1,21 @@
++bin_PROGRAMS = x0vncserver
++
++x0vncserver_SOURCES = \
++ buildtime.c \
++ Image.cxx \
++ Image.h \
++ x0vncserver.cxx \
++ $(top_srcdir)/vncconfig/QueryConnectDialog.h \
++ $(top_srcdir)/vncconfig/QueryConnectDialog.cxx
++
++x0vncserver_CPPFLAGS = \
++ -I$(top_srcdir)/../common \
++ -I$(top_srcdir)/vncconfig \
++ -I$(top_srcdir)/tx \
++ -I$(top_srcdir)
++
++x0vncserver_LDADD = \
++ $(top_srcdir)/../common/rfb/librfb.la \
++ $(top_srcdir)/tx/libtx.la \
++ -lXext \
++ -lXtst
diff --git a/vnc-bounds.patch b/vnc-bounds.patch
new file mode 100644
index 0000000..edbde37
--- /dev/null
+++ b/vnc-bounds.patch
@@ -0,0 +1,55 @@
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc.bounds vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc.bounds 2008-03-17 16:46:27.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc 2008-03-17 16:59:11.000000000 +0100
+@@ -486,32 +486,36 @@ void XserverDesktop::add_changed(RegionP
+ {
+ if (ignoreHooks_) return;
+ if (grabbing) return;
++
++ BoxRec screenbox;
++ RegionPtr newreg = REGION_CREATE(pScreen, 0, 0);
++
++ screenbox.x1 = screenbox.y1 = 0;
++ screenbox.x2 = pScreen->width;
++ screenbox.y2 = pScreen->height;
++
++ RegionPtr screenreg = REGION_CREATE(pScreen, &screenbox, 0);
++ REGION_INTERSECT(pScreen, newreg, reg, screenreg);
++ REGION_DESTROY (pScreen, screenreg);
++
+ try {
+ rfb::Region rfbReg;
+- rfbReg.setExtentsAndOrderedRects((ShortRect*)REGION_EXTENTS(pScreen, reg),
+- REGION_NUM_RECTS(reg),
+- (ShortRect*)REGION_RECTS(reg));
++ rfbReg.setExtentsAndOrderedRects((ShortRect*)REGION_EXTENTS(pScreen, newreg),
++ REGION_NUM_RECTS(newreg),
++ (ShortRect*)REGION_RECTS(newreg));
+ server->add_changed(rfbReg);
+ deferUpdate();
+ } catch (rdr::Exception& e) {
+ vlog.error("XserverDesktop::add_changed: %s",e.str());
+ }
++ REGION_DESTROY (pScreen, newreg);
+ }
+
+ void XserverDesktop::add_copied(RegionPtr dst, int dx, int dy)
+ {
+- if (ignoreHooks_) return;
+- if (grabbing) return;
+- try {
+- rfb::Region rfbReg;
+- rfbReg.setExtentsAndOrderedRects((ShortRect*)REGION_EXTENTS(pScreen, dst),
+- REGION_NUM_RECTS(dst),
+- (ShortRect*)REGION_RECTS(dst));
+- server->add_copied(rfbReg, rfb::Point(dx, dy));
+- deferUpdate();
+- } catch (rdr::Exception& e) {
+- vlog.error("XserverDesktop::add_copied: %s",e.str());
+- }
++ add_changed (dst);
++ REGION_TRANSLATE (pScreen, dst, -dx, -dy);
++ add_changed (dst);
+ }
+
+ void XserverDesktop::positionCursor()
diff --git a/vnc-clipboard.patch b/vnc-clipboard.patch
new file mode 100644
index 0000000..9865ec2
--- /dev/null
+++ b/vnc-clipboard.patch
@@ -0,0 +1,18 @@
+diff -up vnc-4_1_2-unixsrc/unix/vncserver.clipboard vnc-4_1_2-unixsrc/unix/vncserver
+--- vnc-4_1_2-unixsrc/unix/vncserver.clipboard 2008-03-13 16:17:07.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/vncserver 2008-03-13 16:18:14.000000000 +0100
+@@ -42,13 +42,13 @@ $xauthorityFile = "$ENV{XAUTHORITY}" ||
+
+ $defaultXStartup
+ = ("#!/bin/sh\n\n".
++ "vncconfig -iconic &\n".
+ "# Uncomment the following two lines for normal desktop:\n".
+ "# unset SESSION_MANAGER\n".
+ "# exec /etc/X11/xinit/xinitrc\n\n".
+ "[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup\n".
+ "[ -r \$HOME/.Xresources ] && xrdb \$HOME/.Xresources\n".
+ "xsetroot -solid grey\n".
+- "vncconfig -iconic &\n".
+ "xterm -geometry 80x24+10+10 -ls -title \"\$VNCDESKTOP Desktop\" &\n".
+ "twm &\n");
+
diff --git a/vnc-gcc43.patch b/vnc-gcc43.patch
new file mode 100644
index 0000000..b7e035d
--- /dev/null
+++ b/vnc-gcc43.patch
@@ -0,0 +1,35 @@
+diff -up vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx.gcc43 vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx
+--- vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx.gcc43 2008-01-09 14:51:54.000000000 +0100
++++ vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx 2008-01-09 14:51:54.000000000 +0100
+@@ -37,6 +37,9 @@
+ #include <fcntl.h>
+ #endif
+
++extern "C" {
++#include <stdlib.h>
++}
+ #include <network/TcpSocket.h>
+ #include <rfb/util.h>
+ #include <rfb/LogWriter.h>
+diff -up vnc-4_1_2-unixsrc/unix/tx/TXImage.cxx.gcc43 vnc-4_1_2-unixsrc/unix/tx/TXImage.cxx
+--- vnc-4_1_2-unixsrc/unix/tx/TXImage.cxx.gcc43 2006-05-15 18:56:20.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/tx/TXImage.cxx 2008-01-09 14:51:54.000000000 +0100
+@@ -22,6 +22,7 @@
+
+ #include <stdio.h>
+ #include <strings.h>
++#include <stdlib.h>
+ #include <sys/types.h>
+ #include <sys/ipc.h>
+ #include <sys/shm.h>
+diff -up vnc-4_1_2-unixsrc/unix/x0vncserver/Image.cxx.gcc43 vnc-4_1_2-unixsrc/unix/x0vncserver/Image.cxx
+--- vnc-4_1_2-unixsrc/unix/x0vncserver/Image.cxx.gcc43 2006-05-15 18:56:20.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/x0vncserver/Image.cxx 2008-01-09 14:51:54.000000000 +0100
+@@ -21,6 +21,7 @@
+
+
+ #include <stdio.h>
++#include <stdlib.h>
+ #include <sys/types.h>
+ #include <sys/ipc.h>
+ #include <sys/shm.h>
diff --git a/vnc-includes.patch b/vnc-includes.patch
new file mode 100644
index 0000000..fae1c59
--- /dev/null
+++ b/vnc-includes.patch
@@ -0,0 +1,41 @@
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncExtInit.cc.includes vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncExtInit.cc
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncExtInit.cc.includes 2008-04-04 13:54:24.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncExtInit.cc 2008-04-04 13:54:49.000000000 +0200
+@@ -22,8 +22,8 @@
+ extern "C" {
+ #define class c_class
+ #define NEED_EVENTS
+-#include "X.h"
+-#include "Xproto.h"
++#include <X11/X.h>
++#include <X11/Xproto.h>
+ #include "misc.h"
+ #include "os.h"
+ #include "dixstruct.h"
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc.includes vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc.includes 2008-04-04 13:55:07.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc 2008-04-04 13:55:29.000000000 +0200
+@@ -50,9 +50,9 @@ extern char *display;
+ #include "resource.h"
+ #include "cursorstr.h"
+ #include "windowstr.h"
+-#include "mi/mi.h"
++#include "mi.h"
+ #define XK_CYRILLIC
+-#include "keysym.h"
++#include <X11/keysym.h>
+ #undef public
+ #undef class
+ }
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc.includes vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc.includes 2008-04-04 13:57:34.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc 2008-04-04 13:57:44.000000000 +0200
+@@ -68,7 +68,7 @@ extern "C" {
+ #include <X11/XWDFile.h>
+ #include "dix.h"
+ #include "inputstr.h"
+-#include "keysym.h"
++#include <X11/keysym.h>
+ extern int defaultColorVisualClass;
+ #undef new
+ #undef class
diff --git a/vnc-manminor.patch b/vnc-manminor.patch
new file mode 100644
index 0000000..aadbd9d
--- /dev/null
+++ b/vnc-manminor.patch
@@ -0,0 +1,25 @@
+diff -up vnc-4_1_2-unixsrc/unix/vncviewer/vncviewer.man.pedantic vnc-4_1_2-unixsrc/unix/vncviewer/vncviewer.man
+--- vnc-4_1_2-unixsrc/unix/vncviewer/vncviewer.man.pedantic 2008-03-13 14:55:08.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/vncviewer/vncviewer.man 2008-03-13 14:55:58.000000000 +0100
+@@ -8,6 +8,10 @@ vncviewer \- VNC viewer for X
+ .br
+ .B vncviewer
+ .RI [ options ]
++.RI [ host ][:: port ]
++.br
++.B vncviewer
++.RI [ options ]
+ .B \-listen
+ .RI [ port ]
+ .SH DESCRIPTION
+@@ -182,8 +186,8 @@ prefix from the entries in "/usr/include
+ .TP
+ \fB\-via\fR \fIgateway\fR
+ Automatically create encrypted TCP tunnel to the \fIgateway\fR machine
+-before connection, connect to the \fIhost\fR through that tunnel
+-(TightVNC\-specific). By default, this option invokes SSH local port
++before connection, connect to the \fIhost\fR through that tunnel. By default,
++this option invokes SSH local port
+ forwarding, assuming that SSH client binary can be accessed as
+ /usr/bin/ssh. Note that when using the \fB\-via\fR option, the host
+ machine name should be specified as known to the gateway machine, e.g.
diff --git a/vnc-mieq.patch b/vnc-mieq.patch
new file mode 100644
index 0000000..301e85c
--- /dev/null
+++ b/vnc-mieq.patch
@@ -0,0 +1,690 @@
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc.mieq vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc.mieq 2006-05-15 18:56:20.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/XserverDesktop.cc 2008-03-05 12:25:06.000000000 +0100
+@@ -50,12 +50,20 @@ extern char *display;
+ #include "resource.h"
+ #include "cursorstr.h"
+ #include "windowstr.h"
++#include "mi/mi.h"
+ #define XK_CYRILLIC
+ #include "keysym.h"
+ #undef public
+ #undef class
+ }
+
++static xEvent *eventq = NULL;
++static DeviceIntPtr vncKeyboard = NULL;
++static DeviceIntPtr vncMouse = NULL;
++
++static int vfbKeybdProc (DeviceIntPtr pDev, int onoff);
++static int vfbMouseProc (DeviceIntPtr pDev, int onoff);
++
+ using namespace rfb;
+ using namespace network;
+
+@@ -202,6 +210,21 @@ XserverDesktop::XserverDesktop(ScreenPtr
+
+ if (httpListener)
+ httpServer = new FileHTTPServer(this);
++
++// XXX Memory leak here, eventq is not free()-d because it has to exist till server exits
++ if (!eventq)
++ eventq = (xEvent *) xcalloc(sizeof(xEvent), GetMaximumEventsNum());
++ if (!eventq)
++ FatalError("couldn't allocate room for events\n");
++
++ if (vncMouse == NULL) {
++ vncMouse = AddInputDevice(vfbMouseProc, TRUE);
++ RegisterPointerDevice (vncMouse);
++ }
++ if (vncKeyboard == NULL) {
++ vncKeyboard = AddInputDevice(vfbKeybdProc, TRUE);
++ RegisterKeyboardDevice (vncKeyboard);
++ }
+ }
+
+ XserverDesktop::~XserverDesktop()
+@@ -495,7 +518,7 @@ void XserverDesktop::positionCursor()
+ {
+ if (!cursorPos.equals(oldCursorPos)) {
+ oldCursorPos = cursorPos;
+- (*pScreen->SetCursorPosition) (pScreen, cursorPos.x, cursorPos.y, FALSE);
++// (*pScreen->SetCursorPosition) (pScreen, cursorPos.x, cursorPos.y, FALSE);
+ server->setCursorPos(cursorPos);
+ server->tryUpdate();
+ }
+@@ -660,8 +683,8 @@ void XserverDesktop::approveConnection(v
+
+ void XserverDesktop::pointerEvent(const Point& pos, int buttonMask)
+ {
+- xEvent ev;
+- DevicePtr dev = LookupPointerDevice();
++ BYTE detail;
++ int i, j, n, valuators[2];
+
+ // SetCursorPosition seems to be very expensive (at least on XFree86 3.3.6
+ // for S3), so we delay calling it until positionCursor() is called at the
+@@ -670,14 +693,14 @@ void XserverDesktop::pointerEvent(const
+
+ NewCurrentScreen(pScreen, pos.x, pos.y);
+
+- ev.u.u.type = MotionNotify;
+- ev.u.u.detail = 0;
+- ev.u.keyButtonPointer.rootX = pos.x;
+- ev.u.keyButtonPointer.rootY = pos.y;
+- ev.u.keyButtonPointer.time = GetTimeInMillis();
+-
+- if (!pos.equals(cursorPos))
+- (*dev->processInputProc)(&ev, (DeviceIntPtr)dev, 1);
++ if (!pos.equals(cursorPos)) {
++ valuators[0] = pos.x;
++ valuators[1] = pos.y;
++ n = GetPointerEvents (eventq, vncMouse, MotionNotify, 0,
++ POINTER_ABSOLUTE, 0, 2, valuators);
++ for (i = 0; i < n; i++)
++ mieqEnqueue (vncMouse, eventq + i);
++ }
+
+ for (int i = 0; i < 5; i++) {
+ if ((buttonMask ^ oldButtonMask) & (1<<i)) {
+@@ -685,12 +708,15 @@ void XserverDesktop::pointerEvent(const
+ // God knows why but some idiot decided to conditionally move the pointer
+ // mapping out of DIX, so we guess here that if XINPUT is defined we have
+ // to do it ourselves...
+- ev.u.u.detail = ((DeviceIntPtr)dev)->button->map[i + 1];
++ detail = vncMouse->button->map[i + 1];
+ #else
+- ev.u.u.detail = i + 1;
++ detail = i + 1;
+ #endif
+- ev.u.u.type = (buttonMask & (1<<i)) ? ButtonPress : ButtonRelease;
+- (*dev->processInputProc)(&ev, (DeviceIntPtr)dev, 1);
++ n = GetPointerEvents (eventq, vncMouse, (buttonMask & (1<<i)) ?
++ ButtonPress : ButtonRelease,
++ detail, POINTER_RELATIVE, 0, 0, NULL);
++ for (j = 0; j < n; j++)
++ mieqEnqueue (vncMouse, eventq + j);
+ }
+ }
+
+@@ -771,8 +797,8 @@ void XserverDesktop::lookup(int index, i
+
+ class ModifierState {
+ public:
+- ModifierState(DeviceIntPtr dev_, int modIndex_)
+- : dev(dev_), modIndex(modIndex_), nKeys(0), keys(0), pressed(false)
++ ModifierState(int modIndex_)
++ : modIndex(modIndex_), nKeys(0), keys(0), pressed(false)
+ {
+ }
+ ~ModifierState() {
+@@ -781,7 +807,7 @@ public:
+ delete [] keys;
+ }
+ void press() {
+- KeyClassPtr keyc = dev->key;
++ KeyClassPtr keyc = vncKeyboard->key;
+ if (!(keyc->state & (1<<modIndex))) {
+ tempKeyEvent(keyc->modifierKeyMap[modIndex * keyc->maxKeysPerModifier],
+ true);
+@@ -789,7 +815,7 @@ public:
+ }
+ }
+ void release() {
+- KeyClassPtr keyc = dev->key;
++ KeyClassPtr keyc = vncKeyboard->key;
+ if (keyc->state & (1<<modIndex)) {
+ for (int k = 0; k < keyc->maxKeysPerModifier; k++) {
+ int keycode
+@@ -802,20 +828,19 @@ public:
+ private:
+ void tempKeyEvent(int keycode, bool down) {
+ if (keycode) {
+- if (!keys) keys = new int[dev->key->maxKeysPerModifier];
++ if (!keys) keys = new int[vncKeyboard->key->maxKeysPerModifier];
+ keys[nKeys++] = keycode;
+ generateXKeyEvent(keycode, down);
+ }
+ }
+ void generateXKeyEvent(int keycode, bool down) {
+- xEvent ev;
+- ev.u.u.type = down ? KeyPress : KeyRelease;
+- ev.u.u.detail = keycode;
+- ev.u.keyButtonPointer.time = GetTimeInMillis();
+- (*dev->c_public.processInputProc)(&ev, dev, 1);
++ int i, n;
++ n = GetKeyboardEvents (eventq, vncKeyboard,
++ down ? KeyPress : KeyRelease, keycode);
++ for (i = 0; i < n; i++)
++ mieqEnqueue (vncKeyboard, eventq + i);
+ vlog.debug("fake keycode %d %s", keycode, down ? "down" : "up");
+ }
+- DeviceIntPtr dev;
+ int modIndex;
+ int nKeys;
+ int* keys;
+@@ -888,16 +913,16 @@ void XserverDesktop::keyEvent(rdr::U32 k
+ vlog.debug("Ignoring caps lock");
+ return;
+ }
+- DeviceIntPtr dev = (DeviceIntPtr)LookupKeyboardDevice();
+- KeyClassPtr keyc = dev->key;
++ KeyClassPtr keyc = vncKeyboard->key;
+ KeySymsPtr keymap = &keyc->curKeySyms;
++ int i, j, k, n;
+
+ // find which modifier Mode_switch is on.
+ int modeSwitchMapIndex = 0;
+- for (int i = 3; i < 8; i++) {
+- for (int k = 0; k < keyc->maxKeysPerModifier; k++) {
++ for (i = 3; i < 8; i++) {
++ for (k = 0; k < keyc->maxKeysPerModifier; k++) {
+ int keycode = keyc->modifierKeyMap[i * keyc->maxKeysPerModifier + k];
+- for (int j = 0; j < keymap->mapWidth; j++) {
++ for (j = 0; j < keymap->mapWidth; j++) {
+ if (keycode != 0 &&
+ keymap->map[(keycode - keymap->minKeyCode)
+ * keymap->mapWidth + j] == XK_Mode_switch)
+@@ -926,7 +951,7 @@ void XserverDesktop::keyEvent(rdr::U32 k
+ if (kc == 0) {
+ // Not a direct match in the local keyboard mapping. Check for alternative
+ // keysyms with the same meaning.
+- for (int i = 0; i < sizeof(altKeysym) / sizeof(altKeysym_t); i++) {
++ for (i = 0; i < sizeof(altKeysym) / sizeof(altKeysym_t); i++) {
+ if (keysym == altKeysym[i].a)
+ kc = KeysymToKeycode(keymap, altKeysym[i].b, &col);
+ else if (keysym == altKeysym[i].b)
+@@ -954,16 +979,16 @@ void XserverDesktop::keyEvent(rdr::U32 k
+
+ // See if it's a modifier key. If so, then don't do any auto-repeat, because
+ // the X server will translate each press into a release followed by a press.
+- for (int i = 0; i < 8; i++) {
+- for (int k = 0; k < keyc->maxKeysPerModifier; k++) {
++ for (i = 0; i < 8; i++) {
++ for (k = 0; k < keyc->maxKeysPerModifier; k++) {
+ if (kc == keyc->modifierKeyMap[i * keyc->maxKeysPerModifier + k] &&
+ IS_PRESSED(keyc,kc) && down)
+ return;
+ }
+ }
+
+- ModifierState shift(dev, ShiftMapIndex);
+- ModifierState modeSwitch(dev, modeSwitchMapIndex);
++ ModifierState shift(ShiftMapIndex);
++ ModifierState modeSwitch(modeSwitchMapIndex);
+ if (down) {
+ if (col & 1)
+ shift.press();
+@@ -977,11 +1002,10 @@ void XserverDesktop::keyEvent(rdr::U32 k
+ }
+ }
+ vlog.debug("keycode %d %s", kc, down ? "down" : "up");
+- xEvent ev;
+- ev.u.u.type = down ? KeyPress : KeyRelease;
+- ev.u.u.detail = kc;
+- ev.u.keyButtonPointer.time = GetTimeInMillis();
+- (*dev->c_public.processInputProc)(&ev, dev, 1);
++ n = GetKeyboardEvents (eventq, vncKeyboard, down ? KeyPress : KeyRelease,
++ kc);
++ for (i = 0; i < n; i++)
++ mieqEnqueue (vncKeyboard, eventq + i);
+ }
+
+
+@@ -1150,3 +1174,208 @@ static KeyCode KeysymToKeycode(KeySymsPt
+ }
+ return 0;
+ }
++
++void vncRingBell(int percent, int pitch, int duration)
++{
++ if (percent > 0)
++ vncBell();
++}
++
++/* Fairly standard US PC Keyboard */
++
++#define VFB_MIN_KEY 8
++#define VFB_MAX_KEY 255
++#define VFB_MAP_LEN (VFB_MAX_KEY - VFB_MIN_KEY + 1)
++#define KEYSYMS_PER_KEY 2
++KeySym keyboardMap[VFB_MAP_LEN * KEYSYMS_PER_KEY] = {
++ NoSymbol, NoSymbol,
++ XK_Escape, NoSymbol,
++ XK_1, XK_exclam,
++ XK_2, XK_at,
++ XK_3, XK_numbersign,
++ XK_4, XK_dollar,
++ XK_5, XK_percent,
++ XK_6, XK_asciicircum,
++ XK_7, XK_ampersand,
++ XK_8, XK_asterisk,
++ XK_9, XK_parenleft,
++ XK_0, XK_parenright,
++ XK_minus, XK_underscore,
++ XK_equal, XK_plus,
++ XK_BackSpace, NoSymbol,
++ XK_Tab, NoSymbol,
++ XK_q, XK_Q,
++ XK_w, XK_W,
++ XK_e, XK_E,
++ XK_r, XK_R,
++ XK_t, XK_T,
++ XK_y, XK_Y,
++ XK_u, XK_U,
++ XK_i, XK_I,
++ XK_o, XK_O,
++ XK_p, XK_P,
++ XK_bracketleft, XK_braceleft,
++ XK_bracketright, XK_braceright,
++ XK_Return, NoSymbol,
++ XK_Control_L, NoSymbol,
++ XK_a, XK_A,
++ XK_s, XK_S,
++ XK_d, XK_D,
++ XK_f, XK_F,
++ XK_g, XK_G,
++ XK_h, XK_H,
++ XK_j, XK_J,
++ XK_k, XK_K,
++ XK_l, XK_L,
++ XK_semicolon, XK_colon,
++ XK_apostrophe, XK_quotedbl,
++ XK_grave, XK_asciitilde,
++ XK_Shift_L, NoSymbol,
++ XK_backslash, XK_bar,
++ XK_z, XK_Z,
++ XK_x, XK_X,
++ XK_c, XK_C,
++ XK_v, XK_V,
++ XK_b, XK_B,
++ XK_n, XK_N,
++ XK_m, XK_M,
++ XK_comma, XK_less,
++ XK_period, XK_greater,
++ XK_slash, XK_question,
++ XK_Shift_R, NoSymbol,
++ XK_KP_Multiply, NoSymbol,
++ XK_Alt_L, XK_Meta_L,
++ XK_space, NoSymbol,
++ /*XK_Caps_Lock*/ NoSymbol, NoSymbol,
++ XK_F1, NoSymbol,
++ XK_F2, NoSymbol,
++ XK_F3, NoSymbol,
++ XK_F4, NoSymbol,
++ XK_F5, NoSymbol,
++ XK_F6, NoSymbol,
++ XK_F7, NoSymbol,
++ XK_F8, NoSymbol,
++ XK_F9, NoSymbol,
++ XK_F10, NoSymbol,
++ XK_Num_Lock, XK_Pointer_EnableKeys,
++ XK_Scroll_Lock, NoSymbol,
++ XK_KP_Home, XK_KP_7,
++ XK_KP_Up, XK_KP_8,
++ XK_KP_Prior, XK_KP_9,
++ XK_KP_Subtract, NoSymbol,
++ XK_KP_Left, XK_KP_4,
++ XK_KP_Begin, XK_KP_5,
++ XK_KP_Right, XK_KP_6,
++ XK_KP_Add, NoSymbol,
++ XK_KP_End, XK_KP_1,
++ XK_KP_Down, XK_KP_2,
++ XK_KP_Next, XK_KP_3,
++ XK_KP_Insert, XK_KP_0,
++ XK_KP_Delete, XK_KP_Decimal,
++ NoSymbol, NoSymbol,
++ NoSymbol, NoSymbol,
++ NoSymbol, NoSymbol,
++ XK_F11, NoSymbol,
++ XK_F12, NoSymbol,
++ XK_Home, NoSymbol,
++ XK_Up, NoSymbol,
++ XK_Prior, NoSymbol,
++ XK_Left, NoSymbol,
++ NoSymbol, NoSymbol,
++ XK_Right, NoSymbol,
++ XK_End, NoSymbol,
++ XK_Down, NoSymbol,
++ XK_Next, NoSymbol,
++ XK_Insert, NoSymbol,
++ XK_Delete, NoSymbol,
++ XK_KP_Enter, NoSymbol,
++ XK_Control_R, NoSymbol,
++ XK_Pause, XK_Break,
++ XK_Print, XK_Execute,
++ XK_KP_Divide, NoSymbol,
++ XK_Alt_R, XK_Meta_R,
++};
++
++static Bool GetMappings(KeySymsPtr pKeySyms, CARD8 *pModMap)
++{
++ int i;
++
++ for (i = 0; i < MAP_LENGTH; i++)
++ pModMap[i] = NoSymbol;
++
++ for (i = 0; i < VFB_MAP_LEN; i++) {
++ if (keyboardMap[i * KEYSYMS_PER_KEY] == XK_Caps_Lock)
++ pModMap[i + VFB_MIN_KEY] = LockMask;
++ else if (keyboardMap[i * KEYSYMS_PER_KEY] == XK_Shift_L ||
++ keyboardMap[i * KEYSYMS_PER_KEY] == XK_Shift_R)
++ pModMap[i + VFB_MIN_KEY] = ShiftMask;
++ else if (keyboardMap[i * KEYSYMS_PER_KEY] == XK_Control_L ||
++ keyboardMap[i * KEYSYMS_PER_KEY] == XK_Control_R) {
++ pModMap[i + VFB_MIN_KEY] = ControlMask;
++ }
++ else if (keyboardMap[i * KEYSYMS_PER_KEY] == XK_Alt_L ||
++ keyboardMap[i * KEYSYMS_PER_KEY] == XK_Alt_R)
++ pModMap[i + VFB_MIN_KEY] = Mod1Mask;
++ }
++
++ pKeySyms->minKeyCode = VFB_MIN_KEY;
++ pKeySyms->maxKeyCode = VFB_MAX_KEY;
++ pKeySyms->mapWidth = KEYSYMS_PER_KEY;
++ pKeySyms->map = keyboardMap;
++
++ return TRUE;
++}
++
++static int vfbKeybdProc(DeviceIntPtr pDev, int onoff)
++{
++ KeySymsRec keySyms;
++ CARD8 modMap[MAP_LENGTH];
++
++ switch (onoff)
++ {
++ case DEVICE_INIT:
++ GetMappings(&keySyms, modMap);
++ InitKeyboardDeviceStruct(&pDev->c_public, &keySyms, modMap,
++ (BellProcPtr)vncRingBell, (KbdCtrlProcPtr)NoopDDA);
++ break;
++ case DEVICE_ON:
++ pDev->c_public.on = TRUE;
++ break;
++ case DEVICE_OFF:
++ pDev->c_public.on = FALSE;
++ break;
++ case DEVICE_CLOSE:
++ break;
++ }
++ return Success;
++}
++
++static int vfbMouseProc(DeviceIntPtr pDev, int onoff)
++{
++ BYTE map[6];
++
++ switch (onoff)
++ {
++ case DEVICE_INIT:
++ map[1] = 1;
++ map[2] = 2;
++ map[3] = 3;
++ map[4] = 4;
++ map[5] = 5;
++ InitPointerDeviceStruct(&pDev->c_public, map, 5, GetMotionHistory,
++ (PtrCtrlProcPtr)NoopDDA, GetMotionHistorySize(), 2);
++ break;
++
++ case DEVICE_ON:
++ pDev->c_public.on = TRUE;
++ break;
++
++ case DEVICE_OFF:
++ pDev->c_public.on = FALSE;
++ break;
++
++ case DEVICE_CLOSE:
++ break;
++ }
++ return Success;
++}
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc.mieq vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc.mieq 2008-03-04 12:08:05.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/xvnc.cc 2008-03-05 11:52:34.000000000 +0100
+@@ -125,6 +125,8 @@ static bool displaySpecified = false;
+ static bool wellKnownSocketsCreated = false;
+ static char displayNumStr[16];
+
++extern void vncRingBell (int percent, int pitch, int duration);
++
+ #define swapcopy16(_dst, _src) \
+ if (needswap) { CARD16 _s = _src; cpswaps(_s, _dst); } \
+ else _dst = _src;
+@@ -925,7 +927,7 @@ void InitOutput(ScreenInfo *screenInfo,
+ int SelectWaitTime = 10000; /* usec */
+ #endif
+
+-Bool LegalModifier(unsigned int key, DevicePtr pDev)
++Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
+ {
+ return TRUE;
+ }
+@@ -936,223 +938,14 @@ void ProcessInputEvents()
+ miPointerUpdate();
+ }
+
+-/* Fairly standard US PC Keyboard */
+-
+-#define VFB_MIN_KEY 8
+-#define VFB_MAX_KEY 255
+-#define VFB_MAP_LEN (VFB_MAX_KEY - VFB_MIN_KEY + 1)
+-#define KEYSYMS_PER_KEY 2
+-KeySym keyboardMap[VFB_MAP_LEN * KEYSYMS_PER_KEY] = {
+- NoSymbol, NoSymbol,
+- XK_Escape, NoSymbol,
+- XK_1, XK_exclam,
+- XK_2, XK_at,
+- XK_3, XK_numbersign,
+- XK_4, XK_dollar,
+- XK_5, XK_percent,
+- XK_6, XK_asciicircum,
+- XK_7, XK_ampersand,
+- XK_8, XK_asterisk,
+- XK_9, XK_parenleft,
+- XK_0, XK_parenright,
+- XK_minus, XK_underscore,
+- XK_equal, XK_plus,
+- XK_BackSpace, NoSymbol,
+- XK_Tab, NoSymbol,
+- XK_q, XK_Q,
+- XK_w, XK_W,
+- XK_e, XK_E,
+- XK_r, XK_R,
+- XK_t, XK_T,
+- XK_y, XK_Y,
+- XK_u, XK_U,
+- XK_i, XK_I,
+- XK_o, XK_O,
+- XK_p, XK_P,
+- XK_bracketleft, XK_braceleft,
+- XK_bracketright, XK_braceright,
+- XK_Return, NoSymbol,
+- XK_Control_L, NoSymbol,
+- XK_a, XK_A,
+- XK_s, XK_S,
+- XK_d, XK_D,
+- XK_f, XK_F,
+- XK_g, XK_G,
+- XK_h, XK_H,
+- XK_j, XK_J,
+- XK_k, XK_K,
+- XK_l, XK_L,
+- XK_semicolon, XK_colon,
+- XK_apostrophe, XK_quotedbl,
+- XK_grave, XK_asciitilde,
+- XK_Shift_L, NoSymbol,
+- XK_backslash, XK_bar,
+- XK_z, XK_Z,
+- XK_x, XK_X,
+- XK_c, XK_C,
+- XK_v, XK_V,
+- XK_b, XK_B,
+- XK_n, XK_N,
+- XK_m, XK_M,
+- XK_comma, XK_less,
+- XK_period, XK_greater,
+- XK_slash, XK_question,
+- XK_Shift_R, NoSymbol,
+- XK_KP_Multiply, NoSymbol,
+- XK_Alt_L, XK_Meta_L,
+- XK_space, NoSymbol,
+- /*XK_Caps_Lock*/ NoSymbol, NoSymbol,
+- XK_F1, NoSymbol,
+- XK_F2, NoSymbol,
+- XK_F3, NoSymbol,
+- XK_F4, NoSymbol,
+- XK_F5, NoSymbol,
+- XK_F6, NoSymbol,
+- XK_F7, NoSymbol,
+- XK_F8, NoSymbol,
+- XK_F9, NoSymbol,
+- XK_F10, NoSymbol,
+- XK_Num_Lock, XK_Pointer_EnableKeys,
+- XK_Scroll_Lock, NoSymbol,
+- XK_KP_Home, XK_KP_7,
+- XK_KP_Up, XK_KP_8,
+- XK_KP_Prior, XK_KP_9,
+- XK_KP_Subtract, NoSymbol,
+- XK_KP_Left, XK_KP_4,
+- XK_KP_Begin, XK_KP_5,
+- XK_KP_Right, XK_KP_6,
+- XK_KP_Add, NoSymbol,
+- XK_KP_End, XK_KP_1,
+- XK_KP_Down, XK_KP_2,
+- XK_KP_Next, XK_KP_3,
+- XK_KP_Insert, XK_KP_0,
+- XK_KP_Delete, XK_KP_Decimal,
+- NoSymbol, NoSymbol,
+- NoSymbol, NoSymbol,
+- NoSymbol, NoSymbol,
+- XK_F11, NoSymbol,
+- XK_F12, NoSymbol,
+- XK_Home, NoSymbol,
+- XK_Up, NoSymbol,
+- XK_Prior, NoSymbol,
+- XK_Left, NoSymbol,
+- NoSymbol, NoSymbol,
+- XK_Right, NoSymbol,
+- XK_End, NoSymbol,
+- XK_Down, NoSymbol,
+- XK_Next, NoSymbol,
+- XK_Insert, NoSymbol,
+- XK_Delete, NoSymbol,
+- XK_KP_Enter, NoSymbol,
+- XK_Control_R, NoSymbol,
+- XK_Pause, XK_Break,
+- XK_Print, XK_Execute,
+- XK_KP_Divide, NoSymbol,
+- XK_Alt_R, XK_Meta_R,
+-};
+-
+-static Bool GetMappings(KeySymsPtr pKeySyms, CARD8 *pModMap)
+-{
+- int i;
+-
+- for (i = 0; i < MAP_LENGTH; i++)
+- pModMap[i] = NoSymbol;
+-
+- for (i = 0; i < VFB_MAP_LEN; i++) {
+- if (keyboardMap[i * KEYSYMS_PER_KEY] == XK_Caps_Lock)
+- pModMap[i + VFB_MIN_KEY] = LockMask;
+- else if (keyboardMap[i * KEYSYMS_PER_KEY] == XK_Shift_L ||
+- keyboardMap[i * KEYSYMS_PER_KEY] == XK_Shift_R)
+- pModMap[i + VFB_MIN_KEY] = ShiftMask;
+- else if (keyboardMap[i * KEYSYMS_PER_KEY] == XK_Control_L ||
+- keyboardMap[i * KEYSYMS_PER_KEY] == XK_Control_R) {
+- pModMap[i + VFB_MIN_KEY] = ControlMask;
+- }
+- else if (keyboardMap[i * KEYSYMS_PER_KEY] == XK_Alt_L ||
+- keyboardMap[i * KEYSYMS_PER_KEY] == XK_Alt_R)
+- pModMap[i + VFB_MIN_KEY] = Mod1Mask;
+- }
+-
+- pKeySyms->minKeyCode = VFB_MIN_KEY;
+- pKeySyms->maxKeyCode = VFB_MAX_KEY;
+- pKeySyms->mapWidth = KEYSYMS_PER_KEY;
+- pKeySyms->map = keyboardMap;
+-
+- return TRUE;
+-}
+-
+-static void vfbBell(int percent, DeviceIntPtr device, pointer ctrl, int class_)
+-{
+- if (percent > 0)
+- vncBell();
+-}
+-
+-static int vfbKeybdProc(DeviceIntPtr pDevice, int onoff)
+-{
+- KeySymsRec keySyms;
+- CARD8 modMap[MAP_LENGTH];
+- DevicePtr pDev = (DevicePtr)pDevice;
+-
+- switch (onoff)
+- {
+- case DEVICE_INIT:
+- GetMappings(&keySyms, modMap);
+- InitKeyboardDeviceStruct(pDev, &keySyms, modMap,
+- (BellProcPtr)vfbBell, (KbdCtrlProcPtr)NoopDDA);
+- break;
+- case DEVICE_ON:
+- pDev->on = TRUE;
+- break;
+- case DEVICE_OFF:
+- pDev->on = FALSE;
+- break;
+- case DEVICE_CLOSE:
+- break;
+- }
+- return Success;
+-}
+-
+-static int vfbMouseProc(DeviceIntPtr pDevice, int onoff)
++void DDXRingBell(int percent, int pitch, int duration)
+ {
+- BYTE map[6];
+- DevicePtr pDev = (DevicePtr)pDevice;
+-
+- switch (onoff)
+- {
+- case DEVICE_INIT:
+- map[1] = 1;
+- map[2] = 2;
+- map[3] = 3;
+- map[4] = 4;
+- map[5] = 5;
+- InitPointerDeviceStruct(pDev, map, 5, miPointerGetMotionEvents,
+- (PtrCtrlProcPtr)NoopDDA, miPointerGetMotionBufferSize());
+- break;
+-
+- case DEVICE_ON:
+- pDev->on = TRUE;
+- break;
+-
+- case DEVICE_OFF:
+- pDev->on = FALSE;
+- break;
+-
+- case DEVICE_CLOSE:
+- break;
+- }
+- return Success;
++ vncRingBell (percent, pitch, duration);
+ }
+-
+ // InitInput is called after InitExtensions, so we're guaranteed that
+ // vncExtensionInit() has already been called.
+
+ void InitInput(int argc, char *argv[])
+ {
+- DeviceIntPtr p, k;
+- p = AddInputDevice(vfbMouseProc, TRUE);
+- k = AddInputDevice(vfbKeybdProc, TRUE);
+- RegisterPointerDevice(p);
+- RegisterKeyboardDevice(k);
+- miRegisterPointerDevice(screenInfo.screens[0], p);
+- (void)mieqInit ((DevicePtr)k, (DevicePtr)p);
++ mieqInit ();
+ }
diff --git a/vnc-paint.patch b/vnc-paint.patch
new file mode 100644
index 0000000..0f8c8cb
--- /dev/null
+++ b/vnc-paint.patch
@@ -0,0 +1,109 @@
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncHooks.cc.paint vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncHooks.cc
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncHooks.cc.paint 2008-03-06 14:54:52.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncHooks.cc 2008-03-06 14:56:54.000000000 +0100
+@@ -72,8 +72,6 @@ typedef struct {
+
+ CloseScreenProcPtr CloseScreen;
+ CreateGCProcPtr CreateGC;
+- PaintWindowBackgroundProcPtr PaintWindowBackground;
+- PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+ ClearToBackgroundProcPtr ClearToBackground;
+ RestoreAreasProcPtr RestoreAreas;
+@@ -106,10 +104,6 @@ static DevPrivateKey vncHooksGCPrivateKe
+
+ static Bool vncHooksCloseScreen(int i, ScreenPtr pScreen);
+ static Bool vncHooksCreateGC(GCPtr pGC);
+-static void vncHooksPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion,
+- int what);
+-static void vncHooksPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion,
+- int what);
+ static void vncHooksCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
+ RegionPtr pOldRegion);
+ static void vncHooksClearToBackground(WindowPtr pWin, int x, int y, int w,
+@@ -231,8 +225,6 @@ Bool vncHooksInit(ScreenPtr pScreen, Xse
+
+ vncHooksScreen->CloseScreen = pScreen->CloseScreen;
+ vncHooksScreen->CreateGC = pScreen->CreateGC;
+- vncHooksScreen->PaintWindowBackground = pScreen->PaintWindowBackground;
+- vncHooksScreen->PaintWindowBorder = pScreen->PaintWindowBorder;
+ vncHooksScreen->CopyWindow = pScreen->CopyWindow;
+ vncHooksScreen->ClearToBackground = pScreen->ClearToBackground;
+ vncHooksScreen->RestoreAreas = pScreen->RestoreAreas;
+@@ -253,8 +245,6 @@ Bool vncHooksInit(ScreenPtr pScreen, Xse
+
+ pScreen->CloseScreen = vncHooksCloseScreen;
+ pScreen->CreateGC = vncHooksCreateGC;
+- pScreen->PaintWindowBackground = vncHooksPaintWindowBackground;
+- pScreen->PaintWindowBorder = vncHooksPaintWindowBorder;
+ pScreen->CopyWindow = vncHooksCopyWindow;
+ pScreen->ClearToBackground = vncHooksClearToBackground;
+ pScreen->RestoreAreas = vncHooksRestoreAreas;
+@@ -297,8 +287,6 @@ static Bool vncHooksCloseScreen(int i, S
+ SCREEN_UNWRAP(pScreen_, CloseScreen);
+
+ pScreen->CreateGC = vncHooksScreen->CreateGC;
+- pScreen->PaintWindowBackground = vncHooksScreen->PaintWindowBackground;
+- pScreen->PaintWindowBorder = vncHooksScreen->PaintWindowBorder;
+ pScreen->CopyWindow = vncHooksScreen->CopyWindow;
+ pScreen->ClearToBackground = vncHooksScreen->ClearToBackground;
+ pScreen->RestoreAreas = vncHooksScreen->RestoreAreas;
+@@ -333,38 +321,6 @@ static Bool vncHooksCreateGC(GCPtr pGC)
+ return ret;
+ }
+
+-// PaintWindowBackground - changed region is the given region
+-
+-static void vncHooksPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion,
+- int what)
+-{
+- SCREEN_UNWRAP(pWin->drawable.pScreen, PaintWindowBackground);
+-
+- RegionHelper changed(pScreen, pRegion);
+-
+- (*pScreen->PaintWindowBackground) (pWin, pRegion, what);
+-
+- vncHooksScreen->desktop->add_changed(changed.reg);
+-
+- SCREEN_REWRAP(PaintWindowBackground);
+-}
+-
+-// PaintWindowBorder - changed region is the given region
+-
+-static void vncHooksPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion,
+- int what)
+-{
+- SCREEN_UNWRAP(pWin->drawable.pScreen, PaintWindowBorder);
+-
+- RegionHelper changed(pScreen, pRegion);
+-
+- (*pScreen->PaintWindowBorder) (pWin, pRegion, what);
+-
+- vncHooksScreen->desktop->add_changed(changed.reg);
+-
+- SCREEN_REWRAP(PaintWindowBorder);
+-}
+-
+ // CopyWindow - destination of the copy is the old region, clipped by
+ // borderClip, translated by the delta. This call only does the copy - it
+ // doesn't affect any other bits.
+@@ -534,16 +490,9 @@ static void vncHooksValidateGC(GCPtr pGC
+ (*pGC->funcs->ValidateGC) (pGC, changes, pDrawable);
+
+ u.vncHooksGC->wrappedOps = 0;
+- if (pDrawable->type == DRAWABLE_WINDOW && ((WindowPtr)pDrawable)->viewable) {
+- WindowPtr pWin = (WindowPtr)pDrawable;
+- RegionPtr pRegion = &pWin->clipList;
+-
+- if (pGC->subWindowMode == IncludeInferiors)
+- pRegion = &pWin->borderClip;
+- if (REGION_NOTEMPTY(pDrawable->pScreen, pRegion)) {
+- u.vncHooksGC->wrappedOps = pGC->ops;
+- DBGPRINT((stderr,"vncHooksValidateGC: wrapped GC ops\n"));
+- }
++ if (pDrawable->type == DRAWABLE_WINDOW || pDrawable->type == DRAWABLE_PIXMAP) {
++ u.vncHooksGC->wrappedOps = pGC->ops;
++ DBGPRINT((stderr,"vncHooksValidateGC: wrapped GC ops\n"));
+ }
+ }
+
diff --git a/vnc-privates.patch b/vnc-privates.patch
new file mode 100644
index 0000000..fa3cd10
--- /dev/null
+++ b/vnc-privates.patch
@@ -0,0 +1,122 @@
+--- orig/vncHooks.cc 2009-01-03 21:58:21.000000000 +0100
++++ chng/vncHooks.cc 2009-01-03 22:00:36.000000000 +0100
+@@ -87,9 +87,15 @@
+ GCOps *wrappedOps;
+ } vncHooksGCRec, *vncHooksGCPtr;
+
+-static int vncHooksScreenIndex;
+-static int vncHooksGCIndex;
++static DevPrivateKey vncHooksScrPrivateKey = &vncHooksScrPrivateKey;
++static DevPrivateKey vncHooksGCPrivateKey = &vncHooksGCPrivateKey;
+
++#define vncHooksScreenPrivate(scrn) \
++ (vncHooksScreenPtr) dixLookupPrivate (&(scrn)->devPrivates, \
++ vncHooksScrPrivateKey)
++#define vncHooksGCPrivate(pGC) \
++ (vncHooksGCPtr) dixLookupPrivate (&(pGC)->devPrivates, \
++ vncHooksGCPrivateKey)
+
+ // screen functions
+
+@@ -208,26 +214,11 @@
+ if (vncHooksGeneration != serverGeneration) {
+ vncHooksGeneration = serverGeneration;
+
+- vncHooksScreenIndex = AllocateScreenPrivateIndex();
+- if (vncHooksScreenIndex < 0) {
+- ErrorF("vncHooksInit: AllocateScreenPrivateIndex failed\n");
+- return FALSE;
+- }
+-
+- vncHooksGCIndex = AllocateGCPrivateIndex();
+- if (vncHooksGCIndex < 0) {
+- ErrorF("vncHooksInit: AllocateGCPrivateIndex failed\n");
+- return FALSE;
+- }
+- }
+-
+- if (!AllocateGCPrivate(pScreen, vncHooksGCIndex, sizeof(vncHooksGCRec))) {
+- ErrorF("vncHooksInit: AllocateGCPrivate failed\n");
+- return FALSE;
++ if (!dixRequestPrivate (vncHooksGCPrivateKey, sizeof (vncHooksGCRec)))
++ return FALSE;
+ }
+
+ vncHooksScreen = (vncHooksScreenPtr)xnfalloc(sizeof(vncHooksScreenRec));
+- pScreen->devPrivates[vncHooksScreenIndex].ptr = (pointer)vncHooksScreen;
+
+ vncHooksScreen->desktop = desktop;
+
+@@ -267,6 +258,8 @@
+ }
+ #endif
+
++ dixSetPrivate (&pScreen->devPrivates, vncHooksScrPrivateKey, vncHooksScreen);
++
+ return TRUE;
+ }
+
+@@ -282,11 +275,10 @@
+ // distinct type, so it would have to use templates, and it's not worth that
+ // much pain.
+
+-#define SCREEN_UNWRAP(scrn,field) \
+- ScreenPtr pScreen = scrn; \
+- vncHooksScreenPtr vncHooksScreen \
+- = ((vncHooksScreenPtr)pScreen->devPrivates[vncHooksScreenIndex].ptr); \
+- pScreen->field = vncHooksScreen->field; \
++#define SCREEN_UNWRAP(scrn,field) \
++ ScreenPtr pScreen = scrn; \
++ vncHooksScreenPtr vncHooksScreen = vncHooksScreenPrivate (scrn); \
++ pScreen->field = vncHooksScreen->field; \
+ DBGPRINT((stderr,"vncHooks" #field " called\n"));
+
+ #define SCREEN_REWRAP(field) pScreen->field = vncHooks##field;
+@@ -323,8 +315,7 @@
+ {
+ SCREEN_UNWRAP(pGC->pScreen, CreateGC);
+
+- vncHooksGCPtr vncHooksGC
+- = (vncHooksGCPtr)pGC->devPrivates[vncHooksGCIndex].ptr;
++ vncHooksGCPtr vncHooksGC = vncHooksGCPrivate (pGC);
+
+ Bool ret = (*pScreen->CreateGC) (pGC);
+
+@@ -504,8 +495,7 @@
+ CARD16 height)
+ {
+ ScreenPtr pScreen = pDst->pDrawable->pScreen;
+- vncHooksScreenPtr vncHooksScreen = \
+- ((vncHooksScreenPtr)pScreen->devPrivates[vncHooksScreenIndex].ptr);
++ vncHooksScreenPtr vncHooksScreen = vncHooksScreenPrivate (pScreen);
+ BoxRec box;
+ PictureScreenPtr ps = GetPictureScreen(pScreen);
+
+@@ -540,7 +530,7 @@
+ class GCFuncUnwrapper {
+ public:
+ GCFuncUnwrapper(GCPtr pGC_) : pGC(pGC_) {
+- vncHooksGC = (vncHooksGCPtr)pGC->devPrivates[vncHooksGCIndex].ptr;
++ vncHooksGC = vncHooksGCPrivate (pGC);
+ pGC->funcs = vncHooksGC->wrappedFuncs;
+ if (vncHooksGC->wrappedOps)
+ pGC->ops = vncHooksGC->wrappedOps;
+@@ -625,7 +615,7 @@
+ GCOpUnwrapper(DrawablePtr pDrawable, GCPtr pGC_)
+ : pGC(pGC_), pScreen(pDrawable->pScreen)
+ {
+- vncHooksGC = (vncHooksGCPtr)pGC->devPrivates[vncHooksGCIndex].ptr;
++ vncHooksGC = vncHooksGCPrivate (pGC);
+ oldFuncs = pGC->funcs;
+ pGC->funcs = vncHooksGC->wrappedFuncs;
+ pGC->ops = vncHooksGC->wrappedOps;
+@@ -644,8 +634,7 @@
+ #define GC_OP_UNWRAPPER(pDrawable, pGC, name) \
+ GCOpUnwrapper u(pDrawable, pGC); \
+ ScreenPtr pScreen = (pDrawable)->pScreen; \
+- vncHooksScreenPtr vncHooksScreen \
+- = ((vncHooksScreenPtr)pScreen->devPrivates[vncHooksScreenIndex].ptr); \
++ vncHooksScreenPtr vncHooksScreen = vncHooksScreenPrivate (pScreen); \
+ DBGPRINT((stderr,"vncHooks" #name " called\n"));
+
+
diff --git a/vnc-rh212985.patch b/vnc-rh212985.patch
new file mode 100644
index 0000000..fa45c6b
--- /dev/null
+++ b/vnc-rh212985.patch
@@ -0,0 +1,33 @@
+diff -up vnc-4_1_2-unixsrc/unix/vncserver.rh212985 vnc-4_1_2-unixsrc/unix/vncserver
+--- vnc-4_1_2-unixsrc/unix/vncserver.rh212985 2008-07-16 13:55:29.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/vncserver 2008-07-16 14:17:53.000000000 +0200
+@@ -168,11 +168,25 @@ $cmd .= " >> " . &quotedString($desktopL
+ # Run $cmd and record the process ID.
+
+ $pidFile = "$vncUserDir/$host:$displayNumber.pid";
+-system("$cmd & echo \$! >$pidFile");
++system(
++"rm -f $pidFile
++ $cmd &
++ PID_TEMP=\$!
++ PID_NUM=\$PID_TEMP
++
++ # Give Xvnc a chance to start up
++
++ sleep 3;
++
++ if ps -p \$PID_NUM -o comm= | grep -q Xvnc; then
++ echo \$PID_NUM > $pidFile
++ fi"
++);
+
+-# Give Xvnc a chance to start up
+-
+-sleep(3);
++if (!(-e "$pidFile")) {
++ warn "Unable to start Xvnc, exiting\n";
++ exit;
++}
+
+ warn "\nNew '$desktopName' desktop is $host:$displayNumber\n\n";
+
diff --git a/vnc-scrollbars.patch b/vnc-scrollbars.patch
new file mode 100644
index 0000000..e611c35
--- /dev/null
+++ b/vnc-scrollbars.patch
@@ -0,0 +1,69 @@
+diff -up vnc-4_1_2-unixsrc/unix/tx/TXViewport.h.scrollbars vnc-4_1_2-unixsrc/unix/tx/TXViewport.h
+--- vnc-4_1_2-unixsrc/unix/tx/TXViewport.h.scrollbars 2008-03-14 12:44:19.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/tx/TXViewport.h 2008-03-14 12:44:19.000000000 +0100
+@@ -77,7 +77,8 @@ private:
+ int xOff, yOff;
+ rfb::Timer bumpScrollTimer;
+ bool bumpScroll;
+- bool needScrollbars;
++ bool needXScrollbar;
++ bool needYScrollbar;
+ int bumpScrollX, bumpScrollY;
+ };
+ #endif
+diff -up vnc-4_1_2-unixsrc/unix/tx/TXViewport.cxx.scrollbars vnc-4_1_2-unixsrc/unix/tx/TXViewport.cxx
+--- vnc-4_1_2-unixsrc/unix/tx/TXViewport.cxx.scrollbars 2008-03-14 12:44:19.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/tx/TXViewport.cxx 2008-03-14 13:08:30.000000000 +0100
+@@ -25,7 +25,8 @@
+ TXViewport::TXViewport(Display* dpy_, int w, int h, TXWindow* parent_)
+ : TXWindow(dpy_, w, h, parent_), child(0), hScrollbar(0),
+ vScrollbar(0), scrollbarSize(15), xOff(0), yOff(0), bumpScrollTimer(this),
+- bumpScroll(false), needScrollbars(false), bumpScrollX(0), bumpScrollY(0)
++ bumpScroll(false), needXScrollbar(false), needYScrollbar(false),
++ bumpScrollX(0), bumpScrollY(0)
+ {
+ clipper = new TXWindow(dpy, width()-scrollbarSize, height()-scrollbarSize,
+ this);
+@@ -132,13 +133,23 @@ bool TXViewport::handleTimeout(rfb::Time
+
+ void TXViewport::resizeNotify()
+ {
+- needScrollbars = (!bumpScroll &&
+- (width() < child->width() || height() < child->height()) &&
+- (width() > scrollbarSize && height() > scrollbarSize));
+- if (needScrollbars) {
++ needXScrollbar = (!bumpScroll && width() < child->width() &&
++ height() > scrollbarSize && width() > scrollbarSize);
++ needYScrollbar = (!bumpScroll && height() < child->height() &&
++ height() > scrollbarSize && width() > scrollbarSize);
++
++ if (needXScrollbar && needYScrollbar) {
+ clipper->resize(width()-scrollbarSize, height()-scrollbarSize);
+ hScrollbar->map();
+ vScrollbar->map();
++ } else if (needXScrollbar) {
++ clipper->resize(width(), height()-scrollbarSize);
++ hScrollbar->map();
++ vScrollbar->unmap();
++ } else if (needYScrollbar) {
++ clipper->resize(width()-scrollbarSize, height());
++ hScrollbar->unmap();
++ vScrollbar->map();
+ } else {
+ clipper->resize(width(), height());
+ hScrollbar->unmap();
+@@ -147,10 +158,13 @@ void TXViewport::resizeNotify()
+
+ setOffset(xOff, yOff);
+
+- if (needScrollbars) {
++ if (needXScrollbar) {
+ hScrollbar->move(0, height()-scrollbarSize);
+ hScrollbar->resize(width()-scrollbarSize, scrollbarSize);
+ hScrollbar->set(child->width(), -xOff, width()-scrollbarSize);
++ }
++
++ if (needYScrollbar) {
+ vScrollbar->move(width()-scrollbarSize, 0);
+ vScrollbar->resize(scrollbarSize, height()-scrollbarSize);
+ vScrollbar->set(child->height(), -yOff, height()-scrollbarSize);
diff --git a/vnc-selections.patch b/vnc-selections.patch
new file mode 100644
index 0000000..80e7239
--- /dev/null
+++ b/vnc-selections.patch
@@ -0,0 +1,78 @@
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncExtInit.cc.selections vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncExtInit.cc
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncExtInit.cc.selections 2008-03-10 15:34:24.000000000 +0100
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/vnc/vncExtInit.cc 2008-03-11 10:55:44.000000000 +0100
+@@ -62,11 +62,9 @@ extern "C" {
+ static void SendSelectionChangeEvent(Atom selection);
+ static int ProcVncExtDispatch(ClientPtr client);
+ static int SProcVncExtDispatch(ClientPtr client);
++ static void vncSelectionCallback(CallbackListPtr *callbacks, pointer data, pointer args);
+
+ extern char *display;
+-
+- extern Selection *CurrentSelections;
+- extern int NumCurrentSelections;
+ }
+
+ using namespace rfb;
+@@ -99,7 +97,6 @@ struct VncInputSelect {
+ VncInputSelect* next;
+ };
+
+-static int nPrevSelections = 0;
+ static TimeStamp* prevSelectionTimes = 0;
+
+ static int vncErrorBase = 0;
+@@ -147,6 +144,10 @@ void vncExtensionInit()
+ FatalError("AddCallback failed\n");
+ }
+
++ if (!AddCallback(&SelectionCallback, vncSelectionCallback, 0)) {
++ FatalError("Add selection callback failed\n");
++ }
++
+ try {
+ if (!initialised) {
+ rfb::initStdIOLoggers();
+@@ -212,6 +213,14 @@ static void vncResetProc(ExtensionEntry*
+ {
+ }
+
++static void vncSelectionCallback(CallbackListPtr *callbacks, pointer data, pointer args)
++{
++ SelectionInfoRec *info = (SelectionInfoRec *) args;
++ Selection *selection = info->selection;
++
++ SendSelectionChangeEvent(selection->selection);
++}
++
+ //
+ // vncBlockHandler - called just before the X server goes into select(). Call
+ // on to the block handler for each desktop. Then check whether any of the
+@@ -227,27 +236,6 @@ static void vncBlockHandler(pointer data
+ desktop[scr]->blockHandler(fds);
+ }
+ }
+-
+- if (nPrevSelections != NumCurrentSelections) {
+- prevSelectionTimes
+- = (TimeStamp*)xnfrealloc(prevSelectionTimes,
+- NumCurrentSelections * sizeof(TimeStamp));
+- for (int i = nPrevSelections; i < NumCurrentSelections; i++) {
+- prevSelectionTimes[i].months = 0;
+- prevSelectionTimes[i].milliseconds = 0;
+- }
+- nPrevSelections = NumCurrentSelections;
+- }
+- for (int i = 0; i < NumCurrentSelections; i++) {
+- if (CurrentSelections[i].lastTimeChanged.months
+- != prevSelectionTimes[i].months ||
+- CurrentSelections[i].lastTimeChanged.milliseconds
+- != prevSelectionTimes[i].milliseconds)
+- {
+- SendSelectionChangeEvent(CurrentSelections[i].selection);
+- prevSelectionTimes[i] = CurrentSelections[i].lastTimeChanged;
+- }
+- }
+ }
+
+ static void vncWakeupHandler(pointer data, int nfds, pointer readmask)
diff --git a/vnc-viewerIPv6.patch b/vnc-viewerIPv6.patch
new file mode 100644
index 0000000..c841e06
--- /dev/null
+++ b/vnc-viewerIPv6.patch
@@ -0,0 +1,181 @@
+diff -up vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx.ipv6 vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx
+--- vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx.ipv6 2008-06-02 10:22:17.000000000 +0200
++++ vnc-4_1_2-unixsrc/common/network/TcpSocket.cxx 2008-06-02 10:49:04.000000000 +0200
+@@ -109,50 +109,99 @@ TcpSocket::TcpSocket(int sock, bool clos
+ TcpSocket::TcpSocket(const char *host, int port)
+ : closeFd(true)
+ {
+- int sock;
++#define CAST_ADDR(x) (*((struct x *)&addr))
++ int sock, err, family, result = -1;
++ size_t addrlen;
++ struct sockaddr_storage addr;
++#ifdef HAVE_GETADDRINFO
++ struct addrinfo *ai, *current, hints;
++#endif
+
+ // - Create a socket
+ initSockets();
+- if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+- throw SocketException("unable to create socket", errorNumber);
+
+-#ifndef WIN32
+- // - By default, close the socket on exec()
+- fcntl(sock, F_SETFD, FD_CLOEXEC);
+-#endif
++#ifdef HAVE_GETADDRINFO
++ memset(&hints, 0, sizeof(struct addrinfo));
++ hints.ai_family = AF_UNSPEC;
++ hints.ai_socktype = SOCK_STREAM;
++ hints.ai_canonname = NULL;
++ hints.ai_addr = NULL;
++ hints.ai_next = NULL;
++
++ if ((result = getaddrinfo(host, NULL, &hints, &ai)) != 0) {
++ throw Exception("unable to resolve host by name: %s",
++ gai_strerror(result));
++ }
++
++ for (current = ai; current != NULL; current = current->ai_next) {
++ family = current->ai_family;
++ if (family != AF_INET && family != AF_INET6)
++ continue;
++
++ addrlen = current->ai_addrlen;
++ memcpy(&addr, current->ai_addr, addrlen);
++
++ if (family == AF_INET)
++ CAST_ADDR(sockaddr_in).sin_port = htons(port);
++ else
++ CAST_ADDR(sockaddr_in6).sin6_port = htons(port);
+
+- // - Connect it to something
++#else
++ family = AF_INET;
++ addrlen = sizeof(struct sockaddr_in);
+
+- // Try processing the host as an IP address
+- struct sockaddr_in addr;
+- memset(&addr, 0, sizeof(addr));
+- addr.sin_family = AF_INET;
+- addr.sin_addr.s_addr = inet_addr(host);
+- addr.sin_port = htons(port);
+- if ((int)addr.sin_addr.s_addr == -1) {
+- // Host was not an IP address - try resolving as DNS name
+- struct hostent *hostinfo;
+- hostinfo = gethostbyname(host);
+- if (hostinfo && hostinfo->h_addr) {
+- addr.sin_addr.s_addr = ((struct in_addr *)hostinfo->h_addr)->s_addr;
+- } else {
+- int e = errorNumber;
+- closesocket(sock);
+- throw SocketException("unable to resolve host by name", e);
++ // Try processing the host as an IP address
++ memset(&addr, 0, addrlen);
++ CAST_ADDR(sockaddr_in).sin_family = AF_INET;
++ CAST_ADDR(sockaddr_in).sin_addr.s_addr = inet_addr(host);
++ CAST_ADDR(sockaddr_in).sin_port = htons(port);
++ if ((int)CAST_ADDR(sockaddr_in).sin_addr.s_addr == -1) {
++ // Host was not an IP address - try resolving as DNS name
++ struct hostent *hostinfo;
++ hostinfo = gethostbyname(host);
++ if (hostinfo && hostinfo->h_addr) {
++ CAST_ADDR(sockaddr_in).sin_addr.s_addr =
++ ((struct in_addr *)hostinfo->h_addr)->s_addr;
++ } else {
++ err = errorNumber;
++ throw SocketException("unable to resolve host by name", err);
++ }
++ }
++#endif
++ sock = socket (family, SOCK_STREAM, 0);
++ if (sock == -1) {
++ err = errorNumber;
++#ifdef HAVE_GETADDRINFO
++ freeaddrinfo(ai);
++#endif
++ throw SocketException("unable to create socket", err);
+ }
+- }
+
+- // Attempt to connect to the remote host
+- for (;;) {
+- if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
+- int e = errorNumber;
+- if (e == EINTR)
+- continue;
++ // Attempt to connect to the remote host
++ while ((result = connect(sock, (struct sockaddr *)&addr, addrlen)) == -1) {
++ err = errorNumber;
++ if (err == EINTR)
++ continue;
+ closesocket(sock);
+- throw SocketException("unable to connect to host", e);
+- } else break;
++ break;
++ }
++#ifdef HAVE_GETADDRINFO
++ if (result == 0)
++ break;
++ else
++ continue;
+ }
+
++ freeaddrinfo(ai);
++#endif
++ if (result == -1)
++ throw SocketException("unable connect to socket", err);
++
++#ifndef WIN32
++ // - By default, close the socket on exec()
++ fcntl(sock, F_SETFD, FD_CLOEXEC);
++#endif
++
+ // Disable Nagle's algorithm, to reduce latency
+ enableNagles(sock, false);
+
+diff -up vnc-4_1_2-unixsrc/common/rdr/Exception.cxx.ipv6 vnc-4_1_2-unixsrc/common/rdr/Exception.cxx
+--- vnc-4_1_2-unixsrc/common/rdr/Exception.cxx.ipv6 2008-06-02 10:23:35.000000000 +0200
++++ vnc-4_1_2-unixsrc/common/rdr/Exception.cxx 2008-06-02 10:28:51.000000000 +0200
+@@ -22,8 +22,23 @@
+ #include <winsock2.h>
+ #endif
+
++#include <stdarg.h>
++
+ using namespace rdr;
+
++Exception::Exception(const char *format, ...) {
++ va_list ap;
++ int result;
++
++ va_start(ap, format);
++ result = vsnprintf(str_, len, format, ap);
++ va_end(ap);
++
++ /* XXX - ensure that string ends correctly */
++ if (result > len)
++ str_[len - 1] = '\0';
++}
++
+ SystemException::SystemException(const char* s, int err_)
+ : Exception(s), err(err_)
+ {
+diff -up vnc-4_1_2-unixsrc/common/rdr/Exception.h.ipv6 vnc-4_1_2-unixsrc/common/rdr/Exception.h
+--- vnc-4_1_2-unixsrc/common/rdr/Exception.h.ipv6 2008-06-02 10:23:05.000000000 +0200
++++ vnc-4_1_2-unixsrc/common/rdr/Exception.h 2008-06-02 10:28:41.000000000 +0200
+@@ -27,13 +27,7 @@ namespace rdr {
+ struct Exception {
+ enum { len = 256 };
+ char str_[len];
+- Exception(const char* s=0) {
+- str_[0] = 0;
+- if (s)
+- strncat(str_, s, len-1);
+- else
+- strcat(str_, "Exception");
+- }
++ Exception(const char *format, ...);
+ virtual const char* str() const { return str_; }
+ };
+
diff --git a/vnc-vsnprintf.patch b/vnc-vsnprintf.patch
new file mode 100644
index 0000000..8abe7d0
--- /dev/null
+++ b/vnc-vsnprintf.patch
@@ -0,0 +1,20 @@
+--- vnc-4_1_2-unixsrc/common/rfb/Logger.cxx.vsnprintf 2007-02-26 12:29:25.000000000 +0100
++++ vnc-4_1_2-unixsrc/common/rfb/Logger.cxx 2007-02-26 12:30:03.000000000 +0100
+@@ -34,7 +34,7 @@
+
+ using namespace rfb;
+
+-#ifndef HAVE_VSNPRINTF
++/*#ifndef HAVE_VSNPRINTF
+ #ifdef __RFB_THREADING_IMPL
+ static Mutex fpLock;
+ #endif
+@@ -63,7 +63,7 @@
+ return len;
+ }
+ #endif
+-
++*/
+
+ Logger* Logger::loggers = 0;
+
diff --git a/vnc-xorg.patch b/vnc-xorg.patch
new file mode 100644
index 0000000..ef9dc85
--- /dev/null
+++ b/vnc-xorg.patch
@@ -0,0 +1,65 @@
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/configure.ac.vnc vnc-4_1_2-unixsrc/unix/xorg-server/configure.ac
+--- vnc-4_1_2-unixsrc/unix/xorg-server/configure.ac.vnc 2008-10-03 14:27:43.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/xorg-server/configure.ac 2008-10-03 14:29:10.000000000 +0200
+@@ -30,7 +30,6 @@ AC_INIT([xorg-server], 1.5.1, [https://b
+ RELEASE_DATE="23 September 2008"
+ AC_CONFIG_SRCDIR([Makefile.am])
+ AM_INIT_AUTOMAKE([dist-bzip2 foreign])
+-AM_MAINTAINER_MODE
+
+ dnl this gets generated by autoheader, and thus contains all the defines. we
+ dnl don't ever actually use it, internally.
+@@ -1214,6 +1213,13 @@ if test "x$XVFB" = xyes; then
+ AC_SUBST([XVFB_SYS_LIBS])
+ fi
+
++dnl Xvnc DDX
++AC_SUBST([XVNC_CPPFLAGS], ["-DHAVE_DIX_CONFIG_H $XEXT_INC $FB_INC $MI_INC $RENDER_INC"])
++AC_SUBST([XVNC_LIBS], ["$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"])
++
++dnl Xvnc DDX
++AC_SUBST([XVNC_CPPFLAGS], ["-DHAVE_DIX_CONFIG_H $XEXT_INC $FB_INC $MI_INC $RENDER_INC"])
++AC_SUBST([XVNC_LIBS], ["$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"])
+
+ dnl Xnest DDX
+
+@@ -2178,6 +2184,7 @@ hw/dmx/input/Makefile
+ hw/dmx/glxProxy/Makefile
+ hw/dmx/Makefile
+ hw/vfb/Makefile
++hw/vnc/Makefile
+ hw/xgl/Makefile
+ hw/xgl/egl/Makefile
+ hw/xgl/egl/module/Makefile
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/hw/Makefile.am.vnc vnc-4_1_2-unixsrc/unix/xorg-server/hw/Makefile.am
+--- vnc-4_1_2-unixsrc/unix/xorg-server/hw/Makefile.am.vnc 2008-10-03 14:27:44.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/xorg-server/hw/Makefile.am 2008-10-03 14:27:47.000000000 +0200
+@@ -43,7 +43,8 @@ SUBDIRS = \
+ $(DMX_SUBDIRS) \
+ $(KDRIVE_SUBDIRS) \
+ $(XQUARTZ_SUBDIRS) \
+- $(XPRINT_SUBDIRS)
++ $(XPRINT_SUBDIRS) \
++ vnc
+
+ DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xgl xprint
+
+diff -up vnc-4_1_2-unixsrc/unix/xorg-server/mi/miinitext.c.vnc vnc-4_1_2-unixsrc/unix/xorg-server/mi/miinitext.c
+--- vnc-4_1_2-unixsrc/unix/xorg-server/mi/miinitext.c.vnc 2008-10-03 14:27:44.000000000 +0200
++++ vnc-4_1_2-unixsrc/unix/xorg-server/mi/miinitext.c 2008-10-03 14:27:47.000000000 +0200
+@@ -292,6 +292,7 @@ extern void BigReqExtensionInit(INITARGS
+ #ifdef MITMISC
+ extern void MITMiscExtensionInit(INITARGS);
+ #endif
++extern void vncExtensionInit(INITARGS);
+ #ifdef XIDLE
+ extern void XIdleExtensionInit(INITARGS);
+ #endif
+@@ -566,6 +567,7 @@ InitExtensions(argc, argv)
+ #ifdef MITMISC
+ if (!noMITMiscExtension) MITMiscExtensionInit();
+ #endif
++ vncExtensionInit();
+ #ifdef XIDLE
+ if (!noXIdleExtension) XIdleExtensionInit();
+ #endif