summaryrefslogtreecommitdiff
path: root/test/state.c
AgeCommit message (Collapse)AuthorFilesLines
2012-10-29state, context: allow passing NULL to *_unref()Ran Benita1-0/+5
For error handling code, it's nice to be able to pass NULL to these function without worrying about segfaults ensuing. free() sets the precedent here. Also document this fact. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-22Split the mods, layout, leds parts of xkb_state_componentsRan Benita1-42/+52
Note first: This commits breaks the ABI somewhat. If an application is run against this commit without recompiling against the updated header, these break: - xkb_state_layout_*_is_active always retuns false. - xkb_state_serialize_mods always returns 0. So it might break layout switching in some applications. However, xkbcommon-compat.h provides the necessary fixes, so recompiling should work (though updating the application is even better). Split the enum to its individual components, which enables us to refer to them individually. We will use that later for reporting which components of the state have changed after update. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-11Make xkb_keymap_num_leds return the index range instead of active countRan Benita1-1/+1
Currently xkb_keymap_num_leds() returns a count of valid (settable) leds. Because the indexes might be non-consecutive, and some leds might not be settable, it is incorrect to use this function for iterating over the leds in the keymap. But this is the main use case of this function, so instead of the current behavior we adapt the function to the use case by making it return the needed range of iteration. The caller needs to handle invalid intermittent indexes, though. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-10keymap, state: don't assume led index < xkb_keymap_num_ledsRan Benita1-3/+30
xkb_keymap_num_leds() returns the number of leds that have any possibility of being set. Even if a led is defined but can not be set in any way, it is not counted. In a few places currently we assume that led indexes are smaller than this number, which is wrong both for the above reason and for the fact that the xkb format actually allows explicitly setting the indicator index, which means that the indexes might be non-consecutive. We don't really have good API to iterate on leds, now, because xkb_keymap_num_leds is pretty useless. To work around that we use sizeof(xkb_led_mask_t) * 8. This makes the "Group 2" led work (try switching to a layout other than the first in test/interactive). Signed-off-by: Ran Benita <ran234@gmail.com>
2012-10-06state: fix bad EFFECTIVE check in *_is_active()Ran Benita1-0/+9
This is a regression introduced in ed78fbcb30888cbfc6cd00. XKB_STATE_EFFECTIVE is just a OR of the other states, so using & here is completely wrong. So test/state shows for example: dumping state for LCtrl down: group English (US) (0): effective depressed latched locked mod Control (2): depressed latched locked dumping state for LCtrl + RAlt down: group English (US) (0): effective depressed latched locked mod Control (2): depressed latched locked mod Mod1 (3): depressed latched locked dumping state for RAlt down: group English (US) (0): effective depressed latched locked mod Mod1 (3): depressed latched locked dumping state for Caps Lock: group English (US) (0): effective depressed latched locked mod Lock (1): depressed latched locked led Caps Lock (0): active dumping state for Alt-Shift-+ group English (US) (0): effective depressed latched locked mod Shift (0): depressed latched locked mod Mod1 (3): depressed latched locked which is bogus. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-27Add xkb_state_key_get_one_symDaniel Stone1-0/+15
The trivial wrapper around xkb_state_key_get_syms that every user to date has implemented. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-09-24Don't use xkbcommon-compat names in internal codeRan Benita1-35/+34
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-09-02state: fix mod_names_are_activeRan Benita1-20/+25
This function was always returning -1. Adding a test, we see that test/state.c treat the is_active functions as returning booleans, which would treat -1 as success, so we test for > 0 instead (most users would probably get this wrong as well...). Also update the documentation for the are_active functions, and add a ATTR_NULL_SENTINEL for gcc __attribute__((sentinel)). Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-08Add xkb_map_mod_mask_remove_consumedDaniel Stone1-0/+31
A fairly simple helper which, given an xkb_mod_mask_t, removes all modifiers which are consumed during processing of a particular key. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-08-08test: Minimise includesDaniel Stone1-2/+0
Mostly from functions which used to use file functions directly, but now use test.h wrappers. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-12Add a library of common test functionsDaniel Stone1-11/+4
Including creating a context (will come in useful soon), opening and reading files, and compiling keymaps. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22state: Add more comprehensive repeating testDaniel Stone1-5/+3
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-22Add xkb_key_repeatsDaniel Stone1-0/+13
Does what it says on the box. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-06-09state: use darray for filtersRan Benita1-10/+16
For the darray we need to specify the explicit struct xkb_filter type instead of void*, so we move the definition of struct xkb_state into state.c thus making it opaque even from the rest of the files. It has enough getters to get going and is otherwise good style. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-11Rename 'ctx' back to 'context' in external APIDaniel Stone1-5/+5
Still keep things as 'ctx' internally so we don't have to worry about typing it too often, but rename the user-visible API back as it was kinda ugly. This partially reverts e7bb1e5f. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09Rename serialise to serializeDaniel Stone1-8/+8
Yes, British English is correct, but unfortunately we've lost that battle. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09Add common LED names to xkbcommon-names.hDaniel Stone1-2/+2
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09Merge remote-tracking branch 'krh/keysyms'Daniel Stone1-3/+2
Conflicts: src/keysym.c src/misc.c src/text.h src/xkbcomp/expr.c src/xkbcomp/parser.y src/xkbcomp/parseutils.c src/xkbcomp/symbols.c Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09Use our own keysymsKristian Høgsberg1-3/+2
2012-05-09Shorten context to ctxRan Benita1-5/+5
(This breaks the API.) "context" is really annoying to type all the time (and we're going to type it a lot more :). "ctx" is clear, concise and common in many other libraries. Use it! Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Fix for xkb -> keymap change.]
2012-05-09Change all 'xkb' xkb_keymap names to 'keymap'Daniel Stone1-19/+19
To make it a bit more clear what it actually is. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-09Add multiple modifier state matching APIDaniel Stone1-0/+19
Two new calls allow users to test the exact modifier state, including verifying that no other modifiers but the ones you wanted are down. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08Add pre-defined names databaseDaniel Stone1-13/+14
xkbcommon-names.h right now just contains a set of hardcoded modifier strings that are most commonly used for the usual modifiers. Provide definitions of these so people don't have to worry about typoing a string or mixing up Mod1 and Mod4. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08Add flags to context creationDaniel Stone1-1/+1
None defined as yet, but why not. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08Add flags to keymap compilation entrypointsDaniel Stone1-1/+1
No use as yet, but might as well ... Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-08Rename XKBcommonint.h to xkb-priv.h and use itRan Benita1-1/+1
Make the files in the src/* directory use their own header or a consilidated private header. This makes the file dependencies clearer. Also drop the pointless "xkb" file name prefix, add split a few declarations to their own files (atom.h and text.h). Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-09Overhaul test suiteRan Benita1-10/+10
Rewrite all of the current tests in the following ways: - Instead of the current mix of C and shell, just use single-process pure C file per test. All of the .sh files are removed, but everything that was tested is ported. - Instead of handling the test logs ourselves, use Automake's "parallel-test" mechanism. This will create a single log file for each test with it's stdout+stderr, and a top level "test-suite.log" file for all the failed tests. - The "parallel-tests" directive also makes the test run in parallel, so "make check" runs faster. - Also use the "color-tests" directive to have the "make check" output colorized. Who doesn't like to see PASS in green? - All of the test data files are moved into the test/data subdirectory. That way we can just put the directory in EXTRA_DIST and forget about it. - The test/Makefile.am file is consolidated into the main Makefile.am, for a completely non-recursive build. Right now the tests are completely independent and just use simple assert()'s. More sophistication can be added as needed. It should also be noted that it's still possible to use shell, python, etc. if a test wants more flexibility than C can provide, just do as before. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Updated for xkb_keymap changes.]
2012-04-09Rename xkb_desc to xkb_keymapDaniel Stone1-3/+3
struct xkb_desc was just a hangover from the old XkbDescRec, which isn't a very descriptive name. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27Use xkb_contexts in keymap compilationDaniel Stone1-2/+7
Primarily for the include path, but also for the logging in future. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27Define our own None atom valueRan Benita1-2/+0
Since we define our own xkb_atom_t type, it makes sense not to use the X11/X.h None value. This way we can also remove a lot of X11 includes. Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27Move utils.{c,h} to be used by the entire projectRan Benita1-1/+1
This is a first step for making consistent use of utils.h also outside of xkbcomp/ . Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27Add enum xkb_key_direction instead of boolDaniel Stone1-11/+11
Use XKB_KEY_UP instead of 0 and XKB_KEY_DOWN instead of 1. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Reported-by: Ran Benita <ran234@gmail.com>
2012-03-27Add state serialisation APIDaniel Stone1-22/+78
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-22Rename keymap allocation APIDaniel Stone1-2/+2
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-22Add LED state APIDaniel Stone1-11/+28
And also convert state.c to use the state API for mods and groups, rather than testing the state members directly. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-21Round out new state APIDaniel Stone1-13/+62
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-21Add new state APIDaniel Stone1-0/+104
Add new API to deal with xkb_state objects, including xkb_state_update_key, which runs the XKB action machinery internally to calculate what exactly happens to the state when a given key is pressed or released. The canonical way to deal with keys is now: struct xkb_state *state = xkb_state_new(xkb); xkb_keysym_t *syms; int num_syms; xkb_state_update_key(state, key, is_down); num_syms = xkb_key_get_syms(state, key, &syms); More state handling API, including a way to get at or ignore preserved modifiers, is on its way. Signed-off-by: Daniel Stone <daniel@fooishbar.org>