307f30f
diff -up xorg-server-1.17.1/configure.ac.xserver116-rebased xorg-server-1.17.1/configure.ac
307f30f
--- xorg-server-1.17.1/configure.ac.xserver116-rebased	2015-02-10 22:43:52.000000000 +0000
307f30f
+++ xorg-server-1.17.1/configure.ac	2015-02-13 16:14:05.074515927 +0000
307f30f
@@ -74,6 +74,7 @@ dnl forcing an entire recompile.x
307f30f
 AC_CONFIG_HEADERS(include/version-config.h)
307f30f
 
307f30f
 AM_PROG_AS
307f30f
+AC_PROG_CXX
307f30f
 AC_PROG_LN_S
307f30f
 LT_PREREQ([2.2])
307f30f
 LT_INIT([disable-static win32-dll])
307f30f
@@ -1795,6 +1796,10 @@ if test "x$XVFB" = xyes; then
307f30f
 	AC_SUBST([XVFB_SYS_LIBS])
307f30f
 fi
307f30f
 
307f30f
+dnl Xvnc DDX
307f30f
+AC_SUBST([XVNC_CPPFLAGS], ["-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"])
307f30f
+AC_SUBST([XVNC_LIBS], ["$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $MAIN_LIB"])
307f30f
+AC_SUBST([XVNC_SYS_LIBS], ["$GLX_SYS_LIBS"])
307f30f
 
307f30f
 dnl Xnest DDX
307f30f
 
307f30f
@@ -1830,6 +1835,8 @@ if test "x$XORG" = xauto; then
307f30f
 fi
307f30f
 AC_MSG_RESULT([$XORG])
307f30f
 
307f30f
+AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
307f30f
+
307f30f
 if test "x$XORG" = xyes; then
307f30f
 	XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common'
307f30f
 	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
307f30f
@@ -2059,7 +2066,6 @@ if test "x$XORG" = xyes; then
307f30f
 	AC_DEFINE(XORG_SERVER, 1, [Building Xorg server])
307f30f
 	AC_DEFINE(XORGSERVER, 1, [Building Xorg server])
307f30f
 	AC_DEFINE(XFree86Server, 1, [Building XFree86 server])
307f30f
-	AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
307f30f
 	AC_DEFINE(NEED_XF86_TYPES, 1, [Need XFree86 typedefs])
307f30f
 	AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions])
307f30f
 	AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
307f30f
@@ -2599,6 +2605,7 @@ hw/dmx/Makefile
307f30f
 hw/dmx/man/Makefile
307f30f
 hw/vfb/Makefile
307f30f
 hw/vfb/man/Makefile
307f30f
+hw/vnc/Makefile
307f30f
 hw/xnest/Makefile
307f30f
 hw/xnest/man/Makefile
307f30f
 hw/xwin/Makefile
307f30f
diff -up xorg-server-1.17.1/hw/Makefile.am.xserver116-rebased xorg-server-1.17.1/hw/Makefile.am
307f30f
--- xorg-server-1.17.1/hw/Makefile.am.xserver116-rebased	2014-04-16 21:24:00.000000000 +0100
307f30f
+++ xorg-server-1.17.1/hw/Makefile.am	2015-02-13 16:14:05.131516821 +0000
307f30f
@@ -38,7 +38,8 @@ SUBDIRS =			\
307f30f
 	$(DMX_SUBDIRS)		\
307f30f
 	$(KDRIVE_SUBDIRS)	\
307f30f
 	$(XQUARTZ_SUBDIRS)	\
307f30f
-	$(XWAYLAND_SUBDIRS)
307f30f
+	$(XWAYLAND_SUBDIRS)	\
307f30f
+	vnc
307f30f
 
307f30f
 DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xwayland
307f30f
 
307f30f
diff -up xorg-server-1.17.1/mi/miinitext.c.xserver116-rebased xorg-server-1.17.1/mi/miinitext.c
307f30f
--- xorg-server-1.17.1/mi/miinitext.c.xserver116-rebased	2015-01-17 23:42:52.000000000 +0000
307f30f
+++ xorg-server-1.17.1/mi/miinitext.c	2015-02-13 16:14:05.131516821 +0000
307f30f
@@ -111,6 +111,10 @@ SOFTWARE.
307f30f
 #include "micmap.h"
