6969277 Upgrade to TigerVNC 1.0.1
authorAlan Coopersmith <Alan.Coopersmith@Oracle.COM>
Thu, 15 Jul 2010 17:25:40 -0700
changeset 981 34c4991cc8b6
parent 980 c30d0dbf2c96
child 982 10aaecd48644
6969277 Upgrade to TigerVNC 1.0.1
open-src/xserver/xvnc/Makefile
open-src/xserver/xvnc/README.txt
open-src/xserver/xvnc/c++public.patch
open-src/xserver/xvnc/capslock.patch
open-src/xserver/xvnc/solaris-port.patch
open-src/xserver/xvnc/tigervnc-port-to-1.7.patch
open-src/xserver/xvnc/upstream-input-refactor.patch
open-src/xserver/xvnc/upstream-modkeystick.patch
open-src/xserver/xvnc/upstream-port-to-1.7.patch
open-src/xserver/xvnc/vnc-nobuildtime.patch
open-src/xserver/xvnc/vnc-nohttpd.patch
open-src/xserver/xvnc/vnc-samemachine-ipv6.patch
open-src/xserver/xvnc/vncserver-urandom.patch
open-src/xserver/xvnc/vncviewer-connect.patch
--- a/open-src/xserver/xvnc/Makefile	Tue Jul 13 18:22:30 2010 -0700
+++ b/open-src/xserver/xvnc/Makefile	Thu Jul 15 17:25:40 2010 -0700
@@ -39,11 +39,11 @@
 MODULE_LICENSE_SET      = yes
 
 # Version number (used in path names)
-MODULE_VERSION=1.0.0
+MODULE_VERSION=1.0.1
 
 # Checksums for upstream tarball
-TARBALL_MD5  = 622c6689a66651419b5431efdee99d5a
-TARBALL_SHA1 = 2435ea2e3c34a4055350f7680a94cea580b92979
+TARBALL_MD5  = daca3eb16afe65253b766eccb8bfdbc5
+TARBALL_SHA1 = 0c3dd6a3540966fea979a06df08c3aa9bdd1dc67
 
 # Source tarball
 SOURCE_TARBALL_NAME=$(MODULE_NAME)-$(MODULE_VERSION).tar.gz
@@ -63,17 +63,12 @@
 SOURCE_PATCHES = \
 	upstream-xorg-version.patch,-p1 \
 	upstream-input-refactor.patch,-p1 \
-	tigervnc-port-to-1.7.patch \
+	upstream-modkeystick.patch,-p1 \
+	upstream-port-to-1.7.patch,-p1 \
 	tigervnc-xserver17.patch \
-	vnc-samemachine-ipv6.patch,-p1 \
-	c++public.patch,-p1 \
-	vncserver-urandom.patch,-p1 \
 	vnc-nobuildtime.patch \
 	vnc-nohttpd.patch \
-	vncviewer-connect.patch,-p1 \
-	upstream-modkeystick.patch,-p0 \
-	solaris-port.patch \
-	capslock.patch
+	solaris-port.patch
 
 # ARC cases that covered this module
 # PSARC/2007/545 Xvnc
@@ -145,7 +140,7 @@
 $(XORG_TARBALL):
 	(cd ../xorg && $(MAKE) $(MAKEFLAGS) download)
 
-$(XORG_SOURCE_INIT_TARGET): $(XORG_TARBALL)
+$(XORG_SOURCE_INIT_TARGET): $(XORG_TARBALL) $(LNDIR)
 	mkdir -p $(SOURCE_DIR)/unix
 	$(MAKE) $(MAKEFLAGS) init_source \
 		NO_RECURSE="$(POUND_SIGN)" \
--- a/open-src/xserver/xvnc/README.txt	Tue Jul 13 18:22:30 2010 -0700
+++ b/open-src/xserver/xvnc/README.txt	Thu Jul 15 17:25:40 2010 -0700
@@ -1,6 +1,6 @@
 ###############################################################################
 #
-# Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -38,7 +38,7 @@
 
    Upstream:
 	Original: http://www.tigervnc.com/
-	Fedora patches: http://cvs.fedoraproject.org/viewcvs/rpms/vnc/
+	Fedora patches: http://cvs.fedoraproject.org/viewcvs/rpms/tigervnc/
 
    1. Please provide a brief description of the feature and how it is used.
 
@@ -79,19 +79,19 @@
 
    6. Please list the minimum system requirements.
 
-      System running Solaris 10U5 or Nevada.
+      System running Solaris 10U5 or later.
 
    7. List the things (GUI, commands, packages, binaries, configuration files,
       etc.) that are introduced, removed, or have substantially changed by
       this feature or project.
 
-      New package SUNWxvnc:
+  New package SUNWxvnc (S10) / pkg:/x11/server/xvnc (IPS):
 	  /usr/bin/vncpasswd
 	  /usr/bin/vncserver
 	  /usr/bin/x0vncserver
 	  /usr/bin/Xvnc	
       
-      New package SUNWvncviewer:
+  New package SUNWvncviewer (S10) / pkg:/desktop/remote-desktop/tigervnc (IPS):
 	  /usr/bin/vncviewer
 
    8. What major data structures have changed or have been added?
@@ -142,8 +142,92 @@
   16.  If available, please provide a pointer to the cookbook procedures 
        for installation and configuration.
 
-	   See test case instructions in bugster bug id 6572087.
+Updated from test case instructions in bugster bug id 6572087,
+these are several common ways of configuring Xvnc to run:
+
+1) Starting on demand from inetd, displaying graphical login screen:
+
+  a) If using dtlogin (Solaris 10):
+
+     # Enable XDMCP connections on dtlogin by removing "-udpport 0" from args
+     # Warning: restart will kill all current dtlogin sessions!
+	svccfg -s cde-login setprop 'dtlogin/args=""'
+	svcadm refresh cde-login
+	svcadm restart cde-login
+
+     If using gdm (optional in Solaris 10, default in later releases):
 
+     Enable XDMCP connections in gdm by editing /etc/gdm/custom.conf
+     (GDM 2.30 & later) or /etc/X11/gdm/custom.conf (older GDM's) to
+     contain:
+	[xdmcp]
+	Enable=true
+
+     If it wasn't already there, then run "svcadm restart gdm" to activate.
+     ( Warning: restart will kill all current gdm sessions!)
+
+  b) For either dtlogin or gdm:
+
+    # Add xvnc service to /etc/services if it isn't already there
+    # (it was added in snv_99 but is not in any S10 update release)
+	printf "vnc-server\t5900/tcp\t\t\t# VNC Server\n" >> /etc/services
+    # Enable Xvnc inetd service:
+	inetadm -e xvnc-inetd
+
+    Connect from another machine with:
+	vncviewer hostname:0
+    and verify you see the login screen and can login to a desktop session.
+
+2) Starting at system boot from display manager, displaying login screen:
+
+   a) Add a display1 instance of x11-server service for configuration
+      and configure it to run Xvnc:
 
+	svccfg -s application/x11/x11-server add display1
+	svccfg -s application/x11/x11-server:display1 addpg options application
+	svccfg -s application/x11/x11-server:display1 addpropvalue options/server astring: "/usr/X11/bin/Xvnc"
+	svccfg -s application/x11/x11-server:display1 addpropvalue options/server_args astring: '"SecurityTypes=None"'
 
+  b) If using dtlogin (Solaris 10):
+    # Configure dtlogin to start it
+	mkdir -p /etc/dt/config
+	cp /usr/dt/config/Xservers /etc/dt/config/Xservers
+	echo "   :1   Local local_uid@none root /usr/X11/bin/Xserver :1" >> /etc/dt/config/Xservers
+	pkill -HUP dtlogin
 
+     If using gdm 2.30 or later (snv_130 or later):
+        ck-seat-tool -a --display-type=Local  display=:1
+
+  c) Connect from another machine with:
+	vncviewer hostname:1
+    and verify you see the login screen and can login to a desktop session.
+
+3) Starting manually, displaying session of user who started it, requiring
+VNC password (separate from Unix login password, not securely encoded on 
+disk or across the network, so don't use a valuable password):
+
+	/usr/bin/vncserver -httpd
+
+    From another machine, open a web browser and go to
+	http://hostname:5802/
+
+    (Assuming vncserver said it was starting on display :2 - if it listed
+     another display number, change :5802 to 5800 + the display id.)
+
+    Enter the password you provided to the vncserver script when it asked
+    and verify you see a simple desktop session in the viewer.
+
+    When done testing, kill the session with:
+
+    	 vncserver -kill :2
+
+    (again, substituting display value as necessary)
+
+4) Login to a normal/local X desktop session, open a terminal window and
+   run:
+	x0vncserver --SecurityTypes=None
+
+   Connect from another machine with:
+	vncviewer hostname:0
+   and verify you see and can control the existing session you ran
+   x0vncserver in.
--- a/open-src/xserver/xvnc/c++public.patch	Tue Jul 13 18:22:30 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-From 0484f53350a00f072018b36349d13c5f2bce80c4 Mon Sep 17 00:00:00 2001
-From: Alan Coopersmith <[email protected]>
-Date: Fri, 6 Nov 2009 16:34:51 -0800
-Subject: [PATCH] Redefine "public" structure member to avoid clash with C++ keyword
-
-Needed to prevent errors when compiling with Sun C++ compiler:
-"../../include/inputstr.h", line 427: Warning: declarator required in declaration.
-"../../include/inputstr.h", line 427: Error: Use ";" to terminate declarations.
-"../../include/inputstr.h", line 427: Error: No ":" found following "public".
-"../../include/inputstr.h", line 427: Error: "}" expected instead of ";".
-"../../include/inputstr.h", line 427: Warning: declarator required in declaration.
----
- unix/xserver/hw/vnc/vncExtInit.cc |    2 ++
- 1 files changed, 2 insertions(+), 0 deletions(-)
-
-diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
-index a15a77b..0364adc 100644
---- a/unix/xserver/hw/vnc/vncExtInit.cc
-+++ b/unix/xserver/hw/vnc/vncExtInit.cc
-@@ -24,6 +24,7 @@
- 
- extern "C" {
- #define class c_class
-+#define public c_public
- #define NEED_EVENTS
- #include <X11/X.h>
- #include <X11/Xproto.h>
-@@ -38,6 +39,7 @@ extern "C" {
- #include "vncExt.h"
- #undef class
- #undef xalloc
-+#undef public
- }
- 
- #include <rfb/Configuration.h>
--- 
-1.5.6.5
-
--- a/open-src/xserver/xvnc/capslock.patch	Tue Jul 13 18:22:30 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
---- unix/xserver/hw/vnc/Input.cc	Tue May 11 13:29:10 2010
-+++ unix/xserver/hw/vnc/Input.cc.new	Tue May 11 13:11:55 2010
-@@ -436,8 +436,28 @@
-  * 1.6 (aka MPX - Multi pointer X)
-  * - multiple master devices (= core devices) exists, keep vncKeyboardDevice
-  *   synchronized with proper master device
-+ *
-+ * 1.7
-+ * - Need to fix per-keysym memory leak but not with goto's
-  */
- 
-+#if XORG >= 17
-+#define CLEANUP_RETURN			\
-+    {					\
-+	xfree(modKeyMap);		\
-+	if (keymap)			\
-+	{				\
-+		xfree(keymap->map);	\
-+		xfree(keymap);		\
-+	}				\
-+	return;				\
-+    }
-+#else
-+#define CLEANUP_RETURN			\
-+	return;
-+#endif
-+
-+
- void KeyboardDevice::keyEvent(rdr::U32 keysym, bool down)
- {
- 	DeviceIntPtr master;
-@@ -458,7 +478,7 @@
- 
- 	if (keysym == XK_Caps_Lock) {
- 		vlog.debug("Ignoring caps lock");
--		goto cleanup;
-+		CLEANUP_RETURN
- 	}
- 
- #if XORG >= 17
-@@ -465,8 +485,8 @@
- 	int ret = generate_modkeymap(serverClient, dev, &modKeyMap,
- 					     &maxKeysPerModifier);
- 	if (ret != Success)
--		goto cleanup;
--	modState = XkbStateFieldFromRec(&keyc->xkbInfo->state);
-+		CLEANUP_RETURN
-+	modState = XkbStateFieldFromRec(&keyc->xkbInfo->state);	/*SHOULD SEE MODIFIER STATE HERE!!*/
- #else
- 	maxKeysPerModifier = keyc->maxKeysPerModifier;
- 	modKeyMap = keyc->modifierKeyMap;
-@@ -572,7 +592,7 @@
- 	if (kc < minKeyCode) {
- 		vlog.info("Keyboard mapping full - ignoring unknown keysym "
- 			  "0x%x",keysym);
--		goto cleanup;
-+		CLEANUP_RETURN
- 	}
- 
- 	/*
-@@ -585,7 +605,7 @@
- 			int index = i * maxKeysPerModifier + k;
- 			if (kc == modKeyMap[index] &&
- 			    IS_PRESSED(keyc,kc) && down)
--				goto cleanup;
-+				CLEANUP_RETURN
- 		}
- 	}
- 
-@@ -608,15 +628,7 @@
- 	action = down ? KeyPress : KeyRelease;
- 	n = GetKeyboardEvents(eventq, dev, action, kc);
- 	enqueueEvents(dev, n);
--  cleanup:
--#if XORG >= 17
--	xfree(modKeyMap);
--	if (keymap)
--	{
--		xfree(keymap->map);
--		xfree(keymap);
--	}
--#endif
-+	CLEANUP_RETURN
- }
- 
- static KeySym KeyCodetoKeySym(KeySymsPtr keymap, int keycode, int col)
--- a/open-src/xserver/xvnc/solaris-port.patch	Tue Jul 13 18:22:30 2010 -0700
+++ b/open-src/xserver/xvnc/solaris-port.patch	Thu Jul 15 17:25:40 2010 -0700
@@ -118,8 +118,8 @@
  
  .SH PARAMETERS
  VNC parameters can be set both via the command-line and through the
--\fBvncconfig\fP(1) program, and with a VNC-enabled XFree86 server via Options
--entries in the XF86Config file.
+-\fBvncconfig\fP(1) program, and with a VNC-enabled Xorg server via Options
+-entries in the xorg.conf file.
 +\fBvncconfig\fP(1) program.
  
  Parameters can be turned on with -\fIparam\fP or off with
--- a/open-src/xserver/xvnc/tigervnc-port-to-1.7.patch	Tue Jul 13 18:22:30 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,351 +0,0 @@
-diff
---- unix/xserver/hw/vnc/XserverDesktop.cc	Thu Aug 20 02:46:42 2009
-+++ unix/xserver/hw/vnc/XserverDesktop.cc	Fri Nov  6 16:10:43 2009
-@@ -244,8 +244,8 @@
-   int i;
-   pointer retval;
- 
--  i = dixLookupResource(&retval, pScreen->defColormap, RT_COLORMAP, NullClient,
--			DixReadAccess);
-+  i = dixLookupResourceByType(&retval, pScreen->defColormap, RT_COLORMAP,
-+			      NullClient, DixReadAccess);
- 
-   /* Handle suspicious conditions */
-   assert(i == Success);
-diff
---- unix/xserver/hw/vnc/xorg-version.h	2009-11-11 21:46:35.933464092 -0800
-+++ unix/xserver/hw/vnc/xorg-version.h	2009-11-11 21:56:10.657410927 -0800
-@@ -26,8 +26,10 @@
- 
- #if XORG_VERSION_CURRENT < ((1 * 10000000) + (5 * 100000) + (99 * 1000))
- #define XORG 15
--#else
-+#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (6 * 100000) + (99 * 1000))
- #define XORG 16
-+#else
-+#define XORG 17
- #endif
- 
- #endif
-diff
---- unix/xserver/hw/vnc/xvnc.cc	Fri Nov  6 15:23:56 2009
-+++ unix/xserver/hw/vnc/xvnc.cc	Fri Nov  6 16:02:35 2009
-@@ -39,6 +39,10 @@
- #include "vncExtInit.h"
- #include "xorg-version.h"
- 
-+#if XORG >= 17
-+#include <version-config.h>
-+#endif
-+
- extern "C" {
- #define class c_class
- #define public c_public
-diff
---- unix/xserver/hw/vnc/Input.cc~	2009-11-11 22:21:00.795223025 -0800
-+++ unix/xserver/hw/vnc/Input.cc	2009-11-12 00:36:37.552679740 -0800
-@@ -31,6 +31,10 @@ extern "C" {
- #define class c_class
- #include "inputstr.h"
- #include "mi.h"
-+#if XORG >= 17
-+#include "xserver-properties.h"
-+#define XKB
-+#endif
- #ifndef XKB_IN_SERVER
- #define XKB_IN_SERVER
- #endif
-@@ -100,6 +104,9 @@ static void enqueueEvents(DeviceIntPtr d
- #if XORG == 15
- 			    eventq + i
- #else
-+# if XORG >= 17
-+			    (InternalEvent*)
-+# endif
- 			    (eventq + i)->event
- #endif
- 			   );
-@@ -172,15 +179,38 @@ static int pointerProc(DeviceIntPtr pDev
- 
- 	switch (onoff) {
- 	case DEVICE_INIT:
-+	{
-+#if XORG >= 17	
-+		Atom btn_labels[BUTTONS] = {0};
-+		Atom axes_labels[2] = {0};
-+
-+		btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
-+		btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
-+		btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
-+		btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
-+		btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
-+
-+		axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
-+		axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
-+#endif
-+
- 		for (i = 0; i < BUTTONS + 1; i++)
- 			map[i] = i;
- 
- 		InitPointerDeviceStruct(pDev, map, BUTTONS,
-+#if XORG >= 17
-+					btn_labels,
-+#endif					
- #if XORG == 15
- 					GetMotionHistory,
- #endif
- 					(PtrCtrlProcPtr)NoopDDA,
--					GetMotionHistorySize(), 2);
-+					GetMotionHistorySize(), 2
-+#if XORG >= 17
-+					, axes_labels
-+#endif					
-+			);
-+	}
- 		break;
- 	case DEVICE_ON:
- 		pDev->on = TRUE;
-@@ -240,32 +270,79 @@ public:
- 	void press()
- 	{
- 		KeyClassPtr keyc = dev->key;
--		if (!(keyc->state & (1 << modIndex))) {
--			int index = modIndex * keyc->maxKeysPerModifier;
--			tempKeyEvent(keyc->modifierKeyMap[index], true);
-+		KeyCode *modKeyMap = NULL;
-+		int maxKeysPerModifier, modState;
-+#if XORG >= 17
-+		int ret = generate_modkeymap(serverClient, dev, &modKeyMap,
-+					     &maxKeysPerModifier);
-+		if (ret != Success)
-+		    return;
-+		modState = XkbStateFieldFromRec(&keyc->xkbInfo->state);
-+#else
-+		maxKeysPerModifier = keyc->maxKeysPerModifier;
-+		modKeyMap = keyc->modifierKeyMap;
-+		modState = keyc->state;
-+#endif
-+	       
-+		if (!(modState & (1 << modIndex))) {
-+			int index = modIndex * maxKeysPerModifier;
-+			tempKeyEvent(modKeyMap[index], true);
- 			pressed = true;
- 		}
-+#if XORG >= 17
-+		xfree(modKeyMap);
-+#endif
- 	}
- 
- 	void release()
- 	{
- 		KeyClassPtr keyc = dev->key;
--		if ((keyc->state & (1 << modIndex)) == 0)
-+		int modState, maxKeysPerModifier;
-+		KeyCode *modKeyMap = NULL;
-+#if XORG >= 17
-+		int ret = generate_modkeymap(serverClient, dev, &modKeyMap,
-+					     &maxKeysPerModifier);
-+		if (ret != Success)
-+		    return;
-+		modState = XkbStateFieldFromRec(&keyc->xkbInfo->state);
-+#else
-+		modState = keyc->state;
-+		maxKeysPerModifier = keyc->maxKeysPerModifier;
-+		modKeyMap = keyc->modifierKeyMap;
-+#endif
-+		if ((modState & (1 << modIndex)) == 0)
- 			return;
- 
--		for (int k = 0; k < keyc->maxKeysPerModifier; k++) {
--			int index = modIndex * keyc->maxKeysPerModifier + k;
--			int keycode = keyc->modifierKeyMap[index];
-+		for (int k = 0; k < maxKeysPerModifier; k++) {
-+			int index = modIndex * maxKeysPerModifier + k;
-+			int keycode = modKeyMap[index];
- 			if (keycode && IS_PRESSED(keyc, keycode))
- 				tempKeyEvent(keycode, false);
- 		}
-+#if XORG >= 17
-+		xfree(modKeyMap);
-+#endif
- 	}
- 
- private:
- 	void tempKeyEvent(int keycode, bool down)
- 	{
- 		if (keycode) {
--			if (!keys) keys = new int[dev->key->maxKeysPerModifier];
-+			if (!keys) {
-+				int maxKeysPerModifier;
-+#if XORG >= 17
-+				KeyCode *modKeyMap = NULL;
-+				int ret = generate_modkeymap
-+					(serverClient, dev, &modKeyMap,
-+					 &maxKeysPerModifier);
-+				if (ret != Success)
-+					return;
-+				xfree(modKeyMap);
-+#else
-+				maxKeysPerModifier = keyc->maxKeysPerModifier;
-+#endif
-+				keys = new int[maxKeysPerModifier];
-+			}
- 			keys[nKeys++] = keycode;
- 			generateXKeyEvent(keycode, down);
- 		}
-@@ -365,7 +442,13 @@ void KeyboardDevice::keyEvent(rdr::U32 k
- {
- 	DeviceIntPtr master;
- 	KeyClassPtr keyc = dev->key;
-+	KeyCode *modKeyMap = NULL;
-+	int maxKeysPerModifier, modState;
-+#if XORG >= 17	
-+	KeySymsPtr keymap = XkbGetCoreMap(dev);
-+#else
- 	KeySymsPtr keymap = &keyc->curKeySyms;
-+#endif
- 	KeySym *map = keymap->map;
- 	KeyCode minKeyCode = keymap->minKeyCode;
- 	KeyCode maxKeyCode = keymap->maxKeyCode;
-@@ -375,15 +458,26 @@ void KeyboardDevice::keyEvent(rdr::U32 k
- 
- 	if (keysym == XK_Caps_Lock) {
- 		vlog.debug("Ignoring caps lock");
--		return;
-+		goto cleanup;
- 	}
- 
-+#if XORG >= 17
-+	int ret = generate_modkeymap(serverClient, dev, &modKeyMap,
-+					     &maxKeysPerModifier);
-+	if (ret != Success)
-+		goto cleanup;
-+	modState = XkbStateFieldFromRec(&keyc->xkbInfo->state);
-+#else
-+	maxKeysPerModifier = keyc->maxKeysPerModifier;
-+	modKeyMap = keyc->modifierKeyMap;
-+	modState = keyc->state;
-+#endif
- 	/* find which modifier Mode_switch is on. */
- 	int modeSwitchMapIndex = 0;
- 	for (i = 3; i < 8; i++) {
--		for (k = 0; k < keyc->maxKeysPerModifier; k++) {
--			int index = i * keyc->maxKeysPerModifier + k;
--			int keycode = keyc->modifierKeyMap[index];
-+		for (k = 0; k < maxKeysPerModifier; k++) {
-+			int index = i * maxKeysPerModifier + k;
-+			int keycode = modKeyMap[index];
- 
- 			if (keycode == 0)
- 				continue;
-@@ -400,10 +494,10 @@ void KeyboardDevice::keyEvent(rdr::U32 k
- ModeSwitchFound:
- 
- 	int col = 0;
--	if ((keyc->state & (1 << ShiftMapIndex)) != 0)
-+	if ((modState & (1 << ShiftMapIndex)) != 0)
- 		col |= 1;
- 	if (modeSwitchMapIndex != 0 &&
--	    ((keyc->state & (1 << modeSwitchMapIndex))) != 0)
-+	    ((modState & (1 << modeSwitchMapIndex))) != 0)
- 		col |= 2;
- 
- 	int kc = KeysymToKeycode(keymap, keysym, &col);
-@@ -416,7 +510,7 @@ ModeSwitchFound:
- 	 * We never get ISO_Left_Tab here because it's already been translated
- 	 * in VNCSConnectionST.
- 	 */
--	if (keysym == XK_Tab && ((keyc->state & (1 << ShiftMapIndex))) != 0)
-+	if (keysym == XK_Tab && ((modState & (1 << ShiftMapIndex))) != 0)
- 		col |= 1;
- 
- 	if (kc == 0) {
-@@ -447,6 +541,13 @@ ModeSwitchFound:
- 
- 			vlog.info("Added unknown keysym 0x%x to keycode %d",
- 				  keysym, kc);
-+#if XORG >= 17
-+			if (!IsMaster(dev))
-+			{
-+				master = dev->u.master;
-+				CopyKeyClass(dev, master);
-+			}
-+#else
- #if XORG == 15
- 			master = inputInfo.keyboard;
- #else
-@@ -463,6 +564,7 @@ ModeSwitchFound:
- 				CopyKeyClass(dev, master);
- #endif
- 			}
-+#endif /* XORG >= 17 */
- 			break;
- 		}
- 	}
-@@ -470,7 +572,7 @@ ModeSwitchFound:
- 	if (kc < minKeyCode) {
- 		vlog.info("Keyboard mapping full - ignoring unknown keysym "
- 			  "0x%x",keysym);
--		return;
-+		goto cleanup;
- 	}
- 
- 	/*
-@@ -479,11 +581,11 @@ ModeSwitchFound:
- 	 * followed by a press.
- 	 */
- 	for (i = 0; i < 8; i++) {
--		for (k = 0; k < keyc->maxKeysPerModifier; k++) {
--			int index = i * keyc->maxKeysPerModifier + k;
--			if (kc == keyc->modifierKeyMap[index] &&
-+		for (k = 0; k < maxKeysPerModifier; k++) {
-+			int index = i * maxKeysPerModifier + k;
-+			if (kc == modKeyMap[index] &&
- 			    IS_PRESSED(keyc,kc) && down)
--				return;
-+				goto cleanup;
- 		}
- 	}
- 
-@@ -506,6 +608,15 @@ ModeSwitchFound:
- 	action = down ? KeyPress : KeyRelease;
- 	n = GetKeyboardEvents(eventq, dev, action, kc);
- 	enqueueEvents(dev, n);
-+  cleanup:
-+#if XORG >= 17
-+	xfree(modKeyMap);
-+	if (keymap)
-+	{
-+		xfree(keymap->map);
-+		xfree(keymap);
-+	}
-+#endif
- }
- 
- static KeySym KeyCodetoKeySym(KeySymsPtr keymap, int keycode, int col)
-@@ -738,15 +849,25 @@ static void keyboardBell(int percent, De
- 
- static int keyboardProc(DeviceIntPtr pDevice, int onoff)
- {
-+#if XORG >= 17
-+	XkbRMLVOSet rmlvo;
-+#else
- 	KeySymsRec keySyms;
- 	CARD8 modMap[MAP_LENGTH];
-+#endif
- 	DevicePtr pDev = (DevicePtr)pDevice;
- 
- 	switch (onoff) {
- 	case DEVICE_INIT:
-+#if XORG >= 17
-+		XkbGetRulesDflts(&rmlvo);
-+		InitKeyboardDeviceStruct(pDevice, &rmlvo, keyboardBell,
-+					 (KbdCtrlProcPtr)NoopDDA);
-+#else
- 		GetMappings(&keySyms, modMap);
- 		InitKeyboardDeviceStruct(pDev, &keySyms, modMap, keyboardBell,
- 					 (KbdCtrlProcPtr)NoopDDA);
-+#endif
- 		break;
- 	case DEVICE_ON:
- 		pDev->on = TRUE;
--- a/open-src/xserver/xvnc/upstream-input-refactor.patch	Tue Jul 13 18:22:30 2010 -0700
+++ b/open-src/xserver/xvnc/upstream-input-refactor.patch	Thu Jul 15 17:25:40 2010 -0700
@@ -1323,7 +1323,7 @@
    delete httpServer;
    delete server;
  }
-@@ -854,533 +800,10 @@ void XserverDesktop::lookup(int index, int* r, int* g, int* b)
+@@ -854,550 +800,10 @@
    }
  }
  
@@ -1483,6 +1483,14 @@
 -  unsigned int i, n;
 -  int j, k;
 -
+-  /* 
+-   * Since we are checking the current state to determine if we need
+-   * to fake modifiers, we must make sure that everything put on the
+-   * input queue is processed before we start. Otherwise, shift may be
+-   * stuck down.
+-   */ 
+-  mieqProcessInputEvents();
+-
 -  if (keysym == XK_Caps_Lock) {
 -    vlog.debug("Ignoring caps lock");
 -    return;
@@ -1599,6 +1607,15 @@
 -#endif
 -    );
 -  }
+-
+-  /*
+-   * When faking a modifier we are putting a keycode (which can
+-   * currently activate the desired modifier) on the input
+-   * queue. A future modmap change can change the mapping so
+-   * that this keycode means something else entirely. Guard
+-   * against this by processing the queue now.
+-   */
+-  mieqProcessInputEvents();
 +	if (down)
 +		keyboardDevice->Press(keysym);
 +	else
@@ -1873,6 +1890,7 @@
    OsTimerPtr deferredUpdateTimer, dummyTimer;
    rfb::VNCServerST* server;
    rfb::HTTPServer* httpServer;
+
 -- 
 1.5.6.5
 
--- a/open-src/xserver/xvnc/upstream-modkeystick.patch	Tue Jul 13 18:22:30 2010 -0700
+++ b/open-src/xserver/xvnc/upstream-modkeystick.patch	Thu Jul 15 17:25:40 2010 -0700
@@ -1,37 +1,48 @@
---- /dev/null	2009-12-17 01:29:23.000000000 -0800
-+++ upstream-modkeystick.patch	2009-12-17 01:28:12.531376950 -0800
-@@ -0,0 +1,34 @@
-+open-src/xserver/xvnc/build_32/tigervnc-1.0.0
-+--- unix/xserver/hw/vnc/Input.cc.orig	2009-12-16 17:23:13.298295400 -0800
-++++ unix/xserver/hw/vnc/Input.cc	2009-12-16 17:14:56.292383650 -0800
-+@@ -456,6 +456,14 @@
-+ 	unsigned int i, n;
-+ 	int j, k, action;
-+ 
-++	/* 
-++	 * Since we are checking the current state to determine if we need
-++	 * to fake modifiers, we must make sure that everything put on the
-++	 * input queue is processed before we start. Otherwise, shift may be
-++	 * stuck down.
-++	 */ 
-++	mieqProcessInputEvents();
-++	
-+ 	if (keysym == XK_Caps_Lock) {
-+ 		vlog.debug("Ignoring caps lock");
-+ 		goto cleanup;
-+@@ -617,6 +625,15 @@
-+ 		xfree(keymap);
-+ 	}
-+ #endif
-++
-++	/*
-++	 * When faking a modifier we are putting a keycode (which can
-++	 * currently activate the desired modifier) on the input
-++	 * queue. A future modmap change can change the mapping so
-++	 * that this keycode means something else entirely. Guard
-++	 * against this by processing the queue now.
-++	 */
-++	mieqProcessInputEvents();
-+ }
-+ 
-+ static KeySym KeyCodetoKeySym(KeySymsPtr keymap, int keycode, int col)
+From c4867c83722795c55b07c0fbcbd22fe8e86b96e7 Mon Sep 17 00:00:00 2001
+From: astrand <astrand@3789f03b-4d11-0410-bbf8-ca57d06f2519>
+Date: Wed, 9 Dec 2009 12:28:19 +0000
+Subject: [PATCH] Avoid modifiers such as shift sticking.
+
+git-svn-id: https://tigervnc.svn.sourceforge.net/svnroot/tigervnc/trunk@3924 3789f03b-4d11-0410-bbf8-ca57d06f2519
+---
+ unix/xserver/hw/vnc/Input.cc |   17 +++++++++++++++++
+ 1 files changed, 17 insertions(+), 0 deletions(-)
+
+diff --git a/unix/xserver/hw/vnc/Input.cc b/unix/xserver/hw/vnc/Input.cc
+index 478240c..4ad1564 100644
+--- a/unix/xserver/hw/vnc/Input.cc
++++ b/unix/xserver/hw/vnc/Input.cc
+@@ -373,6 +373,14 @@ void KeyboardDevice::keyEvent(rdr::U32 keysym, bool down)
+ 	unsigned int i, n;
+ 	int j, k, action;
+ 
++	/* 
++	 * Since we are checking the current state to determine if we need
++	 * to fake modifiers, we must make sure that everything put on the
++	 * input queue is processed before we start. Otherwise, shift may be
++	 * stuck down.
++	 */ 
++	mieqProcessInputEvents();
++
+ 	if (keysym == XK_Caps_Lock) {
+ 		vlog.debug("Ignoring caps lock");
+ 		return;
+@@ -506,6 +514,15 @@ ModeSwitchFound:
+ 	action = down ? KeyPress : KeyRelease;
+ 	n = GetKeyboardEvents(eventq, dev, action, kc);
+ 	enqueueEvents(dev, n);
++	
++	/*
++	 * When faking a modifier we are putting a keycode (which can
++	 * currently activate the desired modifier) on the input
++	 * queue. A future modmap change can change the mapping so
++	 * that this keycode means something else entirely. Guard
++	 * against this by processing the queue now.
++	 */
++	mieqProcessInputEvents();
+ }
+ 
+ static KeySym KeyCodetoKeySym(KeySymsPtr keymap, int keycode, int col)
+-- 
+1.5.6.5
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/xserver/xvnc/upstream-port-to-1.7.patch	Thu Jul 15 17:25:40 2010 -0700
@@ -0,0 +1,423 @@
+From 186235a9c04d150318b07e00ee2894b8e7817af9 Mon Sep 17 00:00:00 2001
+From: atkac <atkac@3789f03b-4d11-0410-bbf8-ca57d06f2519>
+Date: Mon, 21 Dec 2009 14:01:22 +0000
+Subject: [PATCH] [Development] Make Xvnc working when compiled against X.Org 1.7 (Thanks to adq_dvb at lidskialf dot net).
+
+git-svn-id: https://tigervnc.svn.sourceforge.net/svnroot/tigervnc/trunk@3927 3789f03b-4d11-0410-bbf8-ca57d06f2519
+---
+ unix/xserver/hw/vnc/Input.cc          |  210 +++++++++++++++++++++++++++-----
+ unix/xserver/hw/vnc/XserverDesktop.cc |    7 +
+ unix/xserver/hw/vnc/xorg-version.h    |    6 +-
+ unix/xserver/hw/vnc/xvnc.cc           |    6 +
+ 4 files changed, 195 insertions(+), 34 deletions(-)
+
+diff --git a/unix/xserver/hw/vnc/Input.cc b/unix/xserver/hw/vnc/Input.cc
+index 4ad1564..62fca6d 100644
+--- a/unix/xserver/hw/vnc/Input.cc
++++ b/unix/xserver/hw/vnc/Input.cc
+@@ -43,9 +43,17 @@ extern "C" {
+ #endif
+ #if XORG >= 16
+ #include "exevents.h"
++#endif
++#if XORG == 16
+ extern void
+ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
+ #endif
++#if XORG >= 17
++#include "xkbsrv.h"
++#include "xkbstr.h"
++#include "xserver-properties.h"
++extern _X_EXPORT DevPrivateKey CoreDevicePrivateKey;
++#endif
+ #include <X11/keysym.h>
+ #include <X11/Xutil.h>
+ #undef public
+@@ -99,8 +107,10 @@ static void enqueueEvents(DeviceIntPtr dev, int n)
+ 		mieqEnqueue(dev,
+ #if XORG == 15
+ 			    eventq + i
+-#else
++#elif XORG == 16
+ 			    (eventq + i)->event
++#else
++			    (InternalEvent *) (eventq + i)->event
+ #endif
+ 			   );
+ 	}
+@@ -169,18 +179,43 @@ static int pointerProc(DeviceIntPtr pDevice, int onoff)
+ 	BYTE map[BUTTONS + 1];
+ 	DevicePtr pDev = (DevicePtr)pDevice;
+ 	int i;
++#if XORG >= 17
++	/*
++	 * NOTE: map[] array is one element longer than btn_labels[] array. This
++	 * is not a bug.
++	 */
++	Atom btn_labels[BUTTONS];
++	Atom axes_labels[2];
++#endif
+ 
+ 	switch (onoff) {
+ 	case DEVICE_INIT:
+ 		for (i = 0; i < BUTTONS + 1; i++)
+ 			map[i] = i;
+ 
++#if XORG >= 17
++		btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
++		btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
++		btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
++		btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
++		btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
++
++		axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
++		axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
++#endif
++
+ 		InitPointerDeviceStruct(pDev, map, BUTTONS,
+ #if XORG == 15
+ 					GetMotionHistory,
++#elif XORG >= 17
++					btn_labels,
+ #endif
+ 					(PtrCtrlProcPtr)NoopDDA,
+-					GetMotionHistorySize(), 2);
++					GetMotionHistorySize(), 2
++#if XORG >= 17
++					, axes_labels
++#endif
++					);
+ 		break;
+ 	case DEVICE_ON:
+ 		pDev->on = TRUE;
+@@ -239,33 +274,84 @@ public:
+ 
+ 	void press()
+ 	{
++		int state, index, maxKeysPerMod, keycode;
++#if XORG >= 17
++		int ret;
++		KeyCode *modmap = NULL;
++
++		state = XkbStateFieldFromRec(&dev->u.master->key->xkbInfo->state);
++#else
+ 		KeyClassPtr keyc = dev->key;
+-		if (!(keyc->state & (1 << modIndex))) {
+-			int index = modIndex * keyc->maxKeysPerModifier;
+-			tempKeyEvent(keyc->modifierKeyMap[index], true);
+-			pressed = true;
++		state = keyc->state;
++#endif
++		if ((state & (1 << modIndex)) != 0)
++			return;
++
++#if XORG >= 17
++		if (generate_modkeymap(serverClient, dev, &modmap,
++				       &maxKeysPerMod) != Success) {
++			vlog.error("generate_modkeymap failed");
++			return;
+ 		}
++
++		keycode = modmap[modIndex * maxKeysPerMod];
++		xfree(modmap);
++#else
++		maxKeysPerMod = keyc->maxKeysPerModifier;
++		keycode = keyc->modifierKeyMap[modIndex * maxKeysPerMod];
++#endif
++		tempKeyEvent(keycode, true, maxKeysPerMod);
++		pressed = true;
+ 	}
+ 
+ 	void release()
+ 	{
+-		KeyClassPtr keyc = dev->key;
+-		if ((keyc->state & (1 << modIndex)) == 0)
++		int state, maxKeysPerMod;
++		KeyClassPtr keyc;
++#if XORG >= 17
++		int ret;
++		KeyCode *modmap = NULL;
++
++		keyc = dev->u.master->key;
++		state = XkbStateFieldFromRec(&keyc->xkbInfo->state);
++#else
++		keyc = dev->key;
++		state = keyc->state;
++#endif
++		if ((state & (1 << modIndex)) == 0)
+ 			return;
+ 
+-		for (int k = 0; k < keyc->maxKeysPerModifier; k++) {
+-			int index = modIndex * keyc->maxKeysPerModifier + k;
+-			int keycode = keyc->modifierKeyMap[index];
++#if XORG >= 17
++		if (generate_modkeymap(serverClient, dev, &modmap,
++				       &maxKeysPerMod) != Success) {
++			vlog.error("generate_modkeymap failed");
++			return;
++		}
++#else
++		maxKeysPerMod = keyc->maxKeysPerModifier;
++#endif
++
++		for (int k = 0; k < maxKeysPerMod; k++) {
++			int keycode;
++			int index = modIndex * maxKeysPerMod + k;
++#if XORG >= 17
++			keycode = modmap[index];
++#else
++			keycode = keyc->modifierKeyMap[index];
++#endif
+ 			if (keycode && IS_PRESSED(keyc, keycode))
+-				tempKeyEvent(keycode, false);
++				tempKeyEvent(keycode, false, maxKeysPerMod);
+ 		}
++#if XORG >= 17
++		xfree(modmap);
++#endif
+ 	}
+ 
+ private:
+-	void tempKeyEvent(int keycode, bool down)
++	void tempKeyEvent(int keycode, bool down, int maxKeysPerMod)
+ 	{
+ 		if (keycode) {
+-			if (!keys) keys = new int[dev->key->maxKeysPerModifier];
++			if (!keys) keys = new int[maxKeysPerMod];
+ 			keys[nKeys++] = keycode;
+ 			generateXKeyEvent(keycode, down);
+ 		}
+@@ -361,17 +447,28 @@ static struct altKeysym_t {
+  *   synchronized with proper master device
+  */
+ 
++#if XORG >= 17
++#define FREE_MAPS \
++	do { \
++	        xfree(modmap); \
++	        xfree(keymap->map); \
++	        xfree(keymap); \
++	} while (0);
++#else
++#define FREE_MAPS
++#endif
++
+ void KeyboardDevice::keyEvent(rdr::U32 keysym, bool down)
+ {
+ 	DeviceIntPtr master;
+-	KeyClassPtr keyc = dev->key;
+-	KeySymsPtr keymap = &keyc->curKeySyms;
+-	KeySym *map = keymap->map;
+-	KeyCode minKeyCode = keymap->minKeyCode;
+-	KeyCode maxKeyCode = keymap->maxKeyCode;
+-	int mapWidth = keymap->mapWidth;
++	KeyClassPtr keyc;
++	KeySymsPtr keymap = NULL;
++	KeySym *map = NULL;
++	KeyCode minKeyCode, maxKeyCode;
++	KeyCode *modmap = NULL;
++	int mapWidth;
+ 	unsigned int i, n;
+-	int j, k, action;
++	int j, k, action, state, maxKeysPerMod;
+ 
+ 	/* 
+ 	 * Since we are checking the current state to determine if we need
+@@ -385,13 +482,43 @@ void KeyboardDevice::keyEvent(rdr::U32 keysym, bool down)
+ 		vlog.debug("Ignoring caps lock");
+ 		return;
+ 	}
++vlog.debug("keysym %d", keysym);
++#if XORG >= 17
++	keyc = dev->u.master->key;
++
++	keymap = XkbGetCoreMap(dev);
++	if (!keymap) {
++		vlog.error("VNC keyboard device has no map");
++		return;
++	}
++
++	if (generate_modkeymap(serverClient, dev, &modmap, &maxKeysPerMod)
++	    != Success) {
++		vlog.error("generate_modkeymap failed");
++		xfree(keymap->map);
++		xfree(keymap);
++		return;
++	}
++
++	state = XkbStateFieldFromRec(&keyc->xkbInfo->state);
++#else
++	keyc = dev->key;
++	state = keyc->state;
++	maxKeysPerMod = keyc->maxKeysPerModifier;
++	keymap = &keyc->curKeySyms;
++	modmap = keyc->modifierKeyMap;
++#endif
++	map = keymap->map;
++	minKeyCode = keymap->minKeyCode;
++	maxKeyCode = keymap->maxKeyCode;
++	mapWidth = keymap->mapWidth;
+ 
+ 	/* find which modifier Mode_switch is on. */
+ 	int modeSwitchMapIndex = 0;
+ 	for (i = 3; i < 8; i++) {
+-		for (k = 0; k < keyc->maxKeysPerModifier; k++) {
+-			int index = i * keyc->maxKeysPerModifier + k;
+-			int keycode = keyc->modifierKeyMap[index];
++		for (k = 0; k < maxKeysPerMod; k++) {
++			int index = i * maxKeysPerMod + k;
++			int keycode = modmap[index];
+ 
+ 			if (keycode == 0)
+ 				continue;
+@@ -408,10 +535,10 @@ void KeyboardDevice::keyEvent(rdr::U32 keysym, bool down)
+ ModeSwitchFound:
+ 
+ 	int col = 0;
+-	if ((keyc->state & (1 << ShiftMapIndex)) != 0)
++	if ((state & (1 << ShiftMapIndex)) != 0)
+ 		col |= 1;
+ 	if (modeSwitchMapIndex != 0 &&
+-	    ((keyc->state & (1 << modeSwitchMapIndex))) != 0)
++	    ((state & (1 << modeSwitchMapIndex))) != 0)
+ 		col |= 2;
+ 
+ 	int kc = KeysymToKeycode(keymap, keysym, &col);
+@@ -424,7 +551,7 @@ ModeSwitchFound:
+ 	 * We never get ISO_Left_Tab here because it's already been translated
+ 	 * in VNCSConnectionST.
+ 	 */
+-	if (keysym == XK_Tab && ((keyc->state & (1 << ShiftMapIndex))) != 0)
++	if (keysym == XK_Tab && ((state & (1 << ShiftMapIndex))) != 0)
+ 		col |= 1;
+ 
+ 	if (kc == 0) {
+@@ -455,6 +582,8 @@ ModeSwitchFound:
+ 
+ 			vlog.info("Added unknown keysym 0x%x to keycode %d",
+ 				  keysym, kc);
++
++#if XORG < 17
+ #if XORG == 15
+ 			master = inputInfo.keyboard;
+ #else
+@@ -471,6 +600,12 @@ ModeSwitchFound:
+ 				CopyKeyClass(dev, master);
+ #endif
+ 			}
++#else /* XORG < 17 */
++			XkbApplyMappingChange(dev, keymap, minKeyCode,
++					      maxKeyCode - minKeyCode + 1,
++					      NULL, serverClient);
++			XkbCopyDeviceKeymap(dev->u.master, dev);
++#endif /* XORG < 17 */
+ 			break;
+ 		}
+ 	}
+@@ -478,6 +613,7 @@ ModeSwitchFound:
+ 	if (kc < minKeyCode) {
+ 		vlog.info("Keyboard mapping full - ignoring unknown keysym "
+ 			  "0x%x",keysym);
++		FREE_MAPS;
+ 		return;
+ 	}
+ 
+@@ -487,11 +623,12 @@ ModeSwitchFound:
+ 	 * followed by a press.
+ 	 */
+ 	for (i = 0; i < 8; i++) {
+-		for (k = 0; k < keyc->maxKeysPerModifier; k++) {
+-			int index = i * keyc->maxKeysPerModifier + k;
+-			if (kc == keyc->modifierKeyMap[index] &&
+-			    IS_PRESSED(keyc,kc) && down)
++		for (k = 0; k < maxKeysPerMod; k++) {
++			int index = i * maxKeysPerMod + k;
++			if (kc == modmap[index] && IS_PRESSED(keyc,kc) && down) {
++				FREE_MAPS;
+ 				return;
++			}	
+ 		}
+ 	}
+ 
+@@ -761,9 +898,16 @@ static int keyboardProc(DeviceIntPtr pDevice, int onoff)
+ 
+ 	switch (onoff) {
+ 	case DEVICE_INIT:
++#if XORG < 17
+ 		GetMappings(&keySyms, modMap);
+-		InitKeyboardDeviceStruct(pDev, &keySyms, modMap, keyboardBell,
+-					 (KbdCtrlProcPtr)NoopDDA);
++#endif
++		InitKeyboardDeviceStruct(
++#if XORG >= 17
++					 pDevice, NULL,
++#else
++					 pDev, &keySyms, modMap,
++#endif
++					 keyboardBell, (KbdCtrlProcPtr)NoopDDA);
+ 		break;
+ 	case DEVICE_ON:
+ 		pDev->on = TRUE;
+diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc
+index 66c92d2..b316e69 100644
+--- a/unix/xserver/hw/vnc/XserverDesktop.cc
++++ b/unix/xserver/hw/vnc/XserverDesktop.cc
+@@ -54,6 +54,10 @@ extern char *display;
+ #ifdef RANDR
+ #include "randrstr.h"
+ #endif
++#if XORG >= 17
++#include "cursorstr.h"
++#endif
++
+ #undef public
+ #undef class
+ }
+@@ -185,6 +189,9 @@ void XserverDesktop::serverReset(ScreenPtr pScreen_)
+   int i;
+   pointer retval;
+ 
++#if XORG >= 17
++#define dixLookupResource dixLookupResourceByType
++#endif
+   i = dixLookupResource(&retval, pScreen->defColormap, RT_COLORMAP, NullClient,
+ 			DixReadAccess);
+ 
+diff --git a/unix/xserver/hw/vnc/xorg-version.h b/unix/xserver/hw/vnc/xorg-version.h
+index e7eeca0..3d942fc 100644
+--- a/unix/xserver/hw/vnc/xorg-version.h
++++ b/unix/xserver/hw/vnc/xorg-version.h
+@@ -26,8 +26,12 @@
+ 
+ #if XORG_VERSION_CURRENT < ((1 * 10000000) + (5 * 100000) + (99 * 1000))
+ #define XORG 15
+-#else
++#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (6 * 100000) + (99 * 1000))
+ #define XORG 16
++#elif XORG_VERSION_CURRENT < ((1 * 10000000) + (7 * 100000) + (99 * 1000))
++#define XORG 17
++#else
++#error "X.Org newer than 1.7 is not supported"
+ #endif
+ 
+ #endif
+diff --git a/unix/xserver/hw/vnc/xvnc.cc b/unix/xserver/hw/vnc/xvnc.cc
+index 05066fc..f21cf21 100644
+--- a/unix/xserver/hw/vnc/xvnc.cc
++++ b/unix/xserver/hw/vnc/xvnc.cc
+@@ -81,6 +81,12 @@ extern "C" {
+ #endif /* RANDR */
+ #include <X11/keysym.h>
+   extern char buildtime[];
++#if XORG >= 17
++#undef VENDOR_RELEASE
++#undef VENDOR_STRING
++#include "version-config.h"
++#include "site.h"
++#endif
+ #undef class
+ #undef public
+ }
+-- 
+1.5.6.5
+
--- a/open-src/xserver/xvnc/vnc-nobuildtime.patch	Tue Jul 13 18:22:30 2010 -0700
+++ b/open-src/xserver/xvnc/vnc-nobuildtime.patch	Thu Jul 15 17:25:40 2010 -0700
@@ -117,15 +117,15 @@
 diff -urp -x '*~' -x '*.orig' unix/xserver/hw/vnc/xvnc.cc unix/xserver/hw/vnc/xvnc.cc
 --- unix/xserver/hw/vnc/xvnc.cc	2009-08-20 02:46:42.000000000 -0700
 +++ unix/xserver/hw/vnc/xvnc.cc	2009-11-05 09:51:42.545083912 -0800
-@@ -79,7 +79,6 @@ extern "C" {
+@@ -80,7 +80,6 @@ extern "C" {
  #include "randrstr.h"
  #endif /* RANDR */
  #include <X11/keysym.h>
 -  extern char buildtime[];
- #undef class
- #undef public
- }
-@@ -256,7 +255,7 @@ void ddxBeforeReset(void)
+ #if XORG >= 17
+ #undef VENDOR_RELEASE
+ #undef VENDOR_STRING
+@@ -263,7 +262,7 @@ void ddxBeforeReset(void)
  void 
  ddxUseMsg()
  {
@@ -134,7 +134,7 @@
      ErrorF("Underlying X server release %d, %s\n\n", VENDOR_RELEASE,
             VENDOR_STRING);
      ErrorF("-screen scrn WxHxD     set screen's width, height, depth\n");
-@@ -1225,7 +1224,7 @@ static void vfbClientStateChange(Callbac
+@@ -1232,7 +1231,7 @@ static void vfbClientStateChange(Callbac
  void
  InitOutput(ScreenInfo *screenInfo, int argc, char **argv)
  {
--- a/open-src/xserver/xvnc/vnc-nohttpd.patch	Tue Jul 13 18:22:30 2010 -0700
+++ b/open-src/xserver/xvnc/vnc-nohttpd.patch	Thu Jul 15 17:25:40 2010 -0700
@@ -5,7 +5,7 @@
 diff -urp -x '*~' -x '*.orig' unix/vncserver unix/vncserver
 --- unix/vncserver	2009-08-20 02:46:42.000000000 -0700
 +++ unix/vncserver	2009-08-31 03:21:53.656835000 -0700
-@@ -123,6 +123,7 @@ if ($defFontPath) {
+@@ -121,6 +121,7 @@ if ($defFontPath) {
  # Check command line options
  
  &ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1,
@@ -13,7 +13,7 @@
  	      "-help",0,"-h",0,"--help",0,"-fp",1);
  
  &Usage() if ($opt{'-help'} || $opt{'-h'} || $opt{'--help'});
-@@ -147,6 +148,12 @@ if ($opt{'-fp'}) {
+@@ -145,6 +146,12 @@ if ($opt{'-fp'}) {
      $fontPath = $opt{'-fp'};
      $fpArgSpecified = 1;
  }
@@ -26,7 +26,7 @@
  
  &CheckGeometryAndDepth();
  
-@@ -212,7 +219,7 @@ if ($opt{'-name'}) {
+@@ -219,7 +226,7 @@ if ($opt{'-name'}) {
  
  $cmd = $exedir."Xvnc :$displayNumber";
  $cmd .= " -desktop " . &quotedString($desktopName);
@@ -35,7 +35,7 @@
  $cmd .= " -auth $xauthorityFile";
  $cmd .= " -geometry $geometry" if ($geometry);
  $cmd .= " -depth $depth" if ($depth);
-@@ -535,7 +542,7 @@ sub removeSlashes
+@@ -520,7 +527,7 @@ sub removeSlashes
  
  sub Usage
  {
--- a/open-src/xserver/xvnc/vnc-samemachine-ipv6.patch	Tue Jul 13 18:22:30 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-From 22e6adf46de3d13285e357b2ce1b776acd3d57e9 Mon Sep 17 00:00:00 2001
-From: Alan Coopersmith <[email protected]>
-Date: Fri, 30 Oct 2009 23:38:18 -0700
-Subject: [PATCH] Fix crash in TcpSocket::sameMachine for IPv6 connections
-
-Only enough room to write IPv4 addresses was being passed to
-getpeername & getsockname, but they could be used on IPv6 connections.
-
-If a connection was made to an IPv6 address, the call to getpeername
-would overwrite addrlen with the actual size of the IPv6 address, which
-would then be passed to getsockname as the space available to write the
-next address, which would cause it to smash the stack.
-
-OpenSolaris bug report: http://defect.opensolaris.org/bz/show_bug.cgi?id=12366
----
- common/network/TcpSocket.cxx |   24 +++++++++++++++++++-----
- 1 files changed, 19 insertions(+), 5 deletions(-)
-
-diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
-index 7fd9c6a..93cdceb 100644
---- a/common/network/TcpSocket.cxx
-+++ b/common/network/TcpSocket.cxx
-@@ -293,13 +293,27 @@ char* TcpSocket::getPeerEndpoint() {
- }
- 
- bool TcpSocket::sameMachine() {
--  struct sockaddr_in peeraddr, myaddr;
--  socklen_t addrlen = sizeof(struct sockaddr_in);
-+  vnc_sockaddr_t peeraddr, myaddr;
-+  socklen_t addrlen;
- 
--  getpeername(getFd(), (struct sockaddr *)&peeraddr, &addrlen);
--  getsockname(getFd(), (struct sockaddr *)&myaddr, &addrlen);
-+  addrlen = sizeof(peeraddr);
-+  if (getpeername(getFd(), &peeraddr.u.sa, &addrlen) < 0)
-+      throw SocketException ("unable to get peer address", errorNumber);
- 
--  return (peeraddr.sin_addr.s_addr == myaddr.sin_addr.s_addr);
-+  addrlen = sizeof(myaddr); /* need to reset, since getpeername overwrote */
-+  if (getsockname(getFd(), &myaddr.u.sa, &addrlen) < 0)
-+      throw SocketException ("unable to get my address", errorNumber);
-+
-+  if (peeraddr.u.sa.sa_family != myaddr.u.sa.sa_family)
-+      return false;
-+
-+#ifdef HAVE_GETADDRINFO
-+  if (peeraddr.u.sa.sa_family == AF_INET6)
-+      return IN6_ARE_ADDR_EQUAL(&peeraddr.u.sin6.sin6_addr,
-+				&myaddr.u.sin6.sin6_addr);
-+#endif
-+
-+  return (peeraddr.u.sin.sin_addr.s_addr == myaddr.u.sin.sin_addr.s_addr);
- }
- 
- void TcpSocket::shutdown()
--- 
-1.5.6.5
-
--- a/open-src/xserver/xvnc/vncserver-urandom.patch	Tue Jul 13 18:22:30 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-From 8df3a7a2c49db4509aedd5f3cf1e3340cd9d7b82 Mon Sep 17 00:00:00 2001
-From: Alan Coopersmith <[email protected]>
-Date: Fri, 6 Nov 2009 16:36:45 -0800
-Subject: [PATCH] Use /dev/urandom for xauth cookie generation
-
-The previous comment about only Linux having it is a bit outdated,
-it's common on most modern Unix-like systems now, and we can easily
-fall back to the old method on systems without it.
----
- unix/vncserver |   25 +++++++++++++++++--------
- 1 files changed, 17 insertions(+), 8 deletions(-)
-
-diff --git a/unix/vncserver b/unix/vncserver
-index 90ef0d2..28764cb 100755
---- a/unix/vncserver
-+++ b/unix/vncserver
-@@ -189,16 +189,25 @@ $vncPort = 5900 + $displayNumber;
- $desktopLog = "$vncUserDir/$host:$displayNumber.log";
- unlink($desktopLog);
- 
--# Make an X server cookie - use as the seed the sum of the current time, our
--# PID and part of the encrypted form of the password.  Ideally we'd use
--# /dev/urandom, but that's only available on Linux.
--
--srand(time+$$+unpack("L",`cat $vncUserDir/passwd`));
--$cookie = "";
--for (1..16) {
-+# Make an X server cookie - use /dev/urandom on systems that have it,
-+# otherwise use perl's random number generator, seeded with the sum
-+# of the current time, our PID and part of the encrypted form of the password.
-+
-+my $cookie = "";
-+if (open(URANDOM, '<', '/dev/urandom')) {
-+  my $randata;
-+  if (sysread(URANDOM, $randata, 16) == 16) {
-+    $cookie = unpack 'h*', $randata;
-+  }
-+  close(URANDOM);
-+}
-+if ($cookie eq "") {
-+  srand(time+$$+unpack("L",`cat $vncUserDir/passwd`));
-+  for (1..16) {
-     $cookie .= sprintf("%02x", int(rand(256)) % 256);
-+  }
- }
--    
-+
- system("xauth -f $xauthorityFile add $host:$displayNumber . $cookie");
- system("xauth -f $xauthorityFile add $host/unix:$displayNumber . $cookie"); 
- 
--- 
-1.5.6.5
-
--- a/open-src/xserver/xvnc/vncviewer-connect.patch	Tue Jul 13 18:22:30 2010 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-Use salen for socket length argument to connect()
-
-Needed on Solaris to stop connect() from returning EINVAL for invalid
-socket length when starting vncviewer.
-
-[Submitted to [email protected] on Oct 29 2009,
- applied to svn by atkac on Oct 30 in rev 3917]
-
---- tigervnc-1.0.0/common/network/TcpSocket.cxx	Thu Aug 20 02:46:42 2009
-+++ tigervnc-1.0.0/common/network/TcpSocket.cxx	Thu Oct 29 20:12:25 2009
-@@ -188,7 +188,7 @@
-     }
- 
-   /* Attempt to connect to the remote host */
--    while ((result = connect(sock, &sa.u.sa, sizeof(sa))) == -1) {
-+    while ((result = connect(sock, &sa.u.sa, salen)) == -1) {
-       err = errorNumber;
- #ifndef WIN32
-       if (err == EINTR)