[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tigervnc-devel
Subject:    Re: [Tigervnc-devel] [patch] Add support for xorg 1.7.x
From:       Andrew de Quincey <adq_dvb () lidskialf ! net>
Date:       2009-12-17 19:07:24
Message-ID: 20091217190724.29522lcghzbvs4n4 () lidskialf ! net
[Download RAW message or body]

This message is in MIME format.


Quoting Andrew de Quincey <adq_dvb@lidskialf.net>:

> Quoting Andrew de Quincey <adq_dvb@lidskialf.net>:
> 
> > Quoting Adam Tkac <atkac@redhat.com>:
> > 
> > > On Thu, Dec 17, 2009 at 07:52:04AM -0800, Alan Coopersmith wrote:
> > > > Andrew de Quincey wrote:
> > > > > Hi, the attached two patches (against tigervnc 1.0.0) are my first
> > > > > working version of this.
> > > > > 
> > > > > I'm building against 1.7.3.901 under gentoo. So far I've only had the
> > > > > time to test Xvnc itself, but it seems to be ok so far...
> > > > 
> > > > I found my port to 1.7 was simplified by first taking the patch from
> > > > the upstream svn to replace the XORG_16 style defines with the XORG
> > > > define so that the existing checks became "#if XORG >= 16"
> > > > 
> > > > http://src.opensolaris.org/source/xref/x-cons/XW_NV_tw-clone/open-src/xserver/xvnc/upstream-xorg-version.patch
> > > >  is the copy I use in my builds.
> > > 
> > > Yes, this is the main reason why we started to use XORG <number>
> > > instead of XORG_<number>.
> > > 
> > > The "X.Org 1.7" patch is really welcomed. I will look on it and merge
> > > it to the main repo.
> > 
> > Ah that is much nicer yes; I'll resubmit a patch against SVN with this
> > change in an hour or so.
> > 
> > (My first priority was to get my headless server's VNC working again
> > so I worked against the 1.0.0 release initially :)
> 
> Hi, patch against SVN trunk attached; I like the splitting out of   
> Input.cc BTW, much clearer.

Already, a v2 patch - it needed linked with libxkb for the libvnc.so  
extension to work.


["tigervnc-svn-xserver17-v2.patch" (text/x-patch)]

Index: unix/xserver/hw/vnc/vncExtInit.cc
===================================================================
--- unix/xserver/hw/vnc/vncExtInit.cc	(revision 3925)
+++ unix/xserver/hw/vnc/vncExtInit.cc	(working copy)
@@ -187,7 +187,7 @@
   vncExtGeneration = serverGeneration;
 
   ExtensionEntry* extEntry
-    = AddExtension(VNCEXTNAME, VncExtNumberEvents, VncExtNumberErrors,
+    = AddExtension((char*) VNCEXTNAME, VncExtNumberEvents, VncExtNumberErrors,
                    ProcVncExtDispatch, SProcVncExtDispatch, vncResetProc,
                    StandardMinorOpcode);
   if (!extEntry) {
Index: unix/xserver/hw/vnc/Input.cc
===================================================================
--- unix/xserver/hw/vnc/Input.cc	(revision 3925)
+++ unix/xserver/hw/vnc/Input.cc	(working copy)
@@ -45,7 +45,15 @@
 #include "exevents.h"
 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 /* XORG 17 */
+
+#endif /* XORG 16 */
 #include <X11/keysym.h>
 #include <X11/Xutil.h>
 #undef public
@@ -100,7 +108,7 @@
 #if XORG == 15
 			    eventq + i
 #else
-			    (eventq + i)->event
+			    (InternalEvent*) (eventq + i)->event
 #endif
 			   );
 	}
@@ -169,18 +177,41 @@
 	BYTE map[BUTTONS + 1];
 	DevicePtr pDev = (DevicePtr)pDevice;
 	int i;
+#if XORG == 17
+        Atom btn_labels[5];
+        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[5] = XIGetKnownProperty((char*) \
BTN_LABEL_PROP_BTN_HWHEEL_LEFT); +                btn_labels[4] = \
XIGetKnownProperty((char*) BTN_LABEL_PROP_BTN_WHEEL_DOWN); +                \
btn_labels[3] = XIGetKnownProperty((char*) BTN_LABEL_PROP_BTN_WHEEL_UP); +            \
btn_labels[2] = XIGetKnownProperty((char*) BTN_LABEL_PROP_BTN_RIGHT); +               \
btn_labels[1] = XIGetKnownProperty((char*) BTN_LABEL_PROP_BTN_MIDDLE); +              \
btn_labels[0] = XIGetKnownProperty((char*) BTN_LABEL_PROP_BTN_LEFT); +
+                axes_labels[0] = XIGetKnownProperty((char*) AXIS_LABEL_PROP_REL_X);
+                axes_labels[1] = XIGetKnownProperty((char*) AXIS_LABEL_PROP_REL_Y);
+
+                InitPointerDeviceStruct(pDev, map, 5, btn_labels,
+                                        (PtrCtrlProcPtr)NoopDDA, \
GetMotionHistorySize(), +                                        2, axes_labels);
+#elif XORG == 16
+                InitPointerDeviceStruct(pDev, map, BUTTONS,
+                                        (PtrCtrlProcPtr)NoopDDA,
+                                        GetMotionHistorySize(), 2);
+
+#elif XORG == 15
 		InitPointerDeviceStruct(pDev, map, BUTTONS,
-#if XORG == 15
 					GetMotionHistory,
-#endif
 					(PtrCtrlProcPtr)NoopDDA,
 					GetMotionHistorySize(), 2);
+#endif
 		break;
 	case DEVICE_ON:
 		pDev->on = TRUE;
@@ -240,16 +271,47 @@
 	void press()
 	{
 		KeyClassPtr keyc = dev->key;
+#if XORG >= 17
+		if (!(XkbStateFieldFromRec(&keyc->xkbInfo->state) & (1<<modIndex))) {
+			KeyCode *modkeymap = NULL;
+			int ret, max_keys_per_mod;
+
+			ret = generate_modkeymap(serverClient, dev, &modkeymap, &max_keys_per_mod);
+			if (ret == Success) {
+				tempKeyEvent(modkeymap[modIndex * max_keys_per_mod],
+				true, max_keys_per_mod);
+				pressed = true;
+				xfree(modkeymap);
+			}
+		}
+#else
 		if (!(keyc->state & (1 << modIndex))) {
 			int index = modIndex * keyc->maxKeysPerModifier;
-			tempKeyEvent(keyc->modifierKeyMap[index], true);
+			tempKeyEvent(keyc->modifierKeyMap[index], true, keyc->maxKeysPerModifier);
 			pressed = true;
 		}
+#endif
 	}
 
 	void release()
 	{
 		KeyClassPtr keyc = dev->key;
+#if XORG >= 17
+		if (XkbStateFieldFromRec(&keyc->xkbInfo->state) & (1<<modIndex)) {
+			KeyCode *modkeymap = NULL;
+			int ret, max_keys_per_mod;
+
+			ret = generate_modkeymap(serverClient, dev, &modkeymap, &max_keys_per_mod);
+			if (ret == Success) {
+				for (int k = 0; k < max_keys_per_mod; k++) {
+					int keycode = modkeymap[modIndex * max_keys_per_mod + k];
+					if (keycode && IS_PRESSED(keyc, keycode))
+					tempKeyEvent(keycode, false, max_keys_per_mod);
+				}
+				xfree(modkeymap);
+			}
+		}
+#else
 		if ((keyc->state & (1 << modIndex)) == 0)
 			return;
 
@@ -257,15 +319,16 @@
 			int index = modIndex * keyc->maxKeysPerModifier + k;
 			int keycode = keyc->modifierKeyMap[index];
 			if (keycode && IS_PRESSED(keyc, keycode))
-				tempKeyEvent(keycode, false);
+				tempKeyEvent(keycode, false, keyc->maxKeysPerModifier);
 		}
+#endif
 	}
 
 private:
