--- deviceeventcontroller.c.orig	2007-04-09 02:37:08.000000000 -0400
+++ deviceeventcontroller.c	2008-01-09 11:38:15.000000000 -0500
@@ -82,6 +82,7 @@
 static unsigned int _numlock_physical_mask = Mod2Mask; /* a guess, will be reset */
 
 static GQuark spi_dec_private_quark = 0;
+XModifierKeymap* xmkeymap = NULL;
 
 static int (*x_default_error_handler) (Display *display, XErrorEvent *error_event);
 
@@ -2130,15 +2131,37 @@
 static gboolean
 dec_lock_modifiers (SpiDEController *controller, unsigned modifiers)
 {
-	return XkbLockModifiers (spi_get_display (), XkbUseCoreKbd, 
-			  modifiers, modifiers);
+    DEControllerPrivateData *priv = (DEControllerPrivateData *) 
+    g_object_get_qdata (G_OBJECT (controller), spi_dec_private_quark);	 
+    
+    if (priv->have_xkb) {
+        return XkbLockModifiers (spi_get_display (), XkbUseCoreKbd, 
+                                  modifiers, modifiers);
+    } else {
+	int mod_index;
+	for (mod_index=0;mod_index<8;mod_index++)
+	    if (modifiers & (1<<mod_index))
+	        dec_synth_keycode_press(controller, xmkeymap->modifiermap[mod_index]);
+	return TRUE;
+    }
 }
 
 static gboolean
 dec_unlock_modifiers (SpiDEController *controller, unsigned modifiers)
 {
-	return XkbLockModifiers (spi_get_display (), XkbUseCoreKbd, 
-			  modifiers, 0);
+    DEControllerPrivateData *priv = (DEControllerPrivateData *) 
+    g_object_get_qdata (G_OBJECT (controller), spi_dec_private_quark);	 
+    
+    if (priv->have_xkb) {
+        return XkbLockModifiers (spi_get_display (), XkbUseCoreKbd, 
+                                  modifiers, 0);
+    } else {
+	int mod_index;
+	for (mod_index=0;mod_index<8;mod_index++)
+	    if (modifiers & (1<<mod_index))
+	        dec_synth_keycode_release(controller, xmkeymap->modifiermap[mod_index]);
+	return TRUE;
+    }
 }
 
 static KeySym
@@ -2268,6 +2291,10 @@
   
   gdk_error_trap_push ();
 
+  if (xmkeymap==NULL) {
+    xmkeymap = XGetModifierMapping(spi_get_display ());
+  }
+
   switch (synth_type)
     {
       case Accessibility_KEY_PRESS:
