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

Setting Scroll_Lock to 'On' messes up input #102

Closed
ghost opened this issue Jan 26, 2022 · 8 comments
Closed

Setting Scroll_Lock to 'On' messes up input #102

ghost opened this issue Jan 26, 2022 · 8 comments

Comments

@ghost
Copy link

ghost commented Jan 26, 2022

How to reproduce:

  1. Enable Scroll_Lock. Apparently, Scroll_Lock key isn't enabled by default on Linux (that seems to be a separate Xorg bug, see here: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/issues/194). In order to enable toggling Scroll_Lock one needs to run xmodmap -e "add mod3 = Scroll_Lock".
  2. Turn Scroll Lock on.

Result: You cannot use ibus-table properly anymore. Space now doesn't only confirm input but also types an actual space. Choosing a variant with numbers doesn't work either.

Tested on Ubuntu and Manjaro, Xorg version, GNOME 41. Linux kernel v. 5.15. Tested with ibus-table-cangjie5.

@mike-fabian mike-fabian self-assigned this Jan 27, 2022
@mike-fabian mike-fabian added this to To do in Mike’s github project board via automation Jan 27, 2022
@mike-fabian mike-fabian moved this from To do to In progress in Mike’s github project board Jan 27, 2022
@mike-fabian
Copy link
Owner

Which modifier keys are considered when matching key bindings is specified here:

https://github.com/mike-fabian/ibus-table/blob/master/engine/it_util.py#L55

So currently Caps Lock and Num Lock are ignored when matching key events.

(For example it should not matter whether Caps Lock or Num Lock are on or not when typing “4” this should select candidate number 4 no matter whether Caps Lock or Num Lock are on or not.)

Surely Scroll Lock should be added to that list.

So I think this fixes the problem:

mfabian@taka:/local/mfabian/src/ibus-table (release-candidate-1.16.5 *$%)
$ git diff |cat 
diff --git a/engine/it_util.py b/engine/it_util.py
index 3afcaf3..382e035 100644
--- a/engine/it_util.py
+++ b/engine/it_util.py
@@ -59,6 +59,7 @@ KEYBINDING_STATE_MASK = (
     IBus.ModifierType.MODIFIER_MASK
     & ~IBus.ModifierType.LOCK_MASK # Caps Lock
     & ~IBus.ModifierType.MOD2_MASK # Num Lock
+    & ~IBus.ModifierType.MOD3_MASK # Scroll Lock
 )
 
 def variant_to_value(variant: GLib.Variant) -> Any:
mfabian@taka:/local/mfabian/src/ibus-table (release-candidate-1.16.5 *$%)
$ 

I already tested that this fixes it for me.

Now I only wonder whether I can be sure that MOD3 is always Scroll Lock and never something else ...

https://github.com/mike-fabian/ibus-table/blob/master/engine/it_util.py#L335

has stuff like

# mod1: Usually Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
self.mod1 = self.state & IBus.ModifierType.MOD1_MASK != 0
# mod2: Usually Num_Lock (0x4d)
self.mod2 = self.state & IBus.ModifierType.MOD2_MASK != 0
self.mod3 = self.state & IBus.ModifierType.MOD3_MASK != 0
# mod4: Usually Super_L (0xce),  Hyper_L (0xcf)
self.mod4 = self.state & IBus.ModifierType.MOD4_MASK != 0

The “Usually” worries me a bit, I hope this is never different ...

@ghost
Copy link
Author

ghost commented Jan 27, 2022

How about the Space doubling problem? Does this change fixes that as well?

@ghost
Copy link
Author

ghost commented Jan 27, 2022

The “Usually” worries me a bit, I hope this is never different ...

From the conversation here: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/issues/194 it seems to me that Mod3 should in fact be Scroll_Lock. I just don't know why it isn't enabled by default. By default Mod3 is just empty. But every tutorial online that I could find that teaches how to enable Scroll_Lock on Linux says to use xmodmap -e "add mod3 = Scroll_Lock", so I think Mod3 is either empty or Scroll_Lock for everyone.

@ghost
Copy link
Author

ghost commented Jan 27, 2022

It seems that Xorg people realize this problem (bug) exists and maybe in the future they will find time to make sure Scroll_Lock is set to Mod3 by default. At least that's what I understood from that freedesktop.org issue.

@ghost
Copy link
Author

ghost commented Jan 27, 2022

That issue was originally created five years ago... So I doubt it will be fixed any time soon. But at least I think we can be sure that Mod3 isn't supposed to be used for anything other than Scroll_Lock.

@mike-fabian
Copy link
Owner

How about the Space doubling problem? Does this change fixes that as well?

Yes.

@mike-fabian
Copy link
Owner

New ibus-table-1.16.6 builds for Fedora with the scroll lock fix are here:

https://copr.fedorainfracloud.org/coprs/mfabian/ibus-table/builds/

@ghost
Copy link
Author

ghost commented Jan 27, 2022

Awesome! I'm glad it turned out to be quite an easy fix. I thought it would be something dreadfully complex. (Or maybe you're just a genius programmer, who knows :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant