Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

xkb_state_layout_index_is_active seems broken for XKB_STATE_LAYOUT_DEPRESSED and XKB_STATE_LAYOUT_LATCHED. #520

Open
wismill opened this issue Oct 1, 2024 · 0 comments
Labels
question Indicates that an issue, pull request, or discussion needs more information state Indicates a need for improvements or additions to the xkb_state API
Milestone

Comments

@wismill
Copy link
Member

wismill commented Oct 1, 2024

If we have 2 layouts and e.g. the following state components:

struct state_components components = {
    .base_group = 0
    .latched_group = 0
    .locked_group = 1
    .group = 1
    // …
};

then we have these counter-intuitive results:

xkb_state_layout_index_is_active(state, 0, XKB_STATE_LAYOUT_DEPRESSED) == 1; // Unexpected
xkb_state_layout_index_is_active(state, 0, XKB_STATE_LAYOUT_LATCHED) == 1; // Unexpected
xkb_state_layout_index_is_active(state, 0, XKB_STATE_LAYOUT_LOCKED) == 0;
xkb_state_layout_index_is_active(state, 0, XKB_STATE_LAYOUT_EFFECTIVE) == 0;

This is because we use indexes an not masks, contrary to modifiers. So here 0 may denotes either an unset value or the result of a sum or an actual index.

We should maybe disallow using XKB_STATE_LAYOUT_DEPRESSED and XKB_STATE_LAYOUT_LATCHED and return a negative value, e.g. -2.

@wismill wismill added question Indicates that an issue, pull request, or discussion needs more information state Indicates a need for improvements or additions to the xkb_state API labels Oct 1, 2024
@wismill wismill added this to the 1.9.0 milestone Jan 22, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
question Indicates that an issue, pull request, or discussion needs more information state Indicates a need for improvements or additions to the xkb_state API
Projects
None yet
Development

No branches or pull requests

1 participant