@@ -323,7 +323,8 @@ xkb_filter_group_lock_func(struct xkb_state *state,
323
323
324
324
static bool
325
325
xkb_action_breaks_latch (const union xkb_action * action ,
326
- enum xkb_internal_action_flags flag )
326
+ enum xkb_internal_action_flags flag ,
327
+ xkb_mod_mask_t mask )
327
328
{
328
329
switch (action -> type ) {
329
330
case ACTION_TYPE_NONE :
@@ -335,7 +336,8 @@ xkb_action_breaks_latch(const union xkb_action *action,
335
336
case ACTION_TYPE_TERMINATE :
336
337
return true;
337
338
case ACTION_TYPE_INTERNAL :
338
- return action -> internal .flags & flag ;
339
+ return (action -> internal .flags & flag ) &&
340
+ ((action -> internal .clear_latched_mods & mask ) == mask );
339
341
default :
340
342
return false;
341
343
}
@@ -419,7 +421,7 @@ xkb_filter_group_latch_func(struct xkb_state *state,
419
421
return XKB_FILTER_CONSUME ;
420
422
}
421
423
else if (xkb_action_breaks_latch (& (actions [k ]),
422
- INTERNAL_BREAKS_GROUP_LATCH )) {
424
+ INTERNAL_BREAKS_GROUP_LATCH , 0 )) {
423
425
/* Breaks the latch */
424
426
state -> components .latched_group = 0 ;
425
427
filter -> func = NULL ;
@@ -576,7 +578,8 @@ xkb_filter_mod_latch_func(struct xkb_state *state,
576
578
return XKB_FILTER_CONSUME ;
577
579
}
578
580
else if (xkb_action_breaks_latch (& (actions [k ]),
579
- INTERNAL_BREAKS_MOD_LATCH )) {
581
+ INTERNAL_BREAKS_MOD_LATCH ,
582
+ filter -> action .mods .mods .mask )) {
580
583
/* XXX: This may be totally broken, we might need to break the
581
584
* latch in the next run after this press? */
582
585
state -> components .latched_mods &= ~filter -> action .mods .mods .mask ;
@@ -934,39 +937,40 @@ static const struct xkb_key synthetic_key_break_group_latch = {
934
937
.num_groups = 1 ,
935
938
.groups = & synthetic_key_group_break_group_latch
936
939
};
937
- static struct xkb_level synthetic_key_level_break_mod_latch = {
938
- .num_syms = 1 ,
939
- .s = { XKB_KEY_NoSymbol },
940
- .a = { { .internal = {
941
- .type = ACTION_TYPE_INTERNAL ,
942
- .flags = INTERNAL_BREAKS_MOD_LATCH
943
- } } }
944
- };
945
- static struct xkb_group synthetic_key_group_break_mod_latch = {
946
- .type = & synthetic_key_type ,
947
- .levels = & synthetic_key_level_break_mod_latch
948
- };
949
- static const struct xkb_key synthetic_key_break_mod_latch = {
950
- .num_groups = 1 ,
951
- .groups = & synthetic_key_group_break_mod_latch
952
- };
940
+ static const struct xkb_key synthetic_key = { 0 };
953
941
954
942
/* Transcription from xserver: XkbLatchModifiers */
955
943
static void
956
944
update_latch_modifiers (struct xkb_state * state ,
957
945
xkb_mod_mask_t mask , xkb_mod_mask_t latches )
958
946
{
959
- const struct xkb_key * key = & synthetic_key_break_mod_latch ;
960
-
961
947
/* Clear affected latched modifiers */
962
948
const xkb_mod_mask_t clear =
963
949
mod_mask_get_effective (state -> keymap , mask & ~latches );
964
950
state -> components .latched_mods &= ~clear ;
965
951
966
952
/* Clear any pending latch to locks. */
967
- xkb_filter_apply_all (state , key , XKB_KEY_DOWN );
953
+ const struct xkb_level synthetic_key_level_break_mod_latch = {
954
+ .num_syms = 1 ,
955
+ .s = { XKB_KEY_NoSymbol },
956
+ .a = { { .internal = {
957
+ .type = ACTION_TYPE_INTERNAL ,
958
+ .flags = INTERNAL_BREAKS_MOD_LATCH ,
959
+ .clear_latched_mods = clear
960
+ } } }
961
+ };
962
+ const struct xkb_group synthetic_key_group_break_mod_latch = {
963
+ .type = & synthetic_key_type ,
964
+ .levels = & synthetic_key_level_break_mod_latch
965
+ };
966
+ const const struct xkb_key synthetic_key_break_mod_latch = {
967
+ .num_groups = 1 ,
968
+ .groups = & synthetic_key_group_break_mod_latch
969
+ };
970
+ xkb_filter_apply_all (state , & synthetic_key_break_mod_latch , XKB_KEY_DOWN );
968
971
969
972
/* Simulate tapping a key with a modifier latch action */
973
+ const struct xkb_key * key = & synthetic_key ;
970
974
const union xkb_action latch_mods = {
971
975
.mods = {
972
976
.type = ACTION_TYPE_MOD_LATCH ,
@@ -989,17 +993,16 @@ update_latch_modifiers(struct xkb_state *state,
989
993
static void
990
994
update_latch_group (struct xkb_state * state , int32_t group )
991
995
{
992
- /* Simulate tapping a key with a group latch action, but in isolation: i.e.
993
- * without affecting the other filters. */
994
- const struct xkb_key * key = & synthetic_key_break_group_latch ;
995
-
996
996
/* Clear any pending latch to locks. */
997
- xkb_filter_apply_all (state , key , XKB_KEY_DOWN );
997
+ xkb_filter_apply_all (state , & synthetic_key_break_group_latch , XKB_KEY_DOWN );
998
998
999
+ /* Simulate tapping a key with a group latch action, but in isolation: i.e.
1000
+ * without affecting the other filters. */
1001
+ const struct xkb_key * key = & synthetic_key ;
999
1002
const union xkb_action latch_group = {
1000
1003
.group = {
1001
1004
.type = ACTION_TYPE_GROUP_LATCH ,
1002
- .flags = 0 ,
1005
+ .flags = ACTION_ABSOLUTE_SWITCH ,
1003
1006
.group = group ,
1004
1007
},
1005
1008
};
0 commit comments