Before it was a static array of size XKB_NUM_GROUPS.
The previous cleanups made this transition a bit easier. This is a
first step for removing the XKB_NUM_GROUPS hardcoded limit; but for now
we still check that the groups are < XKB_NUM_GROUPS (e.g. in
ResolveGroup and GetGroupIndex) until the keymap, etc. is worked out as
well.
This also makes us alloc quite a bit less (this is just rulescomp):
Before:
==51999== total heap usage: 291,474 allocs, 291,474 frees, 21,458,334 bytes allocated
After:
==31394== total heap usage: 293,595 allocs, 293,595 frees, 18,150,110 bytes allocated
This is because most rmlvo's don't use the full 4 layouts that KeyInfo
had always alloced statically before.
Signed-off-by: Ran Benita <ran234@gmail.com>
These values weren't wrapped before, which caused group_index_is_active
to stop working after a few group switches.
Also, the current group-wrapping function didn't take into consideration
actions such as LockGroup=-1, which need to wrap around, etc.
xkb_layout_index_t is unsigned, but it was used to hold possibly
negative values (e.g. locked_group is 0 and gets a -1 action).
This group wrapping function should now act like the XkbAdjustGroup
function from xserver, and at least ./test/interactive doesn't bring up
any problems with group switching any more.
Signed-off-by: Ran Benita <ran234@gmail.com>
Currently, xkb_state_layout_{index,name}_is_active may report multiple
groups as effective, because at looks at base,latched,locked separately.
But there can only be one effective group, which is computed from the
other three. So if XKB_STATE_EFFECTIVE is requested, just compare to the
effective group we have computed.
We also modify mod_{index,name}_is_active similarly, just for symmetry
(there the effective mask is just an OR of the other three so the
current test is correct).
Signed-off-by: Ran Benita <ran234@gmail.com>
What this code does is, in case someone compile a keymap like -layout
'us,us,us' then only one group would be created. If there is anything
which differentiates between any of the groups (e.g. a variant, another
layout), then this is not done.
This is pretty obscure, only saves a few kbytes in the final keymap, and
if the user asked for it, why not let her?
Signed-off-by: Ran Benita <ran234@gmail.com>
This old rules parser gives the same kccgst here, so in the interest of
staying compatible we shouldn't fix it there. Similarly we shouldn't
touch ParseIncludeMap, so this is the best place to handle this.
Signed-off-by: Ran Benita <ran234@gmail.com>
Rename the functions to get keysyms by key/layout/level to fit with the
recent public API renames, and expose them.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Move xkb_map_* functions to xkb_keymap_*, xkb_key_* functions under
either xkb_keymap or xkb_state, and rename groups to layout in all
user-visible API.
Backwards-compatible hooks are provided, such that old source will
build, but silently mangled to the new names, and old binaries will
also continue to work.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This just prints the compiled keymap string for to the given command
line arguments. This often useful when developing.
Signed-off-by: Ran Benita <ran234@gmail.com>
xkblib spec says:
XkbSA_LockNoLock If set, and the action type is XkbSA_LockMods,
the server only unlocks the action modifiers.
XkbSA_LockNoUnlock If set, and the action is XkbSA_LockMods,
the server only locks the action modifiers.
Signed-off-by: Ran Benita <ran234@gmail.com>
The xkblib spec says:
If XkbSA_UseModMapMods is not set in the flags field, the mask,
real_mods, vmods1, and vmods2 fields are used to determine the
action modifiers. Otherwise they are ignored and the modifiers
bound to the key (client map->modmap[keycode]) are used instead.
So we should just assign the modmap without considering what's there.
Signed-off-by: Ran Benita <ran234@gmail.com>
This change adds range checks based on the lowest keysym and highest keysym in
the table. This allows a quick check to be applied to identify if the keysym
is inside the table.
To really give value to this optimisation the table is split to have a
separate table for the keypad keysyms.
The test suite passes with this change.
Signed-off-by: Rob Bradford <rob@linux.intel.com>
Trying ''./test/interactive -l us:5' causes us to crash.
The <layout>:<N> syntax says to put this layout at the N'th level.
However the code (inherited from xkbcomp) doesn't check that the group
is valid, and then happily indexes keyi->groups with it, which has a
static size of XKB_NUM_GROUPS (the SetExplicitGroup function assumes the
index is valid). So any value a user might put there > 4 makes nice
things happen.
Signed-off-by: Ran Benita <ran234@gmail.com>
e.g. hhhhhHHHHHHHhhhhhh with shift down and up in the middle.
Unfortunately trying a quick test with test/interactive is not possible
because the evdev soft-repeat stops the repeat when another key is
pressed. So you need real soft-repeat for that.
Signed-off-by: Ran Benita <ran234@gmail.com>
- Add context.h and move context-related functions from xkb-priv.h to
it.
- Move xkb_context definition back to context.c.
- Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it.
- Rename xkb-priv.h to map.h since it only contains keymap-related
definitions and declarations now.
- Remove unnecessary includes and some and some other small cleanups.
Signed-off-by: Ran Benita <ran234@gmail.com>
These statements are pretty pointless for us; we don't restrict keycodes
like X does, and if someone writes e.g. maximum = 255 but only has 100
keys, we currently happily alloc all those empty keys. xkbcomp already
handles the case when these statements aren't given, and uses a computed
min/max instead. We should just always use that.
(Of course since keycodes/evdev currently uses almost all of the
keycodes in the range it declares, including 255, this doesn't save any
memory for the common user right now).
Signed-off-by: Ran Benita <ran234@gmail.com>
This removes all of the boilerplate from the *_new functions, and leaves
them just as simple functions which perform the effect of the action on state.
Signed-off-by: Ran Benita <ran234@gmail.com>
Pass the new filter as a parameter instead of getting a new one in each
action function, and introducing a failure condition there.
Signed-off-by: Ran Benita <ran234@gmail.com>
The policy is now consistent: every API functions which recieves a
keycode should resolve it to an xkb_key first thing, and all the
internal functions use that instead of the keycode.
To facilitate it a bit, we move the KeycodeInRange check to XkbKey
itself, which returns NULL if the keycode is illegal.
Signed-off-by: Ran Benita <ran234@gmail.com>
- The Clear* functions should just free the memory associated with the
object. If the object is used again, it is Init'd again.
- s/Free/Clear if the actual pointer is not free'd.
- Zeroise object in Init and only initialize non-zero fields.
Signed-off-by: Ran Benita <ran234@gmail.com>
This layout stretches us pretty well, so it's good for testing nothing
breaks. There are a couple of things that need looking into, though
(particularly the level5 issue).
Signed-off-by: Ran Benita <ran234@gmail.com>