Branch
Hash :
7a7a3b38
Author :
Date :
2024-02-14T09:47:15
keymap: Canonically map unmapped virtual modifiers
Traditionally, *virtual* modifiers were merely name aliases for *real*
modifiers (X *core* modifiers), e.g. `NumLock` was usually mapped to
`Mod2` (see `modifier_map` statement). Virtual modifiers that were never
mapped to a real ones had no effect on the keymap state.
xkbcommon already supports the concept of “pure” virtual modifiers, i.e.
virtual modifiers that are *encoded* using the full 32-bit range, not
just the first 8 bits corresponding to the real modifiers.
But until this commit, one had to declare such mapping *explicitly*:
e.g. `virtual_modifiers M = 0x100;`. This has at least two drawbacks:
- Numerical values may look quite arbitrary and are not user-friendly.
It’s OK in the resulting compiled keymap, but it requires careful sync
between sections when developing KcCGST files.
- If the modifier is *also* mapped *implicitly* using the traditional
`vmodmap`/`modifier_map`, then both mappings are OR-combined.
This patch enables to automatically map unmapped virtual modifiers to
their *canonical* mapping, i.e. themselves: their corresponding virtual
and real modifier masks are identical: `1u << mod_index`.
Since this feature is incompatible with X11, this is guarded by requiring
at least keymap text format **v2**.
Note that for now, canonical virtual modifiers cannot be used in an
interpret action’s `AnyOf()`. An interpret action for a canonical virtual
modifier must be `AnyOfOrNone()` to take effect:
virtual_modifiers APureMod, …;
interpret a+AnyOfOrNone(all) {
virtualModifier= APureMod;
action= SetMods(modifiers=APureMod);
};
The above adds a virtual modifier `APureMod` for keysym `a`. It will be
canonical iff it is not mapped implicitly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
xkb_keymap {
xkb_keycodes "test" {
minimum = 8;
maximum = 255;
<TLDE> = 49;
<AE01> = 10;
<AE02> = 11;
<AE03> = 12;
<AE04> = 13;
<AE05> = 14;
<AE06> = 15;
<AE07> = 16;
<AE08> = 17;
<AE09> = 18;
<AE10> = 19;
<AE11> = 20;
<AE12> = 21;
<BKSP> = 22;
<TAB> = 23;
<AD01> = 24;
<AD02> = 25;
<AD03> = 26;
<AD04> = 27;
<AD05> = 28;
<AD06> = 29;
<AD07> = 30;
<AD08> = 31;
<AD09> = 32;
<AD10> = 33;
<AD11> = 34;
<AD12> = 35;
<BKSL> = 51;
<RTRN> = 36;
<CAPS> = 66;
<AC01> = 38;
<AC02> = 39;
<AC03> = 40;
<AC04> = 41;
<AC05> = 42;
<AC06> = 43;
<AC07> = 44;
<AC08> = 45;
<AC09> = 46;
<AC10> = 47;
<AC11> = 48;
alias <AC12> = <BKSL>;
<LFSH> = 50;
<LSGT> = 94;
<AB01> = 52;
<AB02> = 53;
<AB03> = 54;
<AB04> = 55;
<AB05> = 56;
<AB06> = 57;
<AB07> = 58;
<AB08> = 59;
<AB09> = 60;
<AB10> = 61;
<RTSH> = 62;
<LVL3> = 92;
<RALT> = 108;
};
xkb_types "complete" {
// Define >20 virtual modifiers. This lead to overcome the X11 limit of
// 16 virtual modifiers.
virtual_modifiers
LevelThree = 0x00000100,
ModA = 0x00000200,
ModB = 0x00000400,
ModC = 0x00000800,
ModD = 0x00001000,
ModE = 0x00002000,
ModF = 0x00004000,
ModG = 0x00008000,
ModH = 0x00010000,
ModI = 0x00020000,
ModJ = 0x00040000,
ModK = 0x00080000,
ModL = 0x00100000,
ModM = 0x00200000,
ModN = 0x00400000,
ModO = 0x00800000,
ModP = 0x01000000,
ModQ = 0x02000000,
ModR = 0x04000000,
ModS = 0x08000000,
ModT = 0x10000000,
ModU = 0x20000000,
ModV = 0x40000000;
type "ONE_LEVEL" {
modifiers= none;
level_name[Level1]= "Any";
};
type "TWO_LEVEL" {
modifiers= Shift;
map[Shift]= 2;
level_name[1]= "Base";
level_name[2]= "Shift";
};
type "TEST" {
modifiers=
Shift + LevelThree +
ModA + ModB + ModC + ModD + ModE + ModF + ModG +
ModH + ModI + ModJ + ModK + ModL + ModM + ModN +
ModO + ModP + ModQ + ModR + ModS + ModT + ModU + ModV;
map[ModA]= 2;
map[ModB]= 3;
map[ModC]= 4;
map[ModD]= 5;
map[ModE]= 6;
map[ModF]= 7;
map[ModG]= 8;
map[ModH]= 9;
map[ModI]= 10;
map[ModJ]= 11;
map[ModK]= 12;
map[ModL]= 13;
map[ModM]= 14;
map[ModN]= 15;
map[ModO]= 16;
map[ModP]= 17;
map[ModQ]= 18;
map[ModR]= 19;
map[ModS]= 20;
map[ModT]= 21;
map[ModU]= 22;
map[ModV]= 23;
map[ModV+Shift]= 24;
map[ModA+ModS]= 25;
map[ModA+ModQ]= 26;
map[LevelThree+ModA]= 27;
map[LevelThree+ModA+ModS]= 28;
map[ModA+ModB+ModC]= 29;
level_name[1]= "1";
level_name[2]= "2";
level_name[3]= "3";
level_name[4]= "4";
level_name[5]= "5";
level_name[6]= "6";
level_name[7]= "7";
level_name[8]= "8";
level_name[9]= "9";
level_name[10]= "10";
level_name[11]= "11";
level_name[12]= "12";
level_name[13]= "13";
level_name[14]= "14";
level_name[15]= "15";
level_name[16]= "16";
level_name[17]= "17";
level_name[18]= "18";
level_name[19]= "19";
level_name[20]= "20";
level_name[21]= "21";
level_name[22]= "22";
level_name[23]= "23";
level_name[24]= "24";
level_name[25]= "25";
level_name[26]= "26";
level_name[27]= "27";
level_name[28]= "28";
level_name[29]= "29";
};
};
xkb_compatibility "complete" {
virtual_modifiers LevelThree, ModA, ModB, ModC, ModD;
interpret.useModMapMods= AnyLevel;
interpret.repeat= False;
interpret.locking= False;
interpret Any+AnyOf(all) {
action= SetMods(modifiers=modMapMods,clearLocks);
};
interpret ISO_Level3_Shift+AnyOf(all) {
virtualModifier= LevelThree;
useModMapMods=level1;
action= SetMods(modifiers=LevelThree,clearLocks);
};
interpret a {
action= SetMods(modifiers=ModA,clearLocks);
};
interpret b {
action= SetMods(modifiers=ModB,clearLocks);
};
interpret c {
action= SetMods(modifiers=ModC,clearLocks);
};
interpret d {
action= SetMods(modifiers=ModD,clearLocks);
};
interpret e {
action= SetMods(modifiers=ModE,clearLocks);
};
interpret f {
action= SetMods(modifiers=ModF,clearLocks);
};
interpret g {
action= SetMods(modifiers=ModG,clearLocks);
};
interpret h {
action= SetMods(modifiers=ModH,clearLocks);
};
interpret i {
action= SetMods(modifiers=ModI,clearLocks);
};
interpret j {
action= SetMods(modifiers=ModJ,clearLocks);
};
interpret k {
action= SetMods(modifiers=ModK,clearLocks);
};
interpret l {
action= SetMods(modifiers=ModL,clearLocks);
};
interpret m {
action= SetMods(modifiers=ModM,clearLocks);
};
interpret n {
action= SetMods(modifiers=ModN,clearLocks);
};
interpret o {
action= SetMods(modifiers=ModO,clearLocks);
};
interpret p {
action= SetMods(modifiers=ModP,clearLocks);
};
interpret q {
action= SetMods(modifiers=ModQ,clearLocks);
};
interpret r {
action= SetMods(modifiers=ModR,clearLocks);
};
interpret s {
action= SetMods(modifiers=ModS,clearLocks);
};
interpret t {
action= SetMods(modifiers=ModT,clearLocks);
};
interpret u {
action= SetMods(modifiers=ModU,clearLocks);
};
interpret v {
action= SetMods(modifiers=ModV,clearLocks);
};
};
xkb_symbols {
name[group1]="Test";
key <LFSH> { [Shift_L] };
key <RALT> { [ISO_Level3_Shift] };
key <LVL3> { [ISO_Level3_Shift] };
modmap Shift { <LFSH> };
modmap Mod5 { <LVL3>, <RALT> };
key <AD01> {[ q, Q ]};
key <AD02> {[ w, W ]};
key <AD03> {[ e, E ]};
key <AD04> {[ r, R ]};
key <AD05> {[ t, T ]};
key <AD06> {[ y, Y ]};
key <AD07> {[ u, U ]};
key <AD08> {[ i, I ]};
key <AD09> {[ o, O ]};
key <AD10> {[ p, P ]};
key <AC01> {[ a, A ]};
key <AC02> {[ s, S ]};
key <AC03> {[ d, D ]};
key <AC04> {[ f, F ]};
key <AC05> {[ g, G ]};
key <AC06> {[ h, H ]};
key <AC07> {[ j, J ]};
key <AC08> {[ k, K ]};
key <AC09> {[ l, L ]};
key <AB01> {[ z, Z ]};
key <AB02> {[ x, X ]};
key <AB03> {[ c, C ]};
key <AB04> {[ v, V ]};
key <AB05> {[ b, B ]};
key <AB06> {[ n, N ]};
key <AB07> {[ m, M ]};
key.type[1] = "TEST";
key <AD02> {
[ w, a, b, c, d, e, f, g, h, i, j, k, l, m, n
, o, p, q, r, s, t, u, v, V, 1, 2, 3, 4, 5 ]
};
};
};