Skip to content

Compose: allow overlapping sequences#398

Draft
wismill wants to merge 1 commit into
xkbcommon:masterfrom
wismill:compose/allow-overlapping-sequences
Draft

Compose: allow overlapping sequences#398
wismill wants to merge 1 commit into
xkbcommon:masterfrom
wismill:compose/allow-overlapping-sequences

Conversation

@wismill

@wismill wismill commented Nov 1, 2023

Copy link
Copy Markdown
Member

Motivation

Currently xkbcommon does not support Compose overlapping sequences,
unlike GTK and ibus. It means a sequence that is a prefix to a longer
one is simply discarded with a warning.

This is unfortunate:

  • There is discrepency for users of xkbcommon, e.g. Qt-based apps.

  • It is impossible to have a sequence that is the prefix of another one.
    As a consequence, if one imports e.g. the system locale Compose file
    (as many – most ? – custom Compose files do), some sequences become
    impossible.

    Example: I used <Multi_key> <minus> <period> : "•" U2022 but
    upstream change in libX11 added <Multi_key> <minus> <period> <e> : "ė̄",
    so I had to introduce an alternative sequence for Qt apps, although
    the previous one works in GTK-based apps.

Proposed change

This commit introduces the new following API:

  • Macro XKB_COMPOSE_HAS_OVERLAPPING_SEQUENCES_SUPPORT to test
    overlapping sequences support at compile time via #ifdef.
  • xkb_compose_compile_flags:
    XKB_COMPOSE_COMPILE_OVERLAPPING_SEQUENCES: Allow overlapping sequences
  • xkb_compose_status:
    - XKB_COMPOSE_CANDIDATE: A complete sequence has been matched, but
    a longer sequence also exists.
    - XKB_COMPOSE_CANDIDATE_ACCEPTED: The last sequence was accepted
    due to an unmatched keysym.

Fixes #395

NOTE: I intend to add the first two commits in #399. Will need to rebase once done.

Trying the patch

You can try it with

meson devenv -C build xkbcli-interactive-wayland --enable-compose --enable-compose-overlapping

or replace wayland with x11 if relevant.

Implementation in Qt

I asked feedback to Qt devs.

I sent also sent a merge request.

@wismill wismill added enhancement Indicates new feature requests compose Indicates a need for improvements or additions to Compose handling labels Nov 1, 2023
@wismill
wismill requested review from bluetech and whot November 1, 2023 17:31
@wismill

wismill commented Nov 1, 2023

Copy link
Copy Markdown
Member Author

The idea is to create nodes that contain the overlapping results using a previously unused slot.

Possible enhancements:

  • Naming
  • Compose sequence iterator
  • Doc
  • Integration in toolkits (Qt in particular)

It would be great to be able to test this in Qt apps to test the design, but I will not do it myself.

@wismill wismill added this to the 1.7.0 milestone Nov 1, 2023
@wismill

wismill commented Nov 2, 2023

Copy link
Copy Markdown
Member Author

I asked feedback to Qt devs.

@wismill

wismill commented Nov 3, 2023

Copy link
Copy Markdown
Member Author

Not too happy with the XKB_COMPOSE_CANDIDATE_ACCEPTED state. But if we return just XKB_COMPOSE_COMPOSED, then the client should handle the last keysym as not part of the sequence.

@wismill
wismill force-pushed the compose/allow-overlapping-sequences branch 2 times, most recently from 95e8b5b to 8f8d656 Compare November 4, 2023 20:27
@wismill
wismill force-pushed the compose/allow-overlapping-sequences branch from 8f8d656 to bbb3ca7 Compare November 6, 2023 20:19
Currently xkbcommon does not support Compose overlapping sequences,
unlike GTK and ibus. It means a sequence that is a prefix to a longer
one is simply discarded with a warning.

This is unfortunate:
- There is discrepency for users of xkbcommon, e.g. Qt-based apps.
- It is impossible to have a sequence that is the prefix of another one.
  As a consequence, if one imports e.g. the system locale Compose file
  (as many – most ? – custom Compose files do), some sequences become
  impossible.

  Example: I used `<Multi_key> <minus> <period> : "•" U2022` but
  upstream change in libX11 added `<Multi_key> <minus> <period> <e> : "ė̄"`,
  so I had to introduce an alternative sequence for Qt apps, although
  the previous one works in GTK-based apps.

This commit introduces the new following API:
- Macro `XKB_COMPOSE_HAS_OVERLAPPING_SEQUENCES_SUPPORT` to test
  overlapping sequences support at compile time via `#ifdef`.
- `xkb_compose_compile_flags`:
  `XKB_COMPOSE_COMPILE_OVERLAPPING_SEQUENCES`: Allow overlapping sequences
- `xkb_compose_status`:
  - `XKB_COMPOSE_CANDIDATE`: A complete sequence has been matched, but
    a longer sequence also exists.
  - `XKB_COMPOSE_CANDIDATE_ACCEPTED`: The last sequence was accepted
    due to an unmatched keysym.
@wismill
wismill force-pushed the compose/allow-overlapping-sequences branch from bbb3ca7 to ab79706 Compare November 6, 2023 20:42
@wismill

wismill commented Nov 8, 2023

Copy link
Copy Markdown
Member Author

I sent a merge request in Qt.

@wismill wismill mentioned this pull request Jan 9, 2024
@wismill wismill modified the milestones: 1.7.0, 1.8.0 Feb 8, 2024
@wismill wismill modified the milestones: 1.8.0, 1.9.0 Nov 29, 2024
@wismill wismill modified the milestones: 1.9.0, 1.10.0 Jan 22, 2025
@wismill wismill modified the milestones: 1.10.0, 1.12.0 May 5, 2025
@wismill wismill modified the milestones: 1.12.0, 1.13.0 Oct 8, 2025
@wismill wismill modified the milestones: 1.13.0, 1.14.0 Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compose Indicates a need for improvements or additions to Compose handling enhancement Indicates new feature requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xkbcommon supports no way for a prefix pattern to override a longer pattern matching the prefix

1 participant