summaryrefslogtreecommitdiff
path: root/src/x11
Commit message (Collapse)AuthorAgeFilesLines
* x11: fix comparison of integer expressions of different signednessRan Benita2021-03-281-1/+1
| | | | | | | | src/x11/keymap.c:980:26: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare] 980 | for (size_t i = 0; i < length; i++) { | ^ Signed-off-by: Ran Benita <ran@unusedvar.com>
* Inline x11_atom_interner_adopt_atoms() into callersUli Schlachter2021-03-093-19/+8
| | | | Signed-off-by: Uli Schlachter <psychon@znc.in>
* Save another GetAtomName round tripUli Schlachter2021-03-093-76/+66
| | | | | | | | | | | | | | | Both get_atom_name() and the new atom interner required a round trip. Move get_atom_name() into the atom interner to save one more round trip. This brings xkb_x11_keymap_new_from_device() down to two round trips, which is the minimum possible number. (Also, I think the new code in keymap.c is more readable than the mess I previously created) With this last commit in the series, this definitely: Fixes: https://github.com/xkbcommon/libxkbcommon/pull/217 Signed-off-by: Uli Schlachter <psychon@znc.in>
* Also batch the XKB GetNames requestUli Schlachter2021-03-091-23/+24
| | | | | | This gets rid of another round trip. Signed-off-by: Uli Schlachter <psychon@znc.in>
* Also batch the XKB-GetMapMap requestUli Schlachter2021-03-091-15/+15
| | | | | | This gets rid of one more round trip. Signed-off-by: Uli Schlachter <psychon@znc.in>
* Remove three more round tripsUli Schlachter2021-03-091-18/+18
| | | | | | | | | | | | | | | There are a number of XKB requests needed to request all the information from the X11 server. So far, the code was sending one request and waiting for the reply. This commit starts batching the request so that we get multiple replies with one round trip. This removes three round trips. Only the simple requests are converted. get_map() and get_names() use some bitmasks that are needed for both the request and the reply. These will be dealt with separately. Signed-off-by: Uli Schlachter <psychon@znc.in>
* Save three more round trips in xkb_x11_keymap_new_from_device()Uli Schlachter2021-03-093-8/+39
| | | | | | | | Instead of asking for an atom name and waiting for the reply four times, this now sends four GetAtomName requests and waits for all the replies at once. Thus, this saves three round trips. Signed-off-by: Uli Schlachter <psychon@znc.in>
* xkb_x11_keymap_new_from_device: Less X11 round-tripsUli Schlachter2021-03-093-104/+157
| | | | | | | | | | | | | | | | | | On my system, calling xkb_x11_keymap_new_from_device() did 78 round trips to the X11 server, which seems excessive. This commit brings this number down to about 9 to 10 round trips. The existing functions adopt_atom() and adopt_atoms() guarantee that the atom was adopted by the time they return. Thus, each call to these functions must do a round-trip. However, none of the callers need this guarantee. This commit makes "atom adopting" asynchronous: Only some time later is the atom actually adopted. Until then, it is in some pending "limbo" state. This actually fixes a TODO in the comments. Fixes: https://github.com/xkbcommon/libxkbcommon/issues/216 Signed-off-by: Uli Schlachter <psychon@znc.in>
* x11: fix type level names missingRan Benita2020-11-231-0/+1
| | | | | | | When reading the keymap, the level names would get discarded. Regressed in 26453b84732da870f5695ee347970b337cfea9c1. Signed-off-by: Ran Benita <ran@unusedvar.com>
* x11/keymap: fix case with no actionsRan Benita2020-11-231-9/+10
| | | | | | | Possible regression in f41e609bbea8447fc82849a1a6ea0d116189f2f8 (not confirmed yet). Signed-off-by: Ran Benita <ran@unusedvar.com>
* x11: cache X11 atomsRan Benita2020-11-201-5/+50
| | | | | | | | | | | | | | | | | | | | On every keymap notify event, the keymap should be refreshed, which fetches the required X11 atoms. A big keymap might have a few hundred of atoms. A profile by a user has shown this *might* be slow when some intensive amount of keymap activity is occurring. It might also be slow on a remote X server. While I'm not really sure this is the actual bottleneck, caching the atoms is easy enough and only needs a couple kb of memory, so do that. On the added bench-x11: Before: retrieved 2500 keymaps from X in 11.233237s After : retrieved 2500 keymaps from X in 1.592339s Signed-off-by: Ran Benita <ran@unusedvar.com>
* x11: eliminate slow divisionsRan Benita2020-11-201-22/+23
| | | | Signed-off-by: Ran Benita <ran@unusedvar.com>
* build: include config.h manuallyRan Benita2019-12-273-0/+6
| | | | | | | | | Previously we included it with an `-include` compiler directive. But that's not portable. And it's better to be explicit anyway. Every .c file should have `include "config.h"` first thing. Signed-off-by: Ran Benita <ran@unusedvar.com>
* utils: use MIN/MAX instead of min/maxRan Benita2019-12-271-1/+1
| | | | | | min/max symbols conflict on some systems (msvc), so just use the macros. Signed-off-by: Ran Benita <ran@unusedvar.com>
* x11: fix undefined behavior when copying the coordinates of ptr movements ↵Ran Benita2018-08-181-2/+2
| | | | | | | | | | actions Left shift of a negative integer. For some reason the protocol representation here got really botched (in the spec it is just a nice and simple INT16). Signed-off-by: Ran Benita <ran234@gmail.com>
* Convert http:// -> https:// where possibleRan Benita2017-12-211-1/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: check and document the correct range of device IDsRan Benita2017-12-181-1/+1
| | | | | | | | | The actual value is 127, not 255. https://bugs.freedesktop.org/show_bug.cgi?id=104321 Reported-by: Gatis Paeglis <gatis.paeglis@qt.io> Signed-off-by: Ran Benita <ran234@gmail.com>
* x11/keymap,test/interactive-evdev: fix a couple of clang-analyzer warningsRan Benita2017-07-311-0/+1
| | | | | | | From my analysis these values cannot be null, but the analyzer cannot see this. So assert it. Signed-off-by: Ran Benita <ran234@gmail.com>
* x11/keymap: handle private actionsRan Benita2014-08-091-0/+14
| | | | | | Previously we treated them as NoAction(). Signed-off-by: Ran Benita <ran234@gmail.com>
* x11/keymap: be more defensive about the number of modifiersRan Benita2014-08-081-2/+4
| | | | | | | | | There can be at most 16 vmods, and we rely on the facts that #vmods + NUM_REAL_MODS (8) <= XKB_MAX_MODS (32) when accessing keymap->mods.mods. But msb_pos() can potentially return up to #vmods = 32 if the server is malicious, so we need to truncate it. Signed-off-by: Ran Benita <ran234@gmail.com>
* x11/keymap: don't forget to add the vmod offset in get_vmodsRan Benita2014-08-081-2/+3
| | | | | | | | | | | | The first 8 modifiers in keymap->mods are the real modifiers; the virtual modifiers are then at slots 8-24. But XkbGetMap's virtualMods mask starts the virtual modifiers at zero, so we need to add an offset (like we do correctly in get_vmod_names()). https://github.com/xkbcommon/libxkbcommon/issues/9 Reported-by: @rtcm Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: don't iterate on empty batchesRan Benita2014-06-151-1/+2
| | | | | | | If count % SIZE == 0 we did a useless iteration where start==stop. It's harmless but strange, so don't do that. Signed-off-by: Ran Benita <ran234@gmail.com>
* Remove unnecessary !!(expressions)Ran Benita2014-06-011-3/+3
| | | | | | _Bool already does that. Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: fix out-of-bounds access in adopt_atoms() error handlingRan Benita2014-05-141-2/+3
| | | | | | | | | | | | | | | | | | Two problems: - `j` can be >= `SIZE`, and needs to be wrapped like in the rest of the code. - `cookies[j % SIZE]` is not initialized if there's no atom in `from[j]`. The is manifested when: - We've already gone through one batch (>= 128 atoms) (in fact this cannot happen in call to `adopt_atoms` in the current code). - An XCB request failed in the middle of a batch. Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap, keycodes, compat: don't use darray for LEDsRan Benita2014-04-221-4/+4
| | | | | | Use a static array of size XKB_MAX_LEDS instead, as in xkb_mod_set. Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap: don't use darray in xkb_mod_setRan Benita2014-04-221-10/+5
| | | | | | | | Instead just statically allocate the mods array (of size MAX_MOD_SIZE = 32). The limit is not going anywhere, and static allocations are nicer (nicer code, no OOM, etc.). It's also small and dense enough. Signed-off-by: Ran Benita <ran234@gmail.com>
* Add struct xkb_mod_setRan Benita2014-04-191-4/+7
| | | | | | | | | | | The only thing that the compilation phase needs the keymap for currently is for access to the modifier information (it also modifies it in place!). We want to only pass along the neccessary information, to make it more tractable and testable, so instead of passing the entire keymap we add a new 'mod_set' object and pass a (const) reference to that. The new object is just the old array of 'struct xkb_mod'. Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: relax XkbGetNames requirementsRan Benita2014-03-061-4/+8
| | | | | | | | | | | | | | | It is valid for a keymap to not have key aliases, group names and various other things. But the current test requires all of them to be present in the reply, which causes us the fail on such keymaps (as the XQuartz one). Instead, require only what we really need. The virtual-mods names may not be strictly required, but it seems safer to leave it in for now. https://bugs.freedesktop.org/show_bug.cgi?id=75798 Reported-by: Gatis Paeglis <gatis.paeglis@digia.com> Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap: change action flag NO_ACCEL -> ACCELRan Benita2014-02-161-2/+2
| | | | | | It's easier to deal with, but we need to set it as "factory default". Signed-off-by: Ran Benita <ran234@gmail.com>
* action: fix SwitchScreen "same" field handlingRan Benita2014-02-161-1/+1
| | | | | | | This used to *unset* a flag called "SwitchApplication"; we changed the flag to "same" but forgot to switch the cases. Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: don't trust keycode before testing its rangeRan Benita2014-02-091-3/+7
| | | | | | The assert is not very useful access the key just before. Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: add 0 < ctrls->numGroups <= 4 assertionRan Benita2014-02-091-0/+1
| | | | | | | This only happens if something is wrong in the server; a valid keymap cannot be had in any case. Signed-off-by: Ran Benita <ran234@gmail.com>
* api: deprecate XKB_MAP_COMPILE_PLACEHOLDER, and use KEYMAP instead of MAPRan Benita2014-02-081-1/+1
| | | | | | | | | | | | | | The PLACEHOLDER was not meant to be used, but c++ doesn't like passing 0 to enums, so it was used. For this reason we add all the NO_FLAGS items, so the PLACEHOLDER shouldn't be used anymore. Second, XKB_MAP is the prefix we used ages ago, KEYMAP is the expected prefix here. So deprecate that as well. The old names may still be used through the xkbcommon-compat.h header, which is included by default (no need to include directly). Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: make sure not to use compat headerRan Benita2014-02-081-1/+1
| | | | | | | src/keymap.h already defines the necessary header guard, so just reverse the include order. Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: make some #defines unsignedRan Benita2014-02-081-9/+9
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: fix truncation of xkb controls mask off the wireRan Benita2014-02-081-1/+1
| | | | | | | It's uint32_t, not uint16_t, so we were losing flags (not that it matters in this case). Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: make msb_pos return unsignedRan Benita2014-02-081-1/+1
| | | | | | | It was initially returning -1 for all-zero arguments, but now it returns 0. Signed-off-by: Ran Benita <ran234@gmail.com>
* Use (1u << idx) instead of (1 << idx) where appropriateRan Benita2014-02-081-2/+2
| | | | | | | | It doesn't matter (I think), since the implicit conversion doesn't have any effect (e.g. sign-extension). But it's better to be aware of the type. Signed-off-by: Ran Benita <ran234@gmail.com>
* Fix sign-compare warningsRan Benita2014-02-081-6/+6
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: add #actions == #syms checkRan Benita2014-02-071-0/+3
| | | | | | | This must always hold (but if there are no actions, #actions==0), and explicitly ensures there won't be a division-by-zero a bit below. Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: add explicit cast in mods conversionRan Benita2014-02-071-1/+4
| | | | | | Explicit is better and all. Signed-off-by: Ran Benita <ran234@gmail.com>
* x11: add XKB protocol keymap and state creation supportRan Benita2014-02-024-0/+1486
These are function to create an xkb_keymap directly from XKB requests to the X server. This opens up the possibility for X clients to use xcb + xcb-xkb + xkbcommon as a proper replacement for Xlib + xkbfile for keyboard support. The X11 support must be enabled with --enable-x11 for now. The functions are in xkbcommon/xkbcommon-x11.h. It depends on a recent libxcb with xkb enabled. The functions are in a new libxkbcommon-x11.so, with a new pkg-config file, etc. so that the packages may be split, and libxkbcommon.so itself remains dependency-free. Why not just use the RMLVO that the server puts in the _XKB_RULES_NAMES property? This does not account for custom keymaps, on-the-fly keymap modifications, remote clients, etc., so is not a proper solution in practice. Also, some servers don't even set it. Now, the client just needs to recreate the keymap in response to a change in the server's keymap (as Xlib clients do with XRefreshKeyboardMapping() and friends). Signed-off-by: Ran Benita <ran234@gmail.com>