Xpra: Ticket #1870: Key Mapping Problem

Overview

I'm using a GB keyboard, on a Canadian system, running Win 10, accessing Ubuntu via Xpra.

Windows client 2.3.1 r19531 64bit Server 2.2.6-r18968 (from package 2.2.6-r18969-1 (latest from winswitch repo))

With a gb keyboard selected in xpra, I see the following in Ubuntu. key-> result.

 [ -> 8
 ] -> 9
 < -> Z
 & -> K
 ^ -> C
 ` ->
 ' -> ´ (after 2 presses!)
 ~ ->

With us mapping selected, I see

 # -> 3

(but it's clearly still using a uk keymap, because shift-2 is sending " rather than @ etc, all other keys are sending their gb keycap value, except for £ that sends |. £ would normally be # on a us layout)

Xpra worked fine for many years, but started with this behavior after a version upgrade near the start of this year.. updated to latest version to see if the problem went away, but no luck.

Given the number of keys involved, I'm going to capture info for the # and & keys when on us and gb keymaps. Hopefully the cause behind '#' sending a '3' when on us keymap, and '&' sending a 'K' is the same as why all the other keys above are misbehaving on gb keymap.

Shout if additional info is needed.. I can append as required.

Keyboard Type

GTK Keyboard Test results.

GTK_Keyboard_Text.exe

pressing my # key
 - down/up numbersign # 35 222 0 0 []
pressing shift-7 (ampersand)
 - down/up ampersand & 38 55 0 0 ['S']

Setxkbmap ouput

setxkbmap output : (for us keymap selected)

$ setxkbmap -print
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us+inet(evdev)"     };
        xkb_geometry  { include "pc(pc105)"     };
};
$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us

setkbmap output : (for gb keymap selected)

$ setxkbmap -print
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+gb+inet(evdev)"     };
        xkb_geometry  { include "pc(pc105)"     };
};
$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     gb

xmodmap output

Requested for 'both' but not available on windows, supplied from host.

gb layout

$ xmodmap -pm
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):
shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_L (0xcc),  Meta_L (0xcd),  Meta_R (0xfe)
mod2        Num_Lock (0x4d)
mod3        Super_L (0x85),  Super_R (0x86),  Super_L (0xce)
mod4        Hyper_L (0xcf),  Hyper_R (0xfd)
mod5        ISO_Level3_Shift (0x5c),  ISO_Level3_Shift (0x6c),  Mode_switch (0xcb)

Server keycode 16,45,51 from xmodmap -pke

keycode  16 = 7 ampersand 7 ampersand
keycode  45 = k K k K kra ampersand kra
keycode  51 = numbersign asciitilde numbersign asciitilde dead_grave dead_breve dead_grave

us layout

$ xmodmap -pm
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):
shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Alt_L (0xcc),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3        Super_L (0x85),  Super_R (0x86),  Super_L (0xce)
mod4        Hyper_L (0xcf),  Hyper_R (0xfe)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

Server keycode 12,16 from xmodmap -pke

keycode  12 = 3 numbersign 3 numbersign
keycode  16 = 7 ampersand 7 ampersand

xbkprint

$ xkbprint -label name $DISPLAY

(No Output)

xev output for keys

# key being pressed with us keymap active

KeyPress event, serial 36, synthetic NO, window 0x2e00001,
    root 0x25c, subw 0x0, time 92934654, (236,102), root:(447,853),
    state 0x10, keycode 12 (keysym 0x33, 3), same_screen YES,
    XLookupString gives 1 bytes: (33) "3"
    XmbLookupString gives 1 bytes: (33) "3"
    XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x2e00001,
    root 0x25c, subw 0x0, time 92934830, (236,102), root:(447,853),
    state 0x10, keycode 12 (keysym 0x33, 3), same_screen YES,
    XLookupString gives 1 bytes: (33) "3"
    XFilterEvent returns: False

# key being pressed with gb keymap active

KeyPress event, serial 36, synthetic NO, window 0x2e00001,
    root 0x25c, subw 0x0, time 92991528, (186,-23), root:(423,754),
    state 0x10, keycode 51 (keysym 0x23, numbersign), same_screen YES,
    XLookupString gives 1 bytes: (23) "#"
    XmbLookupString gives 1 bytes: (23) "#"
    XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x2e00001,
    root 0x25c, subw 0x0, time 92991644, (186,-23), root:(423,754),
    state 0x10, keycode 51 (keysym 0x23, numbersign), same_screen YES,
    XLookupString gives 1 bytes: (23) "#"
    XFilterEvent returns: False

& key being pressed with gb keymap active

KeyPress event, serial 36, synthetic NO, window 0x1000001,
    root 0x25c, subw 0x0, time 95078279, (-16,102), root:(325,983),
    state 0x11, keycode 45 (keysym 0x4b, K), same_screen YES,
    XLookupString gives 1 bytes: (4b) "K"
    XmbLookupString gives 1 bytes: (4b) "K"
    XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1000001,
    root 0x25c, subw 0x0, time 95078383, (-16,102), root:(325,983),
    state 0x11, keycode 45 (keysym 0x4b, K), same_screen YES,
    XLookupString gives 1 bytes: (4b) "K"
    XFilterEvent returns: False

& key being pressed with us keymap active

KeyPress event, serial 36, synthetic NO, window 0x1200001,
    root 0x25c, subw 0x0, time 95144998, (398,367), root:(505,1014),
    state 0x11, keycode 16 (keysym 0x26, ampersand), same_screen YES,
    XLookupString gives 1 bytes: (26) "&"
    XmbLookupString gives 1 bytes: (26) "&"
    XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x1200001,
    root 0x25c, subw 0x0, time 95145104, (398,367), root:(505,1014),
    state 0x11, keycode 16 (keysym 0x26, ampersand), same_screen YES,
    XLookupString gives 1 bytes: (26) "&"
    XFilterEvent returns: False

Xpra debug keyboard

Press of # key with GB Keymap

2018-06-09 08:14:53,879 set_keyboard_layout_group(0) current keyboard group=None
2018-06-09 08:14:53,879 setting XKB layout group 0
2018-06-09 08:14:53,879 get_keycode(222, numbersign, ('mod2',)) keyname+keycode lookup: 51
2018-06-09 08:14:53,879 process_key_action(['key-action', 2, 'numbersign', True, ('mod2',), 35, '#', 222, 0]) server keycode=51
2018-06-09 08:14:53,880 filtered_modifiers_set(['mod2'])=set(['mod2'])
2018-06-09 08:14:53,880 filtered_modifiers_set(('mod2',))=set(['mod2'])
2018-06-09 08:14:53,880 handle_key(2,True,numbersign,35,51,('mod2',)) keyboard_sync=True
2018-06-09 08:14:53,880 is_modifier(51) not found
2018-06-09 08:14:53,880 handle keycode pressing    51: key 'numbersign'
2018-06-09 08:14:53,880 fake_key(51, True)
2018-06-09 08:14:53,881 scheduling key repeat timer with delay 500 for numbersign / 51
2018-06-09 08:14:54,030 set_keyboard_layout_group(0) current keyboard group=0
2018-06-09 08:14:54,030 get_keycode(222, numbersign, ('mod2',)) keyname+keycode lookup: 51
2018-06-09 08:14:54,030 process_key_action(['key-action', 2, 'numbersign', False, ('mod2',), 35, '#', 222, 0]) server keycode=51
2018-06-09 08:14:54,030 filtered_modifiers_set(['mod2'])=set(['mod2'])
2018-06-09 08:14:54,030 filtered_modifiers_set(('mod2',))=set(['mod2'])
2018-06-09 08:14:54,031 handle_key(2,False,numbersign,35,51,('mod2',)) keyboard_sync=True
2018-06-09 08:14:54,031 is_modifier(51) not found
2018-06-09 08:14:54,031 handle keycode unpressing  51: key 'numbersign'
2018-06-09 08:14:54,031 fake_key(51, False)

Press of & with GB Keymap

2018-06-09 08:22:05,496 handle keycode pressing    45: key 'ampersand'
2018-06-09 08:22:05,496 fake_key(45, True)
2018-06-09 08:22:05,496 scheduling key repeat timer with delay 500 for ampersand / 45
2018-06-09 08:22:05,598 set_keyboard_layout_group(0) current keyboard group=0
2018-06-09 08:22:05,598 get_keycode(55, ampersand, ('shift', 'mod2')) keyname+keycode lookup: 45
2018-06-09 08:22:05,598 process_key_action(['key-action', 4, 'ampersand', False, ('shift', 'mod2'), 38, '&', 55, 0]) server keycode=45
2018-06-09 08:22:05,598 filtered_modifiers_set(['mod2', 'shift'])=set(['shift', 'mod2'])
2018-06-09 08:22:05,599 filtered_modifiers_set(('shift', 'mod2'))=set(['shift', 'mod2'])
2018-06-09 08:22:05,599 handle_key(4,False,ampersand,38,45,('shift', 'mod2')) keyboard_sync=True
2018-06-09 08:22:05,599 is_modifier(45) not found
2018-06-09 08:22:05,599 handle keycode unpressing  45: key 'ampersand'
2018-06-09 08:22:05,599 fake_key(45, False)
2018-06-09 08:22:06,158 set_keyboard_layout_group(0) current keyboard group=0
2018-06-09 08:22:06,158 get_keycode(16, Shift_L, ('mod2',)) keyname+keycode lookup: 50
2018-06-09 08:22:06,158 process_key_action(['key-action', 4, 'Shift_L', False, ('mod2',), 65505, '', 16, 0]) server keycode=50
2018-06-09 08:22:06,158 modifier 'shift' ignored (in ignored keynames=set(['Shift_L', 'Shift_R']))
2018-06-09 08:22:06,158 filtered_modifiers_set(['mod2', 'shift'])=set(['mod2'])
2018-06-09 08:22:06,159 filtered_modifiers_set(('mod2',))=set(['mod2'])
2018-06-09 08:22:06,159 handle_key(4,False,Shift_L,65505,50,('mod2',)) keyboard_sync=True
2018-06-09 08:22:06,159 handle keycode unpressing  50: key 'Shift_L'
2018-06-09 08:22:06,159 fake_key(50, False)

Press of # Key with US Keymap

2018-06-09 08:15:38,257 set_keyboard_layout_group(0) current keyboard group=0
2018-06-09 08:15:38,257 get_keycode(222, numbersign, ('mod2',)) keyname+keycode lookup: 12
2018-06-09 08:15:38,257 process_key_action(['key-action', 2, 'numbersign', True, ('mod2',), 35, '#', 222, 0]) server keycode=12
2018-06-09 08:15:38,257 filtered_modifiers_set(['mod2'])=set(['mod2'])
2018-06-09 08:15:38,257 filtered_modifiers_set(('mod2',))=set(['mod2'])
2018-06-09 08:15:38,258 handle_key(2,True,numbersign,35,12,('mod2',)) keyboard_sync=True
2018-06-09 08:15:38,258 is_modifier(12) not found
2018-06-09 08:15:38,258 handle keycode pressing    12: key 'numbersign'
2018-06-09 08:15:38,258 fake_key(12, True)
2018-06-09 08:15:38,258 scheduling key repeat timer with delay 500 for numbersign / 12
2018-06-09 08:15:38,360 set_keyboard_layout_group(0) current keyboard group=0
2018-06-09 08:15:38,361 get_keycode(222, numbersign, ('mod2',)) keyname+keycode lookup: 12
2018-06-09 08:15:38,361 process_key_action(['key-action', 2, 'numbersign', False, ('mod2',), 35, '#', 222, 0]) server keycode=12
2018-06-09 08:15:38,361 filtered_modifiers_set(['mod2'])=set(['mod2'])
2018-06-09 08:15:38,361 filtered_modifiers_set(('mod2',))=set(['mod2'])
2018-06-09 08:15:38,361 handle_key(2,False,numbersign,35,12,('mod2',)) keyboard_sync=True
2018-06-09 08:15:38,361 is_modifier(12) not found
2018-06-09 08:15:38,362 handle keycode unpressing  12: key 'numbersign'
2018-06-09 08:15:38,362 fake_key(12, False)

Press of & Key with US Keymap

2018-06-09 08:27:08,823 handle keycode pressing    16: key 'ampersand'
2018-06-09 08:27:08,824 fake_key(16, True)
2018-06-09 08:27:08,824 scheduling key repeat timer with delay 500 for ampersand / 16
2018-06-09 08:27:08,918 set_keyboard_layout_group(0) current keyboard group=0
2018-06-09 08:27:08,918 get_keycode(55, ampersand, ('shift', 'mod2')) keyname+keycode lookup: 16
2018-06-09 08:27:08,918 process_key_action(['key-action', 4, 'ampersand', False, ('shift', 'mod2'), 38, '&', 55, 0]) server keycode=16
2018-06-09 08:27:08,919 filtered_modifiers_set(['mod2', 'shift'])=set(['shift', 'mod2'])
2018-06-09 08:27:08,919 filtered_modifiers_set(('shift', 'mod2'))=set(['shift', 'mod2'])
2018-06-09 08:27:08,919 handle_key(4,False,ampersand,38,16,('shift', 'mod2')) keyboard_sync=True
2018-06-09 08:27:08,919 is_modifier(16) not found
2018-06-09 08:27:08,919 handle keycode unpressing  16: key 'ampersand'
2018-06-09 08:27:08,919 fake_key(16, False)
2018-06-09 08:27:09,958 set_keyboard_layout_group(0) current keyboard group=0
2018-06-09 08:27:09,958 get_keycode(16, Shift_L, ('mod2',)) keyname+keycode lookup: 50
2018-06-09 08:27:09,958 process_key_action(['key-action', 4, 'Shift_L', False, ('mod2',), 65505, '', 16, 0]) server keycode=50
2018-06-09 08:27:09,958 modifier 'shift' ignored (in ignored keynames=set(['Shift_L', 'Shift_R']))
2018-06-09 08:27:09,959 filtered_modifiers_set(['mod2', 'shift'])=set(['mod2'])
2018-06-09 08:27:09,959 filtered_modifiers_set(('mod2',))=set(['mod2'])
2018-06-09 08:27:09,959 handle_key(4,False,Shift_L,65505,50,('mod2',)) keyboard_sync=True
2018-06-09 08:27:09,959 handle keycode unpressing  50: key 'Shift_L'
2018-06-09 08:27:09,959 fake_key(50, False)


Sat, 09 Jun 2018 12:55:12 GMT - Antoine Martin: owner changed

Please add "xpra info" for both layouts. Having the server log wouldn't hurt either.


Sat, 09 Jun 2018 13:21:36 GMT - Dweller: attachment set

Xpra Info for US Layout


Sat, 09 Jun 2018 13:22:03 GMT - Dweller: attachment set

Xpra Info for GB Layout


Sat, 09 Jun 2018 13:25:07 GMT - Dweller: owner changed

Ubuntu Version:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:        16.04
Codename:       xenial

Sat, 09 Jun 2018 13:29:05 GMT - Dweller: attachment set

Xpra log with -d keyboard


Sat, 09 Jun 2018 13:39:23 GMT - Dweller: attachment set

Results of Keymap_info.exe on client


Tue, 25 Sep 2018 12:14:09 GMT - Antoine Martin: owner, priority, status changed; milestone set

Will fix, I can reproduce this.

This really looks like something that #1902 should have fixed already.


Tue, 25 Sep 2018 17:00:05 GMT - Antoine Martin:

I believe r20530 is the correct fix for this. (more and more we use the new dynamic key lookup code for non-native clients, instead of relying on the pre-calculated translation map because this can take into account the level of the key)

This fix will be backported after more testing.

@Dweller: you should be able to apply it by hand.


Tue, 25 Sep 2018 17:20:51 GMT - Dweller:

I'll have a try later this evening =)


Tue, 25 Sep 2018 17:30:48 GMT - Antoine Martin:

I'll have a try later this evening =)

Thanks. There are updated beta builds with this fix for Ubuntu here: https://xpra.org/beta. (the fix is server-side only but you would also need r20420 so the 2.4 beta builds are your best bet)


Wed, 26 Sep 2018 15:50:49 GMT - Dweller:

Installed

Keyboard now works as expected =) woohoo! =)

Although I've had to remove --sync-vfb=15 from my xpra launch args.

Otherwise the mouse doesn't seem to be able to interact with any windows, I can move, resize etc (all window manager type stuff), but clicking on buttons does nothing, and mouse-overs are not triggering, so I guess the apps are unaware of the pointer location. Since I'm running a beta build now, I'm just mentioning this here.. once a non-beta build with the keyboard fixes in is available, I'll move to it and let you know if the same behavior is still present.

FWIW, my launch args are...

xpra start :100 --start=/usr/bin/wbar \
   --xvfb='Xvfb +extension Composite -screen 0 7360x2560x24+32 -dpi 96 -nolisten tcp -noreset -auth $XAUTHORITY' --sync-xvfb=15 \
   --html=off --file-transfer=yes --encoding=jpeg \
   --speaker=disabled --microphone=disabled --no-pulseaudio --desktop-scaling=off

Thu, 27 Sep 2018 02:08:01 GMT - Antoine Martin: status changed; resolution set

Keyboard now works as expected =) woohoo! =)

Closing.

I've had to remove --sync-vfb=15 from my xpra launch args.

Moving this to #1968

FWIW, my launch args are...

That's a strange launch args:


Thu, 27 Sep 2018 02:43:52 GMT - Dweller:

If I recall correctly, the xvfb arg was to add the screen size, because the normal default didn't allow for a client that large, preventing windows being moved to the full extents of the client desktop.

The jpeg was because mpeg based encoding lead to regular interval resolution drops, where it would go soft focus at what felt like key frame intervals. I suspect the large desktop size was having a bad impact on the codec. Jpeg was reliable, and I'm on a private wired gigabit LAN so bandwidth between the two isn't an issue.


Mon, 01 Oct 2018 10:48:25 GMT - Antoine Martin:

The sync-xvfb bug is fixed, see ticket:1968#comment:1.


Sat, 23 Jan 2021 05:35:58 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1870