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

Invalid variant ignored #16

Closed
teg opened this issue Nov 24, 2014 · 2 comments
Closed

Invalid variant ignored #16

teg opened this issue Nov 24, 2014 · 2 comments

Comments

@teg
Copy link

teg commented Nov 24, 2014

Using libkxbcommon (with the systemd-evcat test tool) I observe:

xkbcommon: DEBUG: Compiling from RMLVO: rules 'evdev', model 'pc105', layout 'us,us', variant 'dvorak-intl', options 'grp:caps_toggle'
xkbcommon: DEBUG: Compiling from KcCGST: keycodes 'evdev+aliases(qwerty)', types 'complete', compat 'complete', symbols 'pc+us+us:2+inet(evdev)+capslock(grouplock)'

(notice the missing trailing comma in the variant). The effect is that I get two plain us keymaps. I would have expected either an error message/failing compilation or for the compiler to somehow make sense of the missing comma (as X does AFAIU).

With the trailing comma:

xkbcommon: DEBUG: Compiling from RMLVO: rules 'evdev', model 'pc105', layout 'us,us', variant 'dvorak-intl,', options 'grp:caps_toggle'
xkbcommon: DEBUG: Compiling from KcCGST: keycodes 'evdev+aliases(qwerty)', types 'complete', compat 'complete', symbols 'pc+us(dvorak-intl)+us:2+inet(evdev)+capslock(grouplock)'

@bluetech
Copy link
Member

This is the intended behavior; it is assumed to work this way by the "rules" file, so we can't change it really. From my tests X does the same, can you tell me how you tested it?

Coincidentally, since libxkbcommon 0.5.0 we now do print a warning when there is a user-provided RMLVO value which is not matched anywhere in the rules file (see d8a4f52). It turns out to not be very effective though because most settings are matched by wildcards whether they are valid or not (in the current rules file in xkeyboard-config at least). But it works well for misspelled "option" values, and it also warns in this case:

ran@ran:~/src/libxkbcommon$ ./test/rmlvo-to-kccgst -l us,us -v dvorak-intl
xkbcommon: ERROR: Unrecognized RMLVO variant "dvorak-intl" was ignored
keycodes: evdev+aliases(qwerty)
types:    complete
compat:   complete
symbols:  pc+us+us:2+inet(evdev)

Here are some technical details if you're interested:

I wrote a document a while ago describing what the rules file: https://raw.githubusercontent.com/xkbcommon/libxkbcommon/master/doc/rules-format.txt It is not "official", but I tried to follow the parser in libxkbfile exactly (used by setxkbmap and friends, and copied verbatim in the X server). In the Notes section I mention:

- If a Rule is matched, %-expansion is performed on the KccgstValue,
  as follows:

  %m, %l, %v:
     The model, layout or variant, if only one was given (e.g.
     %l for "us,il" is invalid).

  %l[1], %v[1]:
     Layout or variant for the specified group Index, if more than
     one was given (e.g. %l[1] for "us" is invalid).

And X has the same behavior:
http://cgit.freedesktop.org/xorg/lib/libxkbfile/tree/src/maprules.c?id=9fa04388dcbb5bf205319569f540a62c03754688#n545
It puts the "us,us" into indexes 1,2 of the layouts array, but puts "dvorak-intl" into index 0 of the variants array.

Since all the rules which match on both layout and variant look something like this:

! model       layout       variant       =      symbols

Or this:

! model       layout[4]      variant[4]     =      symbols

this doesn't match, it only matches these rules:

! model       layout[1]                    =      symbols
[...]
  *           *                    =      pc+%l[1]%(v[1])

And since v[1] doesn't exist, it is dropped, hence the variant is ignored.

@teg
Copy link
Author

teg commented Nov 29, 2014

Thanks for the detailed explanation. I can confirm that an error is printed with 0.5.0, I thought I was testing with 0.5.0 all along, but as it turns out I was using the previous release (a package update had failed without me noticing):

$ ./systemd-evcat
You run in unmanaged mode without being root. This is likely to produce no output..
evcat - Read and catenate events from selected input devices
Running on seat 'seat0' in user-session '1'
Exit by pressing ^C or 'q'
xkbcommon: ERROR: Unrecognized RMLVO variant "dvorak-intl" was ignored

As to how X appears to have been working all this time with the wrong variant, I'm not sure. I assume something (Gnome?) may have been setting the correct layout for me and hence masking the error.

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

No branches or pull requests

2 participants