Bug 78661

Summary: repeat setting is lost once "action" is defined in symbols
Product: xkeyboard-config Reporter: Hanno Zulla <kontakt>
Component: GeneralAssignee: xkb
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Hanno Zulla 2014-05-13 12:53:23 UTC
Hi,

how do you map PgDn to Alt+Down and PgUp to Alt+Up?


I'm trying to replicate the behaviour of the ChromeOS keyboard in normal Linux.

Chromebooks come with a limited set of keys for ease of use and then make missing keys available through modifiers, e.g.:

Up = <UP>
Prior = Alt+<UP>
Home = Ctrl+Alt+<UP>
(see https://support.google.com/chromebook/answer/1047364?hl=en)



To do this, I've tried two approaches.

In symbols/inet, added:

  // Chromebook keyboards
  partial alphanumeric_keys
  xkb_symbols "chromebook" {
    //bla bla, other keys
    
    // first approach:
    key <UP> {
      type="CTRL+ALT_ACTUALLY",
      repeat= yes,
      symbols[Group1] = [ Up, Up, Prior, Home ],
      actions[Group1] = [ NoAction(), NoAction(), RedirectKey(key=<PGUP>, clearmods=Alt), RedirectKey(key=<HOME>, clearmods=Control+Alt) ]
    };
    
    // second approach:
    key <DOWN> {
      type="CTRL+ALT_ACTUALLY",
      symbols[Group1] = [ Down, Down, Next, End ]
    };
  };

In types/pc, added:

  type "CTRL+ALT_ACTUALLY" {
    modifiers = Control+Alt;
    map[None] = Level1;
    map[Control] = Level2;
    map[Alt] = Level3;
    map[Control+Alt] = Level4;
    level_name[Level1] = "Base";
    level_name[Level2] = "Ctrl";
    level_name[Level3] = "Alt";
    level_name[Level4] = "Ctrl+Alt";
  };


Result is this:

For the <DOWN> key, autorepeat works, but the symbols don't work. xev reports the right symbols, but they are not used within the applications.

For the <UP> key, the remapped keys work as expected, but they do not autorepeat when holding the key.


The relevant part of "xkbcomp :0 -xkb -" is this:

    key   <UP> {
        type= "CTRL+ALT_ACTUALLY",
        repeat= No,
        symbols[Group1]= [ Up, Up, Prior, Home ],
        actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<PGUP>,clearMods= Alt), RedirectKey(key=<HOME>,clearMods= Control+Alt) ]
    };

    key <DOWN> {
        type= "CTRL+ALT_ACTUALLY",
        symbols[Group1]= [ Down, Down, Next, End ]
    };
  

So despite "repeat= Yes" in symbols/inet, xkbcomp will return "repeat= No".

If I just remove the "repeat= Yes" line, xkbcomp will return this:

    key   <UP> {
        type= "CTRL+ALT_ACTUALLY",
        symbols[Group1]= [ Up, Up, Prior, Home ],
        actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<PGUP>,clearMods= Alt), RedirectKey(key=<HOME>,clearMods= Control+Alt) ]
    };

...but it still won't work and autorepeat still doesn't kick in.
Comment 1 Ran Benita 2014-05-13 13:40:45 UTC
The explicit repeat should not disappear, so if it happens it's a bug that should be fixed.

That said, the second approach (setting the keysyms directly without redirecting the key) seems like the correct one to take, and *should* work reliably; in what sort of applications does it not work for you?
Comment 2 Andreas Wettstein 2014-05-13 18:06:49 UTC
It seems to be a more general issue, see bug #9796.

> That said, the second approach (setting the keysyms directly without redirecting the key) seems like the correct one to take, and *should* work reliably; in what sort of applications does it not work for you?

I tried and saw failures with emacs (Xaw widgets), OpenOffice 3.2, TotalView, and urxvt.  xterm did work.  I cannot imagine how any non-XKB aware applications should work with Control and Alt as level selectors, so CLX based applications, XCB based applications (at least until recently), and applications running over an untrusted connection will likely not work with the second approach.

From de(neo), which is simpler in the sense that it does not abuse modifiers applications might want to interpret for level selection, also problems with Java applications are reported.  From my experience, cursor control and editing keysyms on a higher level only can be reliably implemented with Redirect.

