Skip to content

Look at the modifiers before every batch typed on X11 - #101

Merged
donislawdev merged 2 commits into
mainfrom
fix/x11-modifiers-mid-send
Oct 28, 2026
Merged

donislawdev merged 2 commits into
mainfrom
fix/x11-modifiers-mid-send

Conversation

@donislawdev

@donislawdev donislawdev commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changes

On X11 a send now asks the server, before its first key and before every batch, which modifier keys are down and what state the keyboard is in (latched and locked modifiers, the layout group). What it finds decides the batch:

Found What the send does
Alt, held or locked stops at once, as on Windows (Alt was pressed)
Caps Lock turned on stops (Caps Lock was pressed)
Ctrl or Super waits up to two seconds, then stops naming the key
Shift or AltGr waits, only for a batch typed with keys of the layout
layout group switched since the start stops (the keyboard layout changed, new), only for a batch with keys of the layout

Before the first batch a modifier is refused by name (... is still held), as a held key always was, and Caps Lock gets its own sentence. A spare key carries its keysym on both levels and in every group, so Shift, AltGr and a group switch do not stop a batch made only of spare keys, and a locked Shift or AltGr at the start still types through spare keys as before.

Why

Measured on Ubuntu 26.04 with Xvfb and with a real Xorg fed by a uinput keyboard, Slint, GTK4 and Qt victims, the binary from main:

  • a locked Alt: a GTK4 field got nothing of a 255 character value while nkb send said it was sent,
  • Ctrl held while typing: 64 of 255 characters in the field, the rest became Ctrl+A,
  • Shift or Caps Lock while typing: capitals, a layout switch while typing: Cyrillic,

all with exit code 0. A latched Ctrl (sticky keys, from the physical keyboard or from XTEST) did not reach the keys this program sends, but the core state cannot tell a latch from a lock, so a latch is refused too. Telling them apart needs the XKB extension of x11rb, left out on purpose.

Code

  • in_the_way, modifiers_down and stopped_before_batch in linux_rules.rs, pure and tested on every system.
  • linux/watch.rs (new) holds what a send looks at before a key, moved out of linux/send.rs, which would have joined the band of files near the length ceiling.
  • StopReason::LayoutChanged in every layer, the clauses of the stop reasons moved from i18n.rs to i18n/stop.rs (the file stood at the ceiling of a whole file), and the marker of a key named in two words keeps one word (caps-lock-pressed).
  • Mutation entries M1597-M1606, and M1537, M1545, M1594 moved to i18n/stop.rs.
  • Clearing is unchanged.

Checked

  • Clippy with -D warnings on Windows, in WSL (Linux) and for aarch64-apple-darwin. Tests of the touched modules, the shape gate on Linux, the file axis, the repository-wide guards, the contract bridge and the release script tests.
  • Nine new scenes of the X11 loop pass on Xvfb and on Xorg with a physical keyboard, and fail on main. The existing scenes for Caps Lock, a held modifier, locked Shift and Mod5, Num Lock, the second layout group, Escape, keys in flight and an empty value pass. Two packs type the same as on main. The X11 clearing loop passes all seven scenes.

Also in this pull request

Cargo.lock takes pulldown-cmark 0.13.5 (from Slint 1.18.1) for RUSTSEC-2026-0414, published today, which made the required advisories check fail on every pull request. 0.13.5 was released on 2026-10-21 and keeps the MIT licence, and no other crate in the lock moves.

🤖 Generated with Claude Code

A send on X11 waited for the modifier keys held at its start and then
looked only at Escape, the caller's flag and the window in front. A
modifier pressed while the value was going in changed it while the send
said every key was typed: under Ctrl the rest became shortcuts, under
Shift and Caps Lock capitals, after a layout switch another script. A
modifier left locked was not seen at all, and a GTK field got nothing of
a value under a locked Alt.

Before the first key and before every batch the server is now asked for
the modifier keys down and for its state. Alt and Caps Lock stop the send
and say so, Ctrl and Super are waited for up to two seconds, and Shift,
AltGr and a switched layout group count only for a batch typed with keys
of the layout, because a spare key carries its keysym on both levels and
in every group. Before the first batch a modifier is refused by name, as
a held key is. The core state does not tell a latch from a lock, so a
latched Ctrl is refused as well.

A new stop reason says that the keyboard layout changed, in every layer.
What the send looks at before a key moves from linux/send.rs to
linux/watch.rs, and the clauses of the stop reasons from i18n.rs to
i18n/stop.rs, so that neither file grows past its ceiling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4435852b-69ee-47ea-8161-1560bf132b63
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Slint 1.18.1 brings pulldown-cmark, and 0.13.4 has an advisory published
today (exponential event growth with ENABLE_WIKILINKS). The required
advisories check fails on it for every pull request. 0.13.5 fixes it,
was released on 2026-10-21, so it has had the week the dependency rules
wait, and keeps the MIT licence. No other crate in the lock moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@donislawdev
donislawdev merged commit 5ad9094 into main Oct 28, 2026
31 checks passed
@donislawdev
donislawdev deleted the fix/x11-modifiers-mid-send branch October 28, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant