Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Using non-US keyboard layouts makes special characters come up wrong. #298

Closed
Elktro opened this issue Nov 11, 2015 · 12 comments
Closed

Comments

@Elktro
Copy link
Contributor

Elktro commented Nov 11, 2015

I'm using Plover on a Linux computer (Ubuntu 15.04) and I noticed that the Plover is somehow affected by the active keyboard layout. For example, I if press PAOEUP which mapped to "{^|^}" while I have the US keyboard selected I get the normal pipe symbol (|). If I, however, have the Finnish keyboard, which is what I usually use all the time, I get the asterisk ().

It seems that Plover is effectively press the key left to enter-key with shift down. On the U.S. keyboard layout it creates the pipe symbol, but on the Finnish keyboard layout it is mapped to the asterisk.

This problem occurs even though I have the Finnish keyboard layout selected when I start Plover.

@benoit-pierre
Copy link
Member

It's weird that it is happening if the layout is set to Finnish before starting Plover. Can you try with the current Git master?

Changing layouts while Plover is running will not work, but I'm working on a fix.

@Elktro
Copy link
Contributor Author

Elktro commented Nov 12, 2015

Tested with

Before I ran "python launch.py", I made sure that I definitely had Finnish keyboard layout active. Still, I experienced the same problem.

@benoit-pierre
Copy link
Member

OK, can you give me the output of setxkbmap -query and xmodmap -pke with both layouts?

@Elktro
Copy link
Contributor Author

Elktro commented Nov 13, 2015

setxkbmap -query when I have the Finnish keyboard layout selected:

rules:      evdev
model:      pc105
layout:     fi,us
variant:    ,
options:    caps:ctrl_modifier

setxkbmap -query when I have the US keyboard layout selected:

rules:      evdev
model:      pc105
layout:     us
options:    caps:ctrl_modifier

Here are the outputs of xmodmap with the layouts:

[xmodmap_fi.txt](https://github.com/openstenoproject/plover/files/33457/xmodmap_fi.txt)
[xmodmap_us.txt](https://github.com/openstenoproject/plover/files/33458/xmodmap_us.txt)

A funny thing, that I just noticed is that some characters seemed to behave right. Such as the colon (:) or the equal sign (=). Which I have defined as

"ST-L": "=",
"TP-PBLG": "{^:}",

Could it have something to do with the fact that the pipe character needs to be typed with the "Alt Gr" or the ISO_Level3_Shift button?

Actually I have XK.load_keysym_group('xkb') in my xkeyboardcontrol.py of my own private clone of Plover to enable me to use "Alt Gr" button.

Here's the diff of the file:

@@ -260,6 +205,8 @@ class KeyboardEmulation(object):
         """Prepare to emulate keyboard events."""
         self.display = display.Display()
         self.modifier_mapping = self.display.get_modifier_mapping()
+        # Load non-us keyboard related keysyms.
+        XK.load_keysym_group('xkb')
         # Determine the backspace keycode.
         backspace_keysym = XK.string_to_keysym('BackSpace')

@benoit-pierre
Copy link
Member

AFAIK, using XK.load_keysym_group('xkb') only extends the list of keysyms available with the XK module, that does not make them available in your keyboard layout...

As for handling "Alt Gr" combos, that's why I asked you to try with the latest Git, because I added support for it: cbedcb2

@benoit-pierre
Copy link
Member

Our handling of groups is wrong, looking into it...

@benoit-pierre
Copy link
Member

So, bad news, bad news...

Without proper support for the XKB extension, there is not way to correctly handle groups... Even worse, the current support for "Alt Gr" combos will not work if more than 1 group is used:

  • we can't set higher modifiers bits when sending a key press/release event with XSendEvent to latch the correct group
  • and even if we could, the keymap information reported by Xlib (without XKB) is not valid when more than 1 group is used (same as with the output of xmodmap -pk utility really)

@morinted morinted added this to the plover-next milestone Feb 10, 2016
@morinted
Copy link
Member

For this issue, if we can at least get to a point where our limitations are defined and we are better off than the current situation, then we can at least claim an improvement. I'd like to have this in for Plover next.

@morinted morinted removed this from the plover-next milestone Feb 10, 2016
@Elktro
Copy link
Contributor Author

Elktro commented Feb 11, 2016

The way I have gotten the pipe symbol working is by defining a dictionary entry:

"PAO*EUP": "{#ISO_Level3_Shift(less)}"

Where the ISO_Level3_shift key as a meta key is enabled by the XK.load_keysym_group('xkb') in the xkeyboardcontrol.py.

This is, of course, not even close to the solution and these kind of entries make the dictionaries keyboard layout specific but it was the only way I was able to get the pipe symbol working with the Finnish keyboard layout.

@jeremy-w jeremy-w changed the title Using non-US keyboard layouts makes special characters come up wrong. Linux: Using non-US keyboard layouts makes special characters come up wrong. Apr 26, 2016
@jeremy-w
Copy link
Member

@benoit-pierre It reads like you have a good understanding of this issue. Is there a solution possible, even if it's one we can't readily implement just now?

@benoit-pierre
Copy link
Member

We need XKB support in python-xlib.

@benoit-pierre
Copy link
Member

Duplicate of #650.

@benoit-pierre benoit-pierre marked this as a duplicate of #650 Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants