summaryrefslogtreecommitdiff
path: root/src/xkbcomp/ast.h
diff options
context:
space:
mode:
authorWismill <dev@wismill.eu>2023-05-01 22:30:41 +0200
committerGitHub <noreply@github.com>2023-05-01 23:30:41 +0300
commit5b5b67f28ccfe1fe69ec5569c90f1752de323a08 (patch)
tree09c02e8aa8d7fe495109823ee5848cdc01becb96 /src/xkbcomp/ast.h
parent0e9c2ec97e8f5280171002834243104b9f53a772 (diff)
downloadxorg-lib-libxkbcommon-5b5b67f28ccfe1fe69ec5569c90f1752de323a08.tar.gz
Add support for modmap None (#291)
Unlike current xkbcommon, X11’s xkbcomp allows to remove entries in the modifiers’ map using “modifier_map None { … }”. “None” is translated to the special value “XkbNoModifier” defined in “X11/extensions/XKB.h”. Then it relies on the fact that in "CopyModMapDef", the following code: 1U << entry->modifier ends up being zero when “entry->modifier” is “XkbNoModifier” (i.e. 0xFF). Indeed, it relies on the overflow behaviour of the left shift, which in practice resolves to use only the 5 low bits of the shift amount, i.e. 0x1F here. Then the result of “1U << 0xFF” is cast to “char”, i.e. 0. This is a good trick but too magical, so in libxkbcommon we will use an explicit test against our new constant XKB_MOD_NONE.
Diffstat (limited to 'src/xkbcomp/ast.h')
-rw-r--r--src/xkbcomp/ast.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/xkbcomp/ast.h b/src/xkbcomp/ast.h
index 6c51ce4..8b0901f 100644
--- a/src/xkbcomp/ast.h
+++ b/src/xkbcomp/ast.h
@@ -303,6 +303,7 @@ typedef struct {
typedef struct {
ParseCommon common;
enum merge_mode merge;
+ // NOTE: Can also be “None”, rather than a modifier name.
xkb_atom_t modifier;
ExprDef *keys;
} ModMapDef;