libxkbcommon/test
Ran Benita 5417440970 state: fix consumed modifier calculation
The current calculation is in short:
    entry ? (entry->mask & ~entry->preserve) : 0

This changes it be
    type->mask & ~(entry ? entry->preserve : 0)

This is what Xlib does. While less intuitive, it is actually more
correct, if you follow this deduction:

- The key group's type->mask defines which modifiers the key even cares
  about. The others are completely irrelevant (and in fact they are
  masked out from all sided in the level calculation). Example: NumLock
  for an alphabetic key.

- The type->mask, the mods which are not masked out, are *all* relevant
  (and in fact in the level calculation they must match *exactly* to the
  state). These mods affect which level is chosen for the key, whether
  they are active or not.

- Because the type->mask mods are all relevant, they must be considered
  as consumed by the calculation *even if they are not active*.

Therefore we use type->mask instead of entry->mask.

The second change is what happens when no entry is found: return 0 or
just take preserve to be 0? Let's consider an example, the basic type

    type "ALPHABETIC" {
        modifiers = Shift+Lock;
        map[Shift] = Level2;
        map[Lock] = Level2;
        level_name[Level1] = "Base";
        level_name[Level2] = "Caps";
    };

Suppose Shift+Lock is active - it doesn't match any entry, thus it gets
to level 0. The first interpretation would take them both to be
unconsumed, the second (new one) would take them both to be consumed.
This seems much better: Caps is active, and Shift disables it, they both
do something.

This change also fixes a pretty lousy bug (since 0.3.2), where Shift
appears to apparently *not* disable Caps. What actually happens is that
Caps is not consumed (see above) but active, thus the implicit
capitalization in get_one_sym() kicks in and capitalizes it anyway.

Reported-by: Davinder Pal Singh Bhamra
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-03-27 19:38:30 +02:00
..
data keymap-dump: don't print "affect=lock" in PtrLock 2014-02-15 23:31:54 +02:00
.gitignore Add utf8.{c,h} for common UTF-8 util functions 2014-03-22 02:10:28 +02:00
atom.c Fix sign-compare warnings 2014-02-08 00:54:53 +02:00
bench-key-proc.c test: Add flags argument to test_get_context() 2013-03-19 10:28:23 +00:00
buffercomp.c keymap: add xkb_keymap_new_from_buffer() 2013-04-01 18:04:06 +01:00
common.c state: fix consumed modifier calculation 2014-03-27 19:38:30 +02:00
context.c atom: really work with non-NUL-terminated strings 2013-07-22 11:02:20 +03:00
filecomp.c scanner: allow empty key name literals 2013-08-02 11:40:27 +03:00
interactive-evdev.c test: rename test/interactive to interactive-evdev 2014-01-13 17:21:56 +02:00
interactive-x11.c interactive-x11: beef up select_events a bit 2014-02-28 15:30:49 +02:00
keyseq.c test/keyseq: add de(neo) Level{6,7,8} tests 2013-07-25 13:21:33 +03:00
keysym.c keysym: add xkb_keysym_to_{lower,upper} 2013-08-15 09:58:50 +03:00
log.c test: Use test_get_context() in log.c 2013-03-19 10:34:28 +00:00
print-compiled-keymap.c test: Add flags argument to test_get_context() 2013-03-19 10:28:23 +00:00
rmlvo-to-kccgst.c test/rmlvo-to-kccgst: use default RMLVO values in translation 2014-02-10 13:15:58 +02:00
rules-file.c test: Add flags argument to test_get_context() 2013-03-19 10:28:23 +00:00
rulescomp.c rulescomp: increase BENCHMARK_ITERATIONS from 1000 to 2500 2013-10-10 22:02:30 +03:00
state.c state: fix consumed modifier calculation 2014-03-27 19:38:30 +02:00
stringcomp.c xkbcomp: escape the section names before storing them in the keymap 2013-07-18 14:50:21 +03:00
test.h x11: add a couple of tests 2014-02-02 11:16:40 +02:00
utf8.c Add utf8.{c,h} for common UTF-8 util functions 2014-03-22 02:10:28 +02:00
x11.c api: deprecate XKB_MAP_COMPILE_PLACEHOLDER, and use KEYMAP instead of MAP 2014-02-08 16:40:20 +02:00