-	void tempKeyEvent(int keycode, bool down)
+	void tempKeyEvent(int keycode, bool down, int maxKeysPerModifier)
 	{
 		if (keycode) {
-			if (!keys) keys = new int[dev->key->maxKeysPerModifier];
+			if (!keys) keys = new int[maxKeysPerModifier];
 			keys[nKeys++] = keycode;
 			generateXKeyEvent(keycode, down);
 		}
@@ -365,13 +428,16 @@
 {
 	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;
+	KeySym *map;
+	KeyCode minKeyCode;
+	KeyCode maxKeyCode;
+	int mapWidth;
 	unsigned int i, n;
 	int j, k, action;
+	KeySymsPtr keymap = NULL;
+	KeyCode *modifierKeyMap = NULL;
+	int maxKeysPerModifier;
+	int state;
 
 	/* 
 	 * Since we are checking the current state to determine if we need
@@ -386,12 +452,35 @@
 		return;
 	}
 
+#if XORG >= 17
+	keymap = XkbGetCoreMap(dev);
+	if (!keymap)
+		return;
+
+	if (generate_modkeymap(serverClient, dev, &modifierKeyMap, &maxKeysPerModifier) != \
Success) { +		xfree(keymap->map);
+		xfree(keymap);
+		return;
+	}
+
+	state = XkbStateFieldFromRec(&keyc->xkbInfo->state);
+#else
+	state = keyc->state;
+	maxKeysPerModifier = keyc->maxKeysPerModifier;
+	keymap = &keyc->curKeySyms;
+	modifierKeyMap = 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 < maxKeysPerModifier; k++) {
+			int index = i * maxKeysPerModifier + k;
+			int keycode = modifierKeyMap[index];
 
 			if (keycode == 0)
 				continue;
@@ -408,10 +497,10 @@
 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 +513,7 @@
 	 * 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) {
@@ -478,6 +567,11 @@
 	if (kc < minKeyCode) {
 		vlog.info("Keyboard mapping full - ignoring unknown keysym "
 			  "0x%x",keysym);
+#if XORG >= 17
+		xfree(keymap->map);
+		xfree(keymap);
+		xfree(modifierKeyMap);
+#endif
 		return;
 	}
 
@@ -487,13 +581,19 @@
 	 * 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 < maxKeysPerModifier; k++) {
+			int index = i * maxKeysPerModifier + k;
+			if (kc == modifierKeyMap[index] &&
+			    IS_PRESSED(keyc,kc) && down) {
+#if XORG >= 17
+				xfree(keymap->map);
+				xfree(keymap);
+				xfree(modifierKeyMap);
+#endif
 				return;
 		}
 	}
+	}
 
 	ModifierState shift(dev, ShiftMapIndex);
 	ModifierState modeSwitch(dev, modeSwitchMapIndex);
@@ -523,6 +623,12 @@
 	 * against this by processing the queue now.
 	 */
 	mieqProcessInputEvents();
+
+#if XORG >= 17
+	xfree(keymap->map);
+	xfree(keymap);
+	xfree(modifierKeyMap);
+#endif
 }
 
 static KeySym KeyCodetoKeySym(KeySymsPtr keymap, int keycode, int col)
@@ -761,9 +867,14 @@
 
 	switch (onoff) {
 	case DEVICE_INIT:
+#if XORG >= 17
+		InitKeyboardDeviceStruct(pDevice, NULL, keyboardBell,
+					(KbdCtrlProcPtr)NoopDDA);
+#else
 		GetMappings(&keySyms, modMap);
 		InitKeyboardDeviceStruct(pDev, &keySyms, modMap, keyboardBell,
 					 (KbdCtrlProcPtr)NoopDDA);
+#endif
 		break;
 	case DEVICE_ON:
 		pDev->on = TRUE;
Index: unix/xserver/hw/vnc/xorg-version.h
===================================================================
--- unix/xserver/hw/vnc/xorg-version.h	(revision 3925)
+++ unix/xserver/hw/vnc/xorg-version.h	(working copy)
@@ -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
Index: unix/xserver/hw/vnc/xvnc.cc
===================================================================
--- unix/xserver/hw/vnc/xvnc.cc	(revision 3925)
+++ unix/xserver/hw/vnc/xvnc.cc	(working copy)
@@ -81,6 +81,13 @@
 #endif /* RANDR */
 #include <X11/keysym.h>
   extern char buildtime[];
+
+#if XORG >= 17
+#undef VENDOR_RELEASE
+#undef VENDOR_STRING
+#include <site.h>
+#endif
+
 #undef class
 #undef public
 }
@@ -629,8 +636,17 @@
     {
 	if (pmap->mid != pmap->pScreen->defColormap)
 	{
+#if XORG >= 17
+            int ret = dixLookupResourceByType((pointer*) &curpmap, \
pmap->pScreen->defColormap, RT_COLORMAP, NullClient, +                                \
DixReadAccess); +            if (ret != Success) {
+		ErrorF("Failed to install colormap, code %d", ret);
+		return;
+            }
+#else
 	    curpmap = (ColormapPtr) LookupIDByType(pmap->pScreen->defColormap,
 						   RT_COLORMAP);
+#endif
 	    (*pmap->pScreen->InstallColormap)(curpmap);
 	}
     }
Index: unix/xserver/hw/vnc/Makefile.am
===================================================================
--- unix/xserver/hw/vnc/Makefile.am	(revision 3925)
+++ unix/xserver/hw/vnc/Makefile.am	(working copy)
@@ -52,7 +52,7 @@
 
 libvnc_la_LDFLAGS = -module -avoid-version
 
-libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS)
+libvnc_la_LIBADD = libvnccommon.la $(COMMON_LIBS) $(top_srcdir)/Xi/libXi.la \
$(top_srcdir)/dix/libdix.la $(top_srcdir)/xkb/libxkb.la  
 EXTRA_DIST = Xvnc.man
 
Index: unix/xserver/hw/vnc/XserverDesktop.cc
===================================================================
--- unix/xserver/hw/vnc/XserverDesktop.cc	(revision 3925)
+++ unix/xserver/hw/vnc/XserverDesktop.cc	(working copy)
@@ -54,6 +54,11 @@
 #ifdef RANDR
 #include "randrstr.h"
 #endif
+
+#if XORG >= 17
+#include <cursorstr.h>
+#endif
+
 #undef public
 #undef class
 }
@@ -185,8 +190,13 @@
   int i;
   pointer retval;
 
+#if XORG >= 17
+  i = dixLookupResourceByType(&retval, pScreen->defColormap, RT_COLORMAP, \
NullClient, +			      DixReadAccess);
+#else
   i = dixLookupResource(&retval, pScreen->defColormap, RT_COLORMAP, NullClient,
 			DixReadAccess);
+#endif
 
   /* Handle suspicious conditions */
   assert(i == Success);



------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 

_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic