Blob Blame Raw
--- libxklavier-2.1.0.2006.02.23/libxklavier/xklavier_config_xkb.c.trap-x-error	2006-03-09 15:10:56.000000000 -0500
+++ libxklavier-2.1.0.2006.02.23/libxklavier/xklavier_config_xkb.c	2006-03-09 15:35:13.000000000 -0500
@@ -158,6 +158,20 @@ void _XklXkbConfigCleanupNative( XkbComp
   free(componentNamesPtr->symbols);
   free(componentNamesPtr->geometry);
 }
+static int (* _XklTrapBeforeXkbWriteToServer) (Display *, XErrorEvent *);
+
+static int _XklXkbWriteToServerTrap (Display     *dpy, 
+                                     XErrorEvent *error_event)
+{
+  if (error_event->error_code != 0 &&
+      error_event->error_code != BadValue &&
+      _XklTrapBeforeXkbWriteToServer != NULL)
+    {
+      return _XklTrapBeforeXkbWriteToServer (dpy, error_event);
+    }
+
+  return 0;
+}
 
 static XkbDescPtr _XklConfigGetKeyboard( XkbComponentNamesPtr componentNamesPtr, Bool activate )
 {
@@ -243,8 +257,17 @@ static XkbDescPtr _XklConfigGetKeyboard(
                 XklDebug( 150, "Loaded legal keymap\n" );
                 if( activate )
                 {
+                  Bool config_was_written = False;
+
                   XklDebug( 150, "Activating it...\n" );
-                  if( XkbWriteToServer(&result) )
+
+                  _XklTrapBeforeXkbWriteToServer = XSetErrorHandler (_XklXkbWriteToServerTrap);
+
+                  config_was_written = XkbWriteToServer (&result);
+
+                  XSetErrorHandler (_XklTrapBeforeXkbWriteToServer);
+
+                  if (config_was_written)
                   {
                      XklDebug( 150, "Updating the keyboard...\n" );
                      xkb = result.xkb;