I think I've found a workaround for the "BadValue" gdk_x_error()
on gnome applications in recent Linux distributions.
At
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=425189
it's said the fail is caused by a XkbSelectEventDetails() call; so
if you create a dynamic object which replaces that function, the
application will start:
$ tail -1 /etc/redhat-release
CentOS release 5 (Final)
$ ./hello_gtk
The program 'hello_gtk' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
(Details: serial 68 error_code 2 request_code 139 minor_code 1)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
$ cat xkb.c
int XkbSelectEventDetails(void *d, int ds, int ev, long b, long v) {return 1;}
$ gcc -fPIC -shared -Wl,-soname,xkb.so -o xkb.so xkb.c
$ LD_LIBRARY_PATH=$PWD LD_PRELOAD=xkb.so ./hello_gtk
... and "hello_gtk" runs fine.