Back to the original problem, the problem is not in xkeyboard-config, but I have no idea where the problem exactly is.  xkbcomp or the server?
Comment 3 Ran Benita 2014-05-13 20:45:22 UTC
Right, I guess the higher groups will not trickle to the core state (but really if you want reasonable input, don't use core input, XKB is 20yo already..)

> Back to the original problem, the problem is not in xkeyboard-config, but I
> have no idea where the problem exactly is.  xkbcomp or the server?

Seems like bug #9796 would be the better place to handle the disappearing repeats. I'll a comment there.
Comment 4 Hanno Zulla 2014-05-14 16:12:09 UTC
Hi Ran, hi Andreas,

thanks for your responses.

> in what sort of applications does it not work for you?

I'm testing this in Firefox and LibreOffice a fairly normal Xubuntu 14.04 with a few minor Chromebook-related driver patches. However, Firefox, LibreOffice and X.org etc. are the standard binaries that come with the distibution.

> the problem is not in xkeyboard-config,
> but I have no idea where the problem exactly is.  xkbcomp or the server?

Don't know (and didn't debug further). I reported the same issue to X.org about two weeks ago at https://bugs.freedesktop.org/show_bug.cgi?id=78180 but didn't get any response so far (however, this bug report is a bit more straightforward than 78180 over there, where my findings were still a bit more work-in-progress).

> but really if you want reasonable input,
> don't use core input, XKB is 20yo already..

So what should I use instead of XKB? My plan was to replicate the behaviour of the ChromeOS keyboard.

It's actually a really nice reduction of the old-style PC keyboard, they removed many of the weirder keys like PrintScreen or ScrollLock, and the removal of CapsLock has been long overdue. I would love to buy a non-ChromeOS laptop with that keyboard layout...

ChromeOS is based on Linux and originally, they used XKB for remapping their keys as well.

https://codereview.chromium.org/3365005/show

However, they later removed it from there and moved the remapping into user space instead.

https://codereview.chromium.org/10537175/show

Someone else stumbled over the same problem as I describe here and asked about it:

http://unix.stackexchange.com/questions/41724/how-to-make-custom-key-type-auto-repeat-in-xkb

...and his question on stackexchange got a reply that points to a patch from ChromeOS at

http://git.chromium.org/gitweb/?p=chromiumos/overlays/chromiumos-overlay.git;a=blob;f=x11-base/xorg-server/files/1.7.6-fix-xkb-autorepeat.patch;h=8bad5abc5ad3958f6d73c55c67d3883ac775db18;hb=c3ce41719abc82a257e1fef1c499ea2e7c6b3c32

I tried to build a modified X.org with that patch and that didn't help, but it is possible that I didn't use the patch right.

So now I'm not quite sure where to look and if it's a bug in my symbols/inet or a bug in XKB or the server or...
Comment 5 Andreas Wettstein 2014-05-14 18:58:38 UTC
> So what should I use instead of XKB? My plan was to replicate the behaviour of > the ChromeOS keyboard.

I believe Ran wanted to say that applications should really support XKB today.  Not all do, and this is one but not the only reason that you are right to use Redirect and, of course, XKB in general.

Please try to use 'xset r keycode' to enable repeat for the key with keycode.  For Linux, for the UP key, keycode is 111, as far as I see.  You can find out with xev.  I hope that gets you going, for now.

Ran is probably right and bug #9796 is the better place to track the issue.  If you agree, you might close this bug and add your findings to bug #9796.
Comment 6 Ran Benita 2014-05-14 22:03:33 UTC
Just a small note: there's an issue with "second approach" beyond XKB vs. Core, which should explain why it doesn't work for the modern applications you mention (Firefox and LibreOffice, both of which use GTK which uses XKB).

The correct keysym is generated (e.g. Home), but the application does not respect the "consumed modifiers" which XKB tells it to mask out. "Consumed modifiers" are modifiers which are used up in the key translation process (that is, appear in the Level which was used in the key type). So in effect you get e.g. "Ctrl+Alt+Home" which does not do what you want.

So indeed the RedirectKey approach with clearmods is the better one here (modulo bug #9796). Hopefully Andreas' "xset r" suggestion works until that bug is fixed.
Comment 7 Hanno Zulla 2014-05-16 10:14:53 UTC
I tried the patch that people discussed about back in 2007 in bug #9796, but that didn't help. Please see there.
Comment 8 GitLab Migration User 2018-12-28 00:34:13 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/issues/22.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.