xserver: Branch 'master' - 10 commits

Daniel Stone daniels at kemper.freedesktop.org
Mon Jan 19 20:34:49 PST 2009


 Xi/exevents.c                  |  101 +++++++++++++++++++----------------------
 configure.ac                   |   82 +++++++++++++++++++++++----------
 dix/getevents.c                |    2 
 hw/xfree86/common/xf86Xinput.c |    9 +++
 include/inputstr.h             |    2 
 include/xkb-config.h.in        |   14 +++++
 include/xkbsrv.h               |    5 ++
 xkb/xkb.h                      |    6 --
 xkb/xkbAccessX.c               |   19 ++++---
 xkb/xkbActions.c               |    6 --
 xkb/xkbInit.c                  |   41 ++++------------
 xkb/xkbPrKeyEv.c               |   62 ++++++-------------------
 xkb/xkbUtils.c                 |   66 +++++++++++++++-----------
 13 files changed, 212 insertions(+), 203 deletions(-)

New commits:
commit e1611d8d55ade35bf8c2e1da7bc2dbf05b011301
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 27 13:34:05 2008 +1100

    XKB: Be more verbose about XkbCopyKeymap failure in debug mode
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 12ef120..a12cb79 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -2130,26 +2130,42 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
     memset(&changes, 0, sizeof(changes));
     memset(&cause, 0, sizeof(cause));
 
-    if (!src || !dst)
+    if (!src || !dst) {
+        DebugF("XkbCopyKeymap: src (%p) or dst (%p) is NULL\n", src, dst);
         return FALSE;
+    }
 
     if (src == dst)
         return TRUE;
 
-    if (!_XkbCopyClientMap(src, dst))
+    if (!_XkbCopyClientMap(src, dst)) {
+        DebugF("XkbCopyKeymap: failed to copy client map\n");
         return FALSE;
-    if (!_XkbCopyServerMap(src, dst))
+    }
+    if (!_XkbCopyServerMap(src, dst)) {
+        DebugF("XkbCopyKeymap: failed to copy server map\n");
         return FALSE;
-    if (!_XkbCopyIndicators(src, dst))
+    }
+    if (!_XkbCopyIndicators(src, dst)) {
+        DebugF("XkbCopyKeymap: failed to copy indicators\n");
         return FALSE;
-    if (!_XkbCopyControls(src, dst))
+    }
+    if (!_XkbCopyControls(src, dst)) {
+        DebugF("XkbCopyKeymap: failed to copy controls\n");
         return FALSE;
-    if (!_XkbCopyNames(src, dst))
+    }
+    if (!_XkbCopyNames(src, dst)) {
+        DebugF("XkbCopyKeymap: failed to copy names\n");
         return FALSE;
-    if (!_XkbCopyCompat(src, dst))
+    }
+    if (!_XkbCopyCompat(src, dst)) {
+        DebugF("XkbCopyKeymap: failed to copy compat map\n");
         return FALSE;
-    if (!_XkbCopyGeom(src, dst))
+    }
+    if (!_XkbCopyGeom(src, dst)) {
+        DebugF("XkbCopyKeymap: failed to copy geometry\n");
         return FALSE;
+    }
 
     for (tmpDev = inputInfo.devices; tmpDev && !pDev; tmpDev = tmpDev->next) {
         if (tmpDev->key && tmpDev->key->xkbInfo &&
commit 5ee504cae5f17d16ee7599beaa4b1944a9a8aee6
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 27 13:31:18 2008 +1100

    XKB: Trying to copy to the same keymap is not fatal
    
    Humour the user if they run XkbCopyKeymap(foo, foo).
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 19be1cf..12ef120 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -2130,9 +2130,12 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
     memset(&changes, 0, sizeof(changes));
     memset(&cause, 0, sizeof(cause));
 
-    if (!src || !dst || src == dst)
+    if (!src || !dst)
         return FALSE;
 
+    if (src == dst)
+        return TRUE;
+
     if (!_XkbCopyClientMap(src, dst))
         return FALSE;
     if (!_XkbCopyServerMap(src, dst))
commit d929ba6886c6f121b101c0bf0f7c63ef9d851a3e
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Dec 26 18:32:41 2008 +1100

    XFree86: Input: Fail NIDR if we can't enable devices
    
    If we can't enable a device, bail out of NewInputDeviceRequest rather than
    blithely continuing. Also, be more verbose when initialization failed. Also,
    be more verbose when initialization failed. Also, be more verbose when
    initialization failed. Also, be more verbose when initialization failed.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 413ef03..d5d06ad 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -591,12 +591,21 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
     dev = pInfo->dev;
     rval = ActivateDevice(dev);
     if (rval != Success)
+    {
+        xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier);
         goto unwind;
+    }
 
     /* Enable it if it's properly initialised and we're currently in the VT */
     if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)
     {
         EnableDevice(dev);
+        if (!dev->enabled)
+        {
+            xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier);
+            rval = BadMatch;
+            goto unwind;
+        }
         /* send enter/leave event, update sprite window */
         CheckMotion(NULL, dev);
     }
commit 534669b376a6a703fbc97269d279a5418cf60c98
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Jan 4 16:24:44 2009 +1100

    XKB: Remove unnecessary prototype
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index dae3596..424fc63 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -74,12 +74,6 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
     WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc);
 }
 
-extern	void	ProcessOtherEvent(
-    xEvent *		/* xE */,
-    DeviceIntPtr 	/* dev */,
-    int 		/* count */
-);
-
 /***====================================================================***/
 
 static XkbAction
commit 27ea1a7e4e7eca394e052791c64bc6be515e075e
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Jan 4 16:40:46 2009 +1100

    XKB: Only Xi events are processed
    
    Core events aren't run through these functions, so don't bother testing
    for them.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index f9b4b85..85d4096 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -33,6 +33,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/X.h>
 #include <X11/Xproto.h>
 #include <X11/keysym.h>
+#include "exglobals.h"
+#include <X11/extensions/XIproto.h>
 #include "inputstr.h"
 #include <xkbsrv.h>
 #if !defined(WIN32)
@@ -691,15 +693,16 @@ XkbSrvInfoPtr	xkbi = dev->key->xkbInfo;
 unsigned 	changed = 0;
 ProcessInputProc backupproc;
 xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
+deviceKeyButtonPointer *kbp = xE;
 
     xkbi->shiftKeyCount = 0;
-    xkbi->lastPtrEventTime= xE->u.keyButtonPointer.time;
+    xkbi->lastPtrEventTime= kbp->time;
 
-    if (xE->u.u.type==ButtonPress) {
+    if (xE->u.u.type==DeviceButtonPress) {
 	    changed |= XkbPointerButtonMask;
     }
-    else if (xE->u.u.type==ButtonRelease) {
-	xkbi->lockedPtrButtons&= ~(1<<(xE->u.u.detail&0x7));
+    else if (xE->u.u.type==DeviceButtonRelease) {
+	xkbi->lockedPtrButtons&= ~(1<<(kbp->detail&0x7));
 	changed |= XkbPointerButtonMask;
     }
 
@@ -726,7 +729,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
     xkbi->state.ptr_buttons = mouse->button->state;
     
     /* clear any latched modifiers */
-    if ( xkbi->state.latched_mods && (xE->u.u.type==ButtonRelease) ) {
+    if ( xkbi->state.latched_mods && (kbp->type==DeviceButtonRelease) ) {
 	unsigned 		changed_leds;
 	XkbStateRec		oldState;
 	XkbSrvLedInfoPtr	sli;
@@ -741,7 +744,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
 	    changed_leds= XkbIndicatorsToUpdate(dev,changed,False);
 	    if (changed_leds) {
 		XkbEventCauseRec	cause;
-		XkbSetCauseKey(&cause,(xE->u.u.detail&0x7),xE->u.u.type);
+		XkbSetCauseKey(&cause,(kbp->detail&0x7),kbp->type);
 		XkbUpdateIndicators(dev,changed_leds,True,NULL,&cause);
 	    }
 	}
@@ -750,8 +753,8 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
 
     if (((xkbi->flags&_XkbStateNotifyInProgress)==0)&&(changed!=0)) {
 	xkbStateNotify	sn;
-	sn.keycode= xE->u.u.detail;
-	sn.eventType= xE->u.u.type;
+	sn.keycode= kbp->detail;
+	sn.eventType= kbp->type;
 	sn.requestMajor = sn.requestMinor = 0;
 	sn.changed= changed;
 	XkbSendStateNotify(dev,&sn);
diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c
index 6feb9be..badfb14 100644
--- a/xkb/xkbPrKeyEv.c
+++ b/xkb/xkbPrKeyEv.c
@@ -49,16 +49,14 @@ XkbSrvInfoPtr	xkbi;
 int		key;
 XkbBehavior	behavior;
 unsigned        ndx;
-int             xiEvent;
 
     xkbi= keyc->xkbInfo;
     key= xE->u.u.detail;
-    xiEvent= (xE->u.u.type & EXTENSION_EVENT_BASE);
     if (xkbDebugFlags&0x8) {
-	DebugF("[xkb] XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up"));
+	DebugF("[xkb] XkbPKE: Key %d %s\n",key,(xE->u.u.type==DeviceKeyPress?"down":"up"));
     }
 
-    if ( (xkbi->repeatKey==key) && (xE->u.u.type==KeyRelease) &&
+    if ( (xkbi->repeatKey==key) && (xE->u.u.type==DeviceKeyRelease) &&
 	 ((xkbi->desc->ctrls->enabled_ctrls&XkbRepeatKeysMask)==0) ) {
 	AccessXCancelRepeatKey(xkbi,key);
     }
@@ -72,55 +70,37 @@ int             xiEvent;
     if ((behavior.type&XkbKB_Permanent)==0) {
 	switch (behavior.type) {
 	    case XkbKB_Default:
-		if (( xE->u.u.type == KeyPress || 
-                            xE->u.u.type == DeviceKeyPress) && 
+		if (xE->u.u.type == DeviceKeyPress && 
 		    (keyc->down[key>>3] & (1<<(key&7)))) {
 		    XkbLastRepeatEvent=	(pointer)xE;
 
-                    if (xiEvent)
-                        xE->u.u.type = DeviceKeyRelease;
-                    else
-                        xE->u.u.type = KeyRelease;
+                    xE->u.u.type = DeviceKeyRelease;
 		    XkbHandleActions(keybd,keybd,xE,count);
 
-                    if (xiEvent)
-                        xE->u.u.type = DeviceKeyPress;
-                    else
-                        xE->u.u.type = KeyPress;
+                    xE->u.u.type = DeviceKeyPress;
 		    XkbHandleActions(keybd,keybd,xE,count);
 		    XkbLastRepeatEvent= NULL;
 		    return;
 		}
-		else if ((xE->u.u.type==KeyRelease || 
-                            xE->u.u.type == DeviceKeyRelease) &&
+		else if (xE->u.u.type==DeviceKeyRelease &&
 			(!(keyc->down[key>>3]&(1<<(key&7))))) {
 		    XkbLastRepeatEvent=	(pointer)&xE;
-                    if (xiEvent)
-                        xE->u.u.type = DeviceKeyPress;
-                    else
-                        xE->u.u.type = KeyPress;
+                    xE->u.u.type = DeviceKeyPress;
 		    XkbHandleActions(keybd,keybd,xE,count);
-                    if (xiEvent)
-                        xE->u.u.type = DeviceKeyRelease;
-                    else
-                        xE->u.u.type = KeyRelease;
+                    xE->u.u.type = DeviceKeyRelease;
 		    XkbHandleActions(keybd,keybd,xE,count);
 		    XkbLastRepeatEvent= NULL;
 		    return;
 		}
 		break;
 	    case XkbKB_Lock:
-		if ( xE->u.u.type == KeyRelease || 
-                        xE->u.u.type == DeviceKeyRelease) {
+		if (xE->u.u.type == DeviceKeyRelease) {
 		    return;
                 }
 		else {
 		    int	bit= 1<<(key&7);
 		    if ( keyc->down[key>>3]&bit ) {
-                        if (xiEvent)
-                            xE->u.u.type = DeviceKeyRelease;
-                        else
-                            xE->u.u.type= KeyRelease;
+                        xE->u.u.type = DeviceKeyRelease;
                     }
                 }
 		break;
@@ -129,14 +109,13 @@ int             xiEvent;
 		if ( ndx<xkbi->nRadioGroups ) {
 		    XkbRadioGroupPtr	rg;
 
-		    if ( xE->u.u.type == KeyRelease ||
-                            xE->u.u.type == DeviceKeyRelease)
+		    if (xE->u.u.type == DeviceKeyRelease)
 		        return;
 
 		    rg = &xkbi->radioGroups[ndx];
 		    if ( rg->currentDown == xE->u.u.detail ) {
 		        if (behavior.data&XkbKB_RGAllowNone) {
-		            xE->u.u.type = KeyRelease;
+		            xE->u.u.type = DeviceKeyRelease;
 			    XkbHandleActions(keybd,keybd,xE,count);
 			    rg->currentDown= 0;
 		        }
@@ -144,16 +123,10 @@ int             xiEvent;
 		    }
 		    if ( rg->currentDown!=0 ) {
 			int key = xE->u.u.detail;
-                        if (xiEvent)
-                            xE->u.u.type = DeviceKeyRelease;
-                        else
-                            xE->u.u.type= KeyRelease;
+                        xE->u.u.type = DeviceKeyRelease;
 			xE->u.u.detail= rg->currentDown;
 		        XkbHandleActions(keybd,keybd,xE,count);
-                        if (xiEvent)
-                            xE->u.u.type = DeviceKeyPress;
-                        else
-                            xE->u.u.type= KeyPress;
+                        xE->u.u.type = DeviceKeyPress;
 		        xE->u.u.detail= key;
 		    }
 		    rg->currentDown= key;
@@ -194,9 +167,8 @@ ProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count)
     XkbSrvInfoPtr xkbi = NULL;
     ProcessInputProc backup_proc;
     xkbDeviceInfoPtr xkb_priv = XKBDEVICEINFO(keybd);
-    int is_press = (xE->u.u.type == KeyPress || xE->u.u.type == DeviceKeyPress);
-    int is_release = (xE->u.u.type == KeyRelease ||
-                      xE->u.u.type == DeviceKeyRelease);
+    int is_press = (xE->u.u.type == DeviceKeyPress);
+    int is_release = (xE->u.u.type == DeviceKeyRelease);
 
     if (keyc)
         xkbi = keyc->xkbInfo;
@@ -225,6 +197,6 @@ ProcessKeyboardEvent(xEvent *xE,DeviceIntPtr keybd,int count)
     } else {
         XkbProcessKeyboardEvent(xE, keybd, count);
     }
-    
+
     return;
 }
commit 2762cafc321166ac48f80146720709b1011e6894
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 27 13:35:42 2008 +1100

    XkbCopyKeymap: inputInfo.keyboard is not a special case
    
    The device-walking code is still depressing, though.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index aeb9892..19be1cf 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -2148,26 +2148,19 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
     if (!_XkbCopyGeom(src, dst))
         return FALSE;
 
-    if (inputInfo.keyboard->key->xkbInfo &&
-        inputInfo.keyboard->key->xkbInfo->desc == dst) {
-        pDev = inputInfo.keyboard;
-    }
-    else {
-        for (tmpDev = inputInfo.devices; tmpDev && !pDev;
-             tmpDev = tmpDev->next) {
-            if (tmpDev->key && tmpDev->key->xkbInfo &&
-                tmpDev->key->xkbInfo->desc == dst) {
-                pDev = tmpDev;
-                break;
-            }
+    for (tmpDev = inputInfo.devices; tmpDev && !pDev; tmpDev = tmpDev->next) {
+        if (tmpDev->key && tmpDev->key->xkbInfo &&
+            tmpDev->key->xkbInfo->desc == dst) {
+            pDev = tmpDev;
+            break;
         }
-        for (tmpDev = inputInfo.off_devices; tmpDev && !pDev;
-                tmpDev = tmpDev->next) {
-            if (tmpDev->key && tmpDev->key->xkbInfo &&
-                    tmpDev->key->xkbInfo->desc == dst) {
-                pDev = tmpDev;
-                break;
-            }
+    }
+    for (tmpDev = inputInfo.off_devices; tmpDev && !pDev;
+         tmpDev = tmpDev->next) {
+        if (tmpDev->key && tmpDev->key->xkbInfo &&
+            tmpDev->key->xkbInfo->desc == dst) {
+            pDev = tmpDev;
+            break;
         }
     }
 
commit 07c3bb922b8c1ae8fe28198f6c451430b836f21e
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Jan 4 14:12:19 2009 +1100

    XKB: Move XkbCopyKeymap definition to xkbsrv.h
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 81bdf0a..b136e01 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -77,7 +77,6 @@ SOFTWARE.
 #ifdef XKB
 #include <X11/extensions/XKBproto.h>
 #include "xkbsrv.h"
-extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies);
 #endif
 
 #define WID(w) ((w) ? ((w)->drawable.id) : 0)
diff --git a/dix/getevents.c b/dix/getevents.c
index 672ff7d..44636d7 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -44,7 +44,7 @@
 
 #ifdef XKB
 #include <X11/extensions/XKBproto.h>
-#include <xkbsrv.h>
+#include "xkbsrv.h"
 #endif
 
 #ifdef PANORAMIX
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index ac1d822..ee04063 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -974,6 +974,11 @@ extern _X_EXPORT void XkbSendNewKeyboardNotify(
 	xkbNewKeyboardNotify *	/* pNKN */
 );
 
+extern Bool XkbCopyKeymap(
+        XkbDescPtr              /* dst */,
+        XkbDescPtr              /* src */,
+        Bool                    /* sendNotifies */);
+
 #include "xkbfile.h"
 #include <X11/extensions/XKMformat.h>
 #include "xkbrules.h"
diff --git a/xkb/xkb.h b/xkb/xkb.h
index bc6c6c9..45d9b3d 100644
--- a/xkb/xkb.h
+++ b/xkb/xkb.h
@@ -31,10 +31,4 @@ extern int ProcXkbSetDebuggingFlags(ClientPtr client);
 extern void XkbExtensionInit(void);
 
 extern Bool XkbFilterEvents(ClientPtr pClient, int nEvents, xEvent *xE);
-
-extern Bool XkbCopyKeymap(
-    XkbDescPtr              src,
-    XkbDescPtr              dst,
-    Bool                    sendNotifies);
-
 #endif
commit 4f35a34f3cd3df3c8af129936d1808dcc063d8a7
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Thu Aug 14 17:26:02 2008 +0930

    dix: Remove traces of CoreDevicePrivateKey
    
    Obsolete with MPX.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/include/inputstr.h b/include/inputstr.h
index adb7b9a..bcfc09e 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -63,8 +63,6 @@ SOFTWARE.
 
 #define EMASKSIZE	MAXDEVICES + 1
 
-extern _X_EXPORT DevPrivateKey CoreDevicePrivateKey;
-
 /* Kludge: OtherClients and InputClients must be compatible, see code */
 
 typedef struct _OtherClients {
commit 58a6b5b9eff25b1b9c6de239d6f5a952a31dfd15
Author: Peter Hutterer <peter.hutterer at redhat.com>
Date:   Thu Aug 14 17:21:28 2008 +0930

    Xi: don't care about CoreDevicePrivateKey when copying keys
    
    If we get here, we must copy.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 6bf9e56..81bdf0a 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -203,67 +203,56 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
     dk = device->key;
     mk = master->key;
 
-    if (device != dixLookupPrivate(&master->devPrivates,
-                                   CoreDevicePrivateKey)) {
-        memcpy(mk->modifierMap, dk->modifierMap, MAP_LENGTH);
+    memcpy(mk->modifierMap, dk->modifierMap, MAP_LENGTH);
 
-        if (dk->maxKeysPerModifier)
-        {
-            mk->modifierKeyMap = xrealloc(mk->modifierKeyMap,
-                                          8 * dk->maxKeysPerModifier);
-            if (!mk->modifierKeyMap)
-                FatalError("[Xi] no memory for class shift.\n");
-            memcpy(mk->modifierKeyMap, dk->modifierKeyMap,
-                    (8 * dk->maxKeysPerModifier));
-        } else
-        {
-            xfree(mk->modifierKeyMap);
-            mk->modifierKeyMap = NULL;
-        }
+    if (dk->maxKeysPerModifier)
+    {
+        mk->modifierKeyMap = xrealloc(mk->modifierKeyMap,
+                                      8 * dk->maxKeysPerModifier);
+        if (!mk->modifierKeyMap)
+            FatalError("[Xi] no memory for class shift.\n");
+        memcpy(mk->modifierKeyMap, dk->modifierKeyMap,
+                (8 * dk->maxKeysPerModifier));
+    } else
+    {
+        xfree(mk->modifierKeyMap);
+        mk->modifierKeyMap = NULL;
+    }
+
+    mk->maxKeysPerModifier = dk->maxKeysPerModifier;
+    mk->curKeySyms.minKeyCode = dk->curKeySyms.minKeyCode;
+    mk->curKeySyms.maxKeyCode = dk->curKeySyms.maxKeyCode;
+    SetKeySymsMap(&mk->curKeySyms, &dk->curKeySyms);
 
-        mk->maxKeysPerModifier = dk->maxKeysPerModifier;
-        mk->curKeySyms.minKeyCode = dk->curKeySyms.minKeyCode;
-        mk->curKeySyms.maxKeyCode = dk->curKeySyms.maxKeyCode;
-        SetKeySymsMap(&mk->curKeySyms, &dk->curKeySyms);
-
-        /*
-         * Copy state from the extended keyboard to core.  If you omit this,
-         * holding Ctrl on keyboard one, and pressing Q on keyboard two, will
-         * cause your app to quit.  This feels wrong to me, hence the below
-         * code.
-         *
-         * XXX: If you synthesise core modifier events, the state will get
-         *      clobbered here.  You'll have to work out something sensible
-         *      to fix that.  Good luck.
-         */
+    /*
+     * Copy state from the extended keyboard to core.  If you omit this,
+     * holding Ctrl on keyboard one, and pressing Q on keyboard two, will
+     * cause your app to quit.  This feels wrong to me, hence the below
+     * code.
+     *
+     * XXX: If you synthesise core modifier events, the state will get
+     *      clobbered here.  You'll have to work out something sensible
+     *      to fix that.  Good luck.
+     */
 
 #define KEYBOARD_MASK (ShiftMask | LockMask | ControlMask | Mod1Mask | \
         Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
-        mk->state &= ~(KEYBOARD_MASK);
-        mk->state |= (dk->state & KEYBOARD_MASK);
+    mk->state &= ~(KEYBOARD_MASK);
+    mk->state |= (dk->state & KEYBOARD_MASK);
 #undef KEYBOARD_MASK
-        for (i = 0; i < 8; i++)
-            mk->modifierKeyCount[i] = dk->modifierKeyCount[i];
+    for (i = 0; i < 8; i++)
+        mk->modifierKeyCount[i] = dk->modifierKeyCount[i];
 
-#ifdef XKB
-        if (!noXkbExtension && dk->xkbInfo && dk->xkbInfo->desc) {
-            if (!mk->xkbInfo || !mk->xkbInfo->desc)
-            {
-                XkbInitDevice(master);
-                XkbFinishDeviceInit(master);
-            }
-            if (!XkbCopyKeymap(dk->xkbInfo->desc, mk->xkbInfo->desc, True))
-                FatalError("Couldn't pivot keymap from device to core!\n");
+    if (dk->xkbInfo && dk->xkbInfo->desc) {
+        if (!mk->xkbInfo || !mk->xkbInfo->desc) {
+            XkbInitDevice(master);
+            XkbFinishDeviceInit(master);
         }
-#endif
-
-        dixSetPrivate(&master->devPrivates, CoreDevicePrivateKey, device);
-        sendNotify = TRUE;
-    } else if (lastMapNotifyDevice != master)
-        sendNotify = TRUE;
+        if (!XkbCopyKeymap(dk->xkbInfo->desc, mk->xkbInfo->desc, True))
+            FatalError("Couldn't pivot keymap from device to core!\n");
+    }
 
-    if (sendNotify)
-    {
+    if (lastMapNotifyDevice != master) {
         SendMappingNotify(master, MappingKeyboard,
                            mk->curKeySyms.minKeyCode,
                           (mk->curKeySyms.maxKeyCode -
@@ -271,6 +260,13 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
                           serverClient);
         lastMapNotifyDevice = master;
     }
+
+    /* Copy the state here.  This means we'll only have consistency
+     * between state and active keymap, rather than between state and
+     * keycodes pressed, but there's pretty much no way to win here,
+     * so might as well go for the one that would seem to give the
+     * least nonsensical result. */
+    mk->xkbInfo->state = dk->xkbInfo->state;
 }
 
 /**
commit 23862ede59a9ce11a06ec5151bde460fb836c603
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Jan 10 14:36:16 2009 +0200

    XKB: Allow build-time configuration of XKB defaults
    
    Instead of hardcoding base/pc105/us, allow users to change the defaults at
    ./configure time.  Change the default model to be evdev on Linux.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/configure.ac b/configure.ac
index dec9319..e8c5b6a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -485,6 +485,26 @@ AC_ARG_WITH(xkb-path,         AS_HELP_STRING([--with-xkb-path=PATH], [Path to XK
 AC_ARG_WITH(xkb-output,       AS_HELP_STRING([--with-xkb-output=PATH], [Path to XKB output dir (default: ${datadir}/X11/xkb/compiled)]),
 				[ XKBOUTPUT="$withval" ],
 				[ XKBOUTPUT="compiled" ])
+AC_ARG_WITH(default-xkb-rules, AS_HELP_STRING([--with-default-xkb-rules=RULES],
+                                   [Keyboard ruleset (default: base/evdev)]),
+                                [ XKB_RULES="$withval" ],
+                                [ XKB_RULES="" ])
+AC_ARG_WITH(default-xkb-model, AS_HELP_STRING([--with-default-xkb-model=MODEL],
+                                   [Keyboard model (default: pc104)]),
+                                [ XKB_MODEL="$withval" ],
+                                [ XKB_MODEL="pc104" ])
+AC_ARG_WITH(default-xkb-layout, AS_HELP_STRING([--with-default-xkb-layout=LAYOUT],
+                                   [Keyboard layout (default: us)]),
+                                [ XKB_LAYOUT="$withval" ],
+                                [ XKB_LAYOUT="us" ])
+AC_ARG_WITH(default-xkb-variant, AS_HELP_STRING([--with-default-xkb-variant=VARIANT],
+                                   [Keyboard variant (default: (none))]),
+                                [ XKB_VARIANT="$withval" ],
+                                [ XKB_VARIANT="" ])
+AC_ARG_WITH(default-xkb-options, AS_HELP_STRING([--with-default-xkb-options=OPTIONS],
+                                   [Keyboard layout options (default: (none))]),
+                                [ XKB_OPTIONS="$withval" ],
+                                [ XKB_OPTIONS="" ])
 AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH],
 				   [Directory where ancillary server config files are installed (default: ${libdir}/xorg)]),
 				[ SERVERCONFIG="$withval" ],
@@ -996,9 +1016,47 @@ AC_DEFINE(SHAPE, 1, [Support SHAPE extension])
 AC_DEFINE(XKB, 1, [Build XKB])
 AC_DEFINE(XKB_IN_SERVER, 1, [Build XKB server])
 AC_DEFINE(XKB_DFLT_DISABLED, 0, [Disable XKB per default])
-REQUIRED_MODULES="$REQUIRED_MODULES xkbfile"
+AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data])
+AC_DEFINE_DIR(XKB_BIN_DIRECTORY, bindir, [Path to XKB bin dir])
+
+dnl Make sure XKM_OUTPUT_DIR is an absolute path
+XKBOUTPUT_FIRSTCHAR=`echo $XKBOUTPUT | cut -b 1`
+if [[ x$XKBOUTPUT_FIRSTCHAR != x/ ]] ; then
+   XKBOUTPUT="$XKB_BASE_DIRECTORY/$XKBOUTPUT"
+fi
+
+dnl XKM_OUTPUT_DIR (used in code) must end in / or file names get hosed
+dnl XKB_COMPILED_DIR (used in Makefiles) must not or install-sh gets confused
+
+XKBOUTPUT=`echo $XKBOUTPUT/ | sed 's|/*$|/|'`
+XKB_COMPILED_DIR=`echo $XKBOUTPUT | sed 's|/*$||'`
+AC_DEFINE_DIR(XKM_OUTPUT_DIR, XKBOUTPUT, [Path to XKB output dir])
+AC_SUBST(XKB_COMPILED_DIR)
+
+if test "x$XKB_DFLT_RULES" = x; then
+    case $host_os in
+    linux*)
+        dnl doesn't take AutoAddDevices into account, but whatever.
+        if test "x$CONFIG_HAL" = xyes; then
+            XKB_DFLT_RULES="evdev"
+        else
+            XKB_DFLT_RULES="base"
+        fi
+        ;;
+    *)
+        XKB_DFLT_RULES="base"
+        ;;
+    esac
+fi
+AC_DEFINE_UNQUOTED(XKB_DFLT_RULES, ["$XKB_DFLT_RULES"], [Default XKB ruleset])
+AC_DEFINE_UNQUOTED(XKB_DFLT_MODEL, ["$XKB_DFLT_MODEL"], [Default XKB model])
+AC_DEFINE_UNQUOTED(XKB_DFLT_LAYOUT, ["$XKB_DFLT_LAYOUT"], [Default XKB layout])
+AC_DEFINE_UNQUOTED(XKB_DFLT_VARIANT, ["$XKB_DFLT_VARIANT"], [Default XKB variant])
+AC_DEFINE_UNQUOTED(XKB_DFLT_OPTIONS, ["$XKB_DFLT_OPTIONS"], [Default XKB options])
+
 XKB_LIB='$(top_builddir)/xkb/libxkb.la'
 XKB_STUB_LIB='$(top_builddir)/xkb/libxkbstubs.la'
+REQUIRED_MODULES="$REQUIRED_MODULES xkbfile"
 
 AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
                                         [Do not have 'strcasecmp'.]))
@@ -1786,28 +1844,6 @@ AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
 AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes])
 AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
 
-dnl these only go in xkb-config.h (which is shared by the Xorg and Xnest servers)
-AC_DEFINE(__XKBDEFRULES__, "xorg", [Default XKB rules])
-AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data])
-AC_DEFINE_DIR(XKB_BIN_DIRECTORY, bindir, [Path to XKB bin dir])
-
-# Make sure XKM_OUTPUT_DIR is an absolute path
-XKBOUTPUT_FIRSTCHAR=`echo $XKBOUTPUT | cut -b 1`
-
-if [[ x$XKBOUTPUT_FIRSTCHAR != x/ ]] ; then
-   XKBOUTPUT="$XKB_BASE_DIRECTORY/$XKBOUTPUT"
-fi
-
-# XKM_OUTPUT_DIR (used in code) must end in / or file names get hosed
-# XKB_COMPILED_DIR (used in Makefiles) must not or install-sh gets confused
-
-XKBOUTPUT=`echo $XKBOUTPUT/ | sed 's|/*$|/|'`
-XKB_COMPILED_DIR=`echo $XKBOUTPUT | sed 's|/*$||'`
-
-AC_DEFINE_DIR(XKM_OUTPUT_DIR, XKBOUTPUT, [Path to XKB output dir])
-
-AC_SUBST(XKB_COMPILED_DIR)
-
 dnl and the rest of these are generic, so they're in config.h
 dnl 
 dnl though, thanks to the passing of some significant amount of time, the
diff --git a/include/xkb-config.h.in b/include/xkb-config.h.in
index 29261de..d3cdd19 100644
--- a/include/xkb-config.h.in
+++ b/include/xkb-config.h.in
@@ -6,7 +6,19 @@
 #define _XKB_CONFIG_H_
 
 /* Default set of XKB rules. */
-#undef __XKBDEFRULES__
+#undef XKB_DFLT_RULES
+
+/* Default XKB model. */
+#undef XKB_DFLT_MODEL
+
+/* Default XKB layout. */
+#undef XKB_DFLT_LAYOUT
+
+/* Default XKB variant. */
+#undef XKB_DFLT_VARIANT
+
+/* Default XKB options. */
+#undef XKB_DFLT_OPTIONS
 
 /* Path to XKB definitions. */
 #undef XKB_BASE_DIRECTORY
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index f10125b..573e731 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -85,27 +85,6 @@ typedef struct	_SrvXkmInfo {
 
 /***====================================================================***/
 
-#ifndef XKB_BASE_DIRECTORY
-#define	XKB_BASE_DIRECTORY	"/usr/lib/X11/xkb"
-#endif
-#ifndef XKB_BIN_DIRECTORY
-#define	XKB_BIN_DIRECTORY	XKB_BASE_DIRECTORY
-#endif
-#ifndef XKB_DFLT_RULES_FILE
-#define	XKB_DFLT_RULES_FILE	"base"
-#endif
-#ifndef XKB_DFLT_KB_LAYOUT
-#define	XKB_DFLT_KB_LAYOUT	"us"
-#endif
-#ifndef XKB_DFLT_KB_MODEL
-#define	XKB_DFLT_KB_MODEL	"dflt"
-#endif
-#ifndef XKB_DFLT_KB_VARIANT
-#define	XKB_DFLT_KB_VARIANT	NULL
-#endif
-#ifndef XKB_DFLT_KB_OPTIONS
-#define	XKB_DFLT_KB_OPTIONS	NULL
-#endif
 #ifndef XKB_DFLT_DISABLED
 #define	XKB_DFLT_DISABLED	True
 #endif
@@ -140,14 +119,14 @@ static char *
 XkbGetRulesDflts(XkbRF_VarDefsPtr defs)
 {
     if (XkbModelDflt)	defs->model= XkbModelDflt;
-    else		defs->model= XKB_DFLT_KB_MODEL;
+    else		defs->model= XKB_DFLT_MODEL;
     if (XkbLayoutDflt)	defs->layout= XkbLayoutDflt;
-    else		defs->layout= XKB_DFLT_KB_LAYOUT;
+    else		defs->layout= XKB_DFLT_LAYOUT;
     if (XkbVariantDflt)	defs->variant= XkbVariantDflt;
-    else		defs->variant= XKB_DFLT_KB_VARIANT;
+    else		defs->variant= XKB_DFLT_VARIANT;
     if (XkbOptionsDflt)	defs->options= XkbOptionsDflt;
-    else		defs->options= XKB_DFLT_KB_OPTIONS;
-    return (rulesDefined?XkbRulesFile:XKB_DFLT_RULES_FILE);
+    else		defs->options= XKB_DFLT_OPTIONS;
+    return (rulesDefined?XkbRulesFile:XKB_DFLT_RULES);
 }
 
 static Bool
@@ -159,7 +138,7 @@ char *			pval;
 
     if (rulesDefined && (!XkbRulesFile))
 	return False;
-    len= (XkbRulesFile?strlen(XkbRulesFile):strlen(XKB_DFLT_RULES_FILE));
+    len= (XkbRulesFile?strlen(XkbRulesFile):strlen(XKB_DFLT_RULES));
     len+= (XkbModelUsed?strlen(XkbModelUsed):0);
     len+= (XkbLayoutUsed?strlen(XkbLayoutUsed):0);
     len+= (XkbVariantUsed?strlen(XkbVariantUsed):0);
@@ -185,8 +164,8 @@ char *			pval;
 	strcpy(&pval[out],XkbRulesFile);
 	out+= strlen(XkbRulesFile);
     } else {
-	strcpy(&pval[out],XKB_DFLT_RULES_FILE);
-	out+= strlen(XKB_DFLT_RULES_FILE);
+	strcpy(&pval[out],XKB_DFLT_RULES);
+	out+= strlen(XKB_DFLT_RULES);
     }
     pval[out++]= '\0';
     if (XkbModelUsed) {
@@ -255,8 +234,8 @@ XkbSetRulesDflts(char *rulesFile,char *model,char *layout,
     {
 	LogMessage(X_WARNING, "[xkb] No rule given, and no previous rule "
 		              "defined. Defaulting to '%s'.\n",
-                              XKB_DFLT_RULES_FILE);
-	rulesFile = XKB_DFLT_RULES_FILE;
+                              XKB_DFLT_RULES);
+	rulesFile = XKB_DFLT_RULES;
     }
 
     if (rulesFile) {


More information about the xorg-commit mailing list