307f30f
 #include "globals.h"
307f30f
 
307f30f
+#ifdef TIGERVNC
307f30f
+extern void vncExtensionInit(INITARGS);
307f30f
+#endif
307f30f
+
307f30f
 /* The following is only a small first step towards run-time
307f30f
  * configurable extensions.
307f30f
  */
307f30f
@@ -235,6 +239,9 @@ EnableDisableExtensionError(const char *
307f30f
 
307f30f
 /* List of built-in (statically linked) extensions */
307f30f
 static const ExtensionModule staticExtensions[] = {
307f30f
+#ifdef TIGERVNC
307f30f
+    {vncExtensionInit, "VNC-EXTENSION", NULL},
307f30f
+#endif
307f30f
     {GEExtensionInit, "Generic Event Extension", &noGEExtension},
307f30f
     {ShapeExtensionInit, "SHAPE", NULL},
307f30f
 #ifdef MITSHM
307f30f
diff -up xorg-server-1.17.1/os/WaitFor.c.xserver116-rebased xorg-server-1.17.1/os/WaitFor.c
307f30f
--- xorg-server-1.17.1/os/WaitFor.c.xserver116-rebased	2015-01-26 18:40:30.000000000 +0000
307f30f
+++ xorg-server-1.17.1/os/WaitFor.c	2015-02-13 16:14:05.132516837 +0000
307f30f
@@ -125,6 +125,9 @@ static void DoTimer(OsTimerPtr timer, CA
307f30f
 static void CheckAllTimers(void);
307f30f
 static volatile OsTimerPtr timers = NULL;
307f30f
 
307f30f
+extern void vncWriteBlockHandler(fd_set *fds);
307f30f
+extern void vncWriteWakeupHandler(int nfds, fd_set *fds);
307f30f
+
307f30f
 /*****************
307f30f
  * WaitForSomething:
307f30f
  *     Make the server suspend until there is
307f30f
@@ -150,6 +153,7 @@ WaitForSomething(int *pClientsReady)
307f30f
     INT32 timeout = 0;
307f30f
     fd_set clientsReadable;
307f30f
     fd_set clientsWritable;
307f30f
+    fd_set socketsWritable;
307f30f
     int curclient;
307f30f
     int selecterr;
307f30f
     static int nready;
307f30f
@@ -212,6 +216,9 @@ WaitForSomething(int *pClientsReady)
307f30f
             XFD_COPYSET(&AllSockets, &LastSelectMask);
307f30f
         }
307f30f
 
307f30f
+        FD_ZERO(&socketsWritable);
307f30f
+        vncWriteBlockHandler(&socketsWritable);
307f30f
+
307f30f
         BlockHandler((void *) &wt, (void *) &LastSelectMask);
307f30f
         if (NewOutputPending)
307f30f
             FlushAllOutput();
307f30f
@@ -223,10 +230,20 @@ WaitForSomething(int *pClientsReady)
307f30f
             i = Select(MaxClients, &LastSelectMask, &clientsWritable, NULL, wt);
307f30f
         }
307f30f
         else {
307f30f
-            i = Select(MaxClients, &LastSelectMask, NULL, NULL, wt);
307f30f
+	    if (AnyClientsWriteBlocked)
307f30f
+		XFD_ORSET(&socketsWritable, &ClientsWriteBlocked, &socketsWritable);
307f30f
+
307f30f
+	    if (XFD_ANYSET(&socketsWritable)) {
307f30f
+		i = Select(MaxClients, &LastSelectMask, &socketsWritable, NULL, wt);
307f30f
+		if (AnyClientsWriteBlocked)
307f30f
+		    XFD_ANDSET(&clientsWritable, &socketsWritable, &ClientsWriteBlocked);
307f30f
+	    } else {
307f30f
+		i = Select(MaxClients, &LastSelectMask, NULL, NULL, wt);
307f30f
+	    }
307f30f
         }
307f30f
         selecterr = GetErrno();
307f30f
         WakeupHandler(i, (void *) &LastSelectMask);
307f30f
+	vncWriteWakeupHandler(i, &socketsWritable);
307f30f
         if (i <= 0) {           /* An error or timeout occurred */
307f30f
             if (dispatchException)
307f30f
                 return 0;