Skip to content

Commit

Permalink
symbols: Add tests for multiple actions per level
Browse files Browse the repository at this point in the history
  • Loading branch information
wismill committed Oct 8, 2024
1 parent b6035e9 commit d0c49c8
Show file tree
Hide file tree
Showing 4 changed files with 368 additions and 1 deletion.
6 changes: 6 additions & 0 deletions test/data/keymaps/stringcomp.data
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,12 @@ xkb_symbols "pc_us_ru_2_ca(multix)_3_de(neo)_4_inet(evdev)" {
type= "CTRL+ALT",
symbols[Group1]= [ F12, F12, F12, F12, XF86Switch_VT_12 ]
};
key <AB11> {
symbols[Group1]= [ Control_L, { Control_L, Mode_switch } ],
actions[Group1]= [ SetMods(modifiers=Control), { SetMods(modifiers=Control), SetGroup(group=+1) } ],
symbols[Group2]= [ { Control_L, Mode_switch }, Control_L ],
actions[Group2]= [ { SetMods(modifiers=Control), SetGroup(group=+1) }, SetMods(modifiers=Control) ]
};
key <KATA> { [ Katakana ] };
key <HIRA> { [ Hiragana ] };
key <HENK> { [ Henkan_Mode ] };
Expand Down
7 changes: 6 additions & 1 deletion test/data/symbols/awesome
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ xkb_symbols "awesome" {
key <AC01> { [ a, A, Return, Return ] };
key <AC02> { [ s, S, Left] };
key <AC03> { [ d, D, Down] };
key <AC04> { [ f, F, Righ] };
key <AC04> { [ f, F, Right] };
key <AC05> { [ g, G, BackSpace, BackSpace ] };

key <AB05> { [ b, B, Delete, Delete ] };

key <LCTL> {
symbols[1] = [ {Control_L, ISO_Next_Group } ],
actions[1] = [ {SetMods(modifiers=Control), SetGroup(group=+1) } ]
};
};
140 changes: 140 additions & 0 deletions test/data/symbols/multiple_actions
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
default alphanumeric_keys modifier_keys
xkb_symbols "basic" {
name[1] = "Multiple actions";

virtual_modifiers Alt, Super, LevelThree;

// Multiple keysyms but no actions: OK
key <LCTL> {
symbols[1] = [ { Control_L, ISO_Group_Shift } ]
};
// Multiple actions but no keysyms: OK, but will use NoSymbol
key <RCTL> {
actions[1] = [ { SetMods(modifiers=Control), SetGroup(group=+1) } ]
};
// Multiple keysyms and matching actions
key <LVL3> {
virtualModifiers = LevelThree,
symbols[1] = [ { ISO_Level3_Shift, ISO_Group_Shift } ],
actions[1] = [ { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ]
};
// Multiple actions and matching keysyms
key <MDSW> {
virtualModifiers = LevelThree,
actions[1] = [ { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ],
symbols[1] = [ { ISO_Level3_Shift, ISO_Group_Shift } ]
};

// Incompatible actions and keysyms count: error
key <LALT> {
symbols[1] = [ { Alt_L } ],
actions[1] = [ { SetMods(modifiers=Alt), SetGroup(group=+1) } ]
};
key <RALT> {
symbols[1] = [ { Alt_R, ISO_Group_Shift } ],
actions[1] = [ { SetMods(modifiers=Alt) } ]
};
key <LWIN> {
symbols[1] = [ { Super_L, ISO_Group_Shift } ],
actions[1] = [ { SetMods(modifiers=Super), SetGroup(group=+1), NoAction() } ]
};
key <RWIN> {
symbols[1] = [ { Super_R, ISO_Group_Shift , NoSymbol } ],
actions[1] = [ { SetMods(modifiers=Super), SetGroup(group=+1) } ]
};

// Incompatible categories
key <AB11> {
symbols[1] = [ { Control_L, Shift_L } ]
};
modifier_map Control { <AB11> };
key <AE13> {
symbols[1] = [ { Control_L, Shift_L } ],
actions[1] = [ { SetMods(modifiers=Control), SetMods(modifiers=Shift) } ]
};

// Various overrides, different keysyms, no explicit actions
key <AB01> { [ x ] };
key <AB01> { [ { Control_L, ISO_Group_Shift } ] };

key <AB02> { [ { Control_L, ISO_Group_Shift } ] };
key <AB02> { [ x ] };

// Various overrides, no keysyms, explicit actions
key <AB03> { actions[1] = [ { SetMods(modifiers=LevelThree) } ] };
key <AB03> { actions[1] = [ { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ] };

key <AB04> { actions[1] = [ { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ] };
key <AB04> { actions[1] = [ { SetMods(modifiers=LevelThree) } ] };

// Various overrides, different keysyms & actions
key <AB05> {
virtualModifiers = LevelThree,
symbols[1] = [ Control_L ],
actions[1] = [ SetMods(modifiers=Control) ]
};
key <AB05> {
symbols[1] = [ { ISO_Level3_Shift, ISO_Group_Shift } ],
actions[1] = [ { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ]
};

key <AB06> {
virtualModifiers = LevelThree,
symbols[1] = [ { ISO_Level3_Shift, ISO_Group_Shift } ],
actions[1] = [ { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ]
};
key <AB06> {
symbols[1] = [ Control_L ],
actions[1] = [ SetMods(modifiers=Control) ]
};

// Various overrides, same keysyms but different actions
key <AB07> {
virtualModifiers = LevelThree,
symbols[1] = [ { ISO_Level3_Shift, ISO_Group_Shift } ],
actions[1] = [ { SetMods(modifiers=Control), Private(type=254, data="foo") } ]
};
key <AB07> {
symbols[1] = [ { ISO_Level3_Shift, ISO_Group_Shift } ],
actions[1] = [ { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ]
};

// Mix various number of keysyms/actions
key <AC01> {
symbols[1] = [ ISO_Level3_Shift , { ISO_Level3_Shift, ISO_Group_Shift } ]
};
key <AC02> {
actions[1] = [ SetMods(modifiers=LevelThree), { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ]
};
key <AC03> {
symbols[1] = [ ISO_Level3_Shift , { ISO_Level3_Shift, ISO_Group_Shift } ],
actions[1] = [ SetMods(modifiers=LevelThree), { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ]
};
key <AC04> {
symbols[1] = [ { ISO_Level3_Shift, ISO_Group_Shift }, ISO_Level3_Shift ]
};
key <AC05> {
actions[1] = [ { SetMods(modifiers=LevelThree), SetGroup(group=+1) }, SetMods(modifiers=LevelThree) ]
};
key <AC06> {
symbols[1] = [ { ISO_Level3_Shift, ISO_Group_Shift }, ISO_Level3_Shift ],
actions[1] = [ { SetMods(modifiers=LevelThree), SetGroup(group=+1) }, SetMods(modifiers=LevelThree) ]
};
key <AC07> {
symbols[1] = [ ISO_Level3_Shift , { ISO_Level3_Shift, ISO_Group_Shift }, { ISO_Level3_Shift, ISO_Group_Shift } ]
};
key <AC08> {
actions[1] = [ SetMods(modifiers=LevelThree), { SetMods(modifiers=LevelThree), SetGroup(group=+1) }, { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ]
};
key <AC09> {
symbols[1] = [ ISO_Level3_Shift , { ISO_Level3_Shift, ISO_Group_Shift }, { ISO_Level3_Shift, ISO_Group_Shift } ],
actions[1] = [ SetMods(modifiers=LevelThree), { SetMods(modifiers=LevelThree), SetGroup(group=+1) }, { SetMods(modifiers=LevelThree), SetGroup(group=+1) } ]
};

// Using modifier_map (may trigger multiple interprets)
key <AD01> { symbols[1] = [ { a, b } ] };
modifier_map Shift { <AD01> };

// Our only alphanum key ✨
key <AE02> { [ 2, at ] };
};
Loading

0 comments on commit d0c49c8

Please sign in to comment.