Skip to content

Commit

Permalink
Clear mods properly with |=
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-Bertholet committed Jan 8, 2025
1 parent d2eb860 commit 4cd5209
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ xkb_filter_mod_set_func(struct xkb_state *state,
return XKB_FILTER_CONSUME;
}

state->clear_mods = filter->action.mods.mods.mask;
state->clear_mods |= filter->action.mods.mods.mask;
if (filter->action.mods.flags & ACTION_LOCK_CLEAR)
state->components.locked_mods &= ~filter->action.mods.mods.mask;

Expand Down Expand Up @@ -587,13 +587,13 @@ xkb_filter_mod_latch_func(struct xkb_state *state,
state->components.latched_mods &=
~filter->action.mods.mods.mask;
else
state->clear_mods = filter->action.mods.mods.mask;
state->clear_mods |= filter->action.mods.mods.mask;
state->components.locked_mods &= ~filter->action.mods.mods.mask;
filter->func = NULL;
}
else {
latch = LATCH_PENDING;
state->clear_mods = filter->action.mods.mods.mask;
state->clear_mods |= filter->action.mods.mods.mask;
state->components.latched_mods |= filter->action.mods.mods.mask;
/* XXX beep beep! */
}
Expand Down
1 change: 1 addition & 0 deletions test/data/keycodes/evdev
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ default xkb_keycodes "evdev" {

// Fake keycodes for virtual keys
<LVL3> = 92;
<LVL5> = 500;
<MDSW> = 203;
<ALT> = 204;
<META> = 205;
Expand Down
13 changes: 13 additions & 0 deletions test/data/symbols/issue583
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
default partial alphanumeric_keys
xkb_symbols "base" {
name[Group1] = "Test issue #583";

key <AB01> { [ z, Z, y, Y, ezh, EZH, ydiaeresis, Ydiaeresis ], type[Group1] = "EIGHT_LEVEL" };

key <LCTL> { [ Control_L ] };

key <RALT> { [ ISO_Level3_Latch, ISO_Level5_Latch ], type[Group1] = "PC_CONTROL_LEVEL2" };

key <LVL5> { [ ISO_Level5_Shift ] };
modifier_map Mod3 { <LVL5> };
};
23 changes: 23 additions & 0 deletions test/keyseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,28 @@ test_explicit_actions(struct xkb_context *ctx)
}
}

static void
test_583(struct xkb_context *context)
{
struct xkb_keymap *keymap;

keymap = test_compile_rules(context, "evdev", "evdev", "issue583", "", "");
assert(keymap);

assert(test_key_seq(keymap,
KEY_LEFTCTRL , DOWN, XKB_KEY_Control_L , // Set Control
NEXT, KEY_RIGHTALT , BOTH, XKB_KEY_ISO_Level5_Latch , // Latch Level5
NEXT, KEY_LEFTCTRL , UP , XKB_KEY_Control_L , // Unset Control
NEXT, KEY_RIGHTALT , BOTH, XKB_KEY_ISO_Level3_Latch , // Latch Level3
NEXT, KEY_Z , BOTH, XKB_KEY_ydiaeresis , // Unlatch Level3, unlatch Level5
NEXT, KEY_Z , BOTH, XKB_KEY_z ,
NEXT, KEY_Z , BOTH, XKB_KEY_z ,

FINISH));

xkb_keymap_unref(keymap);
}

int
main(void)
{
Expand All @@ -375,6 +397,7 @@ main(void)

assert(ctx);

test_583(ctx);
test_group_latch(ctx);
test_explicit_actions(ctx);

Expand Down

0 comments on commit 4cd5209

Please sign in to comment.