xkb: wrong KeySym at first start of X

chris_honschu at gmx.de chris_honschu at gmx.de
Tue Aug 11 07:15:37 PDT 2009


Hi

at the first start and at the very beginning of a running X
the KeySym changes from a wrong value to the correct
one.
Is this a bug? Because thereby my window-manager 
keymappings go wrong.

I have a 'de' (German) keyboard (qwertz).
For the first ~14k loops of xkeytest the button "y" is
referred to a 'z':

loop-nr.:0 testing KeyCode=52 -> KeySym 0x7a name=z
loop-nr.:13906 testing KeyCode=52 -> KeySym 0x79 name=y



~/.xinitrc
exec xkeytest



/* xkeytest.c
 * ugly hack to check the keySym
 *
 * compile a.out with:
 *
 * gcc -I/usr/X11R6/include -O2 -lX11 xkeytest.c
 */

#include <X11/Xlib.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

Display *dpy;
KeySym ks = 0;
KeySym ks_i = 0;
KeyCode kc = 52;
char *ksname;
char str[200];
FILE *fp;
int counter = 0;

int main()
{
    system("echo \"*** date:\" >> /tmp/xkeytest");
    system("date >> /tmp/xkeytest");

    while (1) {
        if (!(dpy=XOpenDisplay(NULL))) {
            fprintf(stderr, "ERROR: could not open display\n");
            exit(1);
        }
        ks = XKeycodeToKeysym(dpy, kc, 0);
        ksname = XKeysymToString(ks);

        if ( ks_i != ks ) {
            if ((fp = fopen("/tmp/xkeytest", "a"))==NULL) {
                printf("Cannot open file.\n");
                exit(1);
            }
            sprintf(str, "loop-nr.:%u testing KeyCode=%u -> "
                          "KeySym 0x%lx name=%s\n",
                          counter, kc, (unsigned long) ks, ksname);
            fputs(str, fp);
            fclose(fp);

            printf("xkeytest: %s",str);
            system("echo \"*** xprop -root | grep XKB\" >> /tmp/xkeytest");
            system("xprop -root | grep XKB >> /tmp/xkeytest");
            system("echo \"*** xinput list\" >> /tmp/xkeytest");
            system("xinput list >> /tmp/xkeytest");
            system("echo >> /tmp/xkeytest");

            ks_i = ks;
        }
        XCloseDisplay(dpy);
        counter++;
    }

    return 0;
}



/tmp/xkeytest:
*** date:
Tue Aug 11 15:13:51 CEST 2009
loop-nr.:0 testing KeyCode=52 -> KeySym 0x7a name=z
*** xprop -root | grep XKB
_XKB_RULES_NAMES(STRING) = "xorg", "pc105", "de", "", ""
*** xinput list
"Virtual core keyboard"	id=0	[XKeyboard]
	Num_keys is 248
	Min_keycode is 8
	Max_keycode is 255
"Virtual core pointer"	id=1	[XPointer]
	Num_buttons is 32
	Num_axes is 2
	Mode is Relative
	Motion_buffer is 256
	Axis 0 :
		Min_value is 0
		Max_value is -1
		Resolution is 0
	Axis 1 :
		Min_value is 0
		Max_value is -1
		Resolution is 0
"LogiMouse"	id=2	[XExtensionPointer]
	Num_buttons is 9
	Num_axes is 2
	Mode is Relative
	Motion_buffer is 256
	Axis 0 :
		Min_value is -1
		Max_value is -1
		Resolution is 1
	Axis 1 :
		Min_value is -1
		Max_value is -1
		Resolution is 1
"<default keyboard>"	id=3	[XExtensionKeyboard]
	Num_keys is 248
	Min_keycode is 8
	Max_keycode is 255

loop-nr.:13906 testing KeyCode=52 -> KeySym 0x79 name=y
*** xprop -root | grep XKB
_XKB_RULES_NAMES(STRING) = "xorg", "pc105", "de", "", ""
*** xinput list
"Virtual core keyboard"	id=0	[XKeyboard]
	Num_keys is 248
	Min_keycode is 8
	Max_keycode is 255
"Virtual core pointer"	id=1	[XPointer]
	Num_buttons is 32
	Num_axes is 2
	Mode is Relative
	Motion_buffer is 256
	Axis 0 :
		Min_value is 0
		Max_value is -1
		Resolution is 0
	Axis 1 :
		Min_value is 0
		Max_value is -1
		Resolution is 0
"LogiMouse"	id=2	[XExtensionPointer]
	Num_buttons is 9
	Num_axes is 2
	Mode is Relative
	Motion_buffer is 256
	Axis 0 :
		Min_value is -1
		Max_value is -1
		Resolution is 1
	Axis 1 :
		Min_value is -1
		Max_value is -1
		Resolution is 1
"<default keyboard>"	id=3	[XExtensionKeyboard]
	Num_keys is 248
	Min_keycode is 8
	Max_keycode is 255



relevant lshal 
  system.firmware.release_date = '11/04/2005'  (string)
  system.firmware.vendor = 'Phoenix/Award Technologies, LTD'  (string)
  system.firmware.version = '6.00 PG'  (string)
  system.formfactor = 'desktop'  (string)
  system.kernel.machine = 'i686'  (string)
  system.kernel.name = 'Linux'  (string)
  system.kernel.version = '2.6.26-1-686'  (string)

udi = '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port'
  info.linux.driver = 'atkbd'  (string)
  info.parent = '/org/freedesktop/Hal/devices/platform_i8042'  (string)
  info.product = 'i8042 KBD port'  (string)
  info.subsystem = 'serio'  (string)
  info.udi = '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port'  
(string)
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'serio'  (string)
  linux.sysfs_path = '/sys/devices/platform/i8042/serio0'  (string)
  serio.description = 'i8042 KBD port'  (string)
  serio.id = 'serio0'  (string)

udi 
= '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port_logicaldev_input'
  info.addons.singleton = {'hald-addon-input'} (string list)
  info.capabilities = 
{'input', 'input.keyboard', 'input.keypad', 'input.keys', 'button'} (string 
list)
  info.category = 'input'  (string)
  info.parent = '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port'  
(string)
  info.product = 'AT Translated Set 2 keyboard'  (string)
  info.subsystem = 'input'  (string)
  info.udi 
= '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port_logicaldev_input'  
(string)
  input.device = '/dev/input/event0'  (string)
  input.originating_device 
= '/org/freedesktop/Hal/devices/platform_i8042_i8042_KBD_port'  (string)
  input.product = 'AT Translated Set 2 keyboard'  (string)
  input.xkb.layout = 'de'  (string)
  input.xkb.model = 'evdev'  (string)
  input.xkb.rules = 'base'  (string)
  input.xkb.variant = ''  (string)
  linux.device_file = '/dev/input/event0'  (string)
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'input'  (string)
  linux.sysfs_path = '/sys/class/input/input0/event0'  (string)



Xorg -version
X.Org X Server 1.4.2
Release Date: 11 June 2008
X Protocol Version 11, Revision 0
Build Operating System: Linux Debian (xorg-server 2:1.4.2-10.lenny2)
Current Operating System: Linux mars 2.6.26-1-686 #1 SMP Fri Mar 13 18:08:45 UTC 
2009 i686
Build Date: 08 June 2009  09:12:57AM


/etc/X11/xorg.conf
 no Section "InputDevice" with Driver "kbd"



More information about the xorg mailing list