Skip to content

fix: re-apply xkb.file keymap in reset_keymap path#3558

Draft
mgabor3141 wants to merge 1 commit intoniri-wm:mainfrom
mgabor3141:fix/reset-keymap-xkb-file
Draft

fix: re-apply xkb.file keymap in reset_keymap path#3558
mgabor3141 wants to merge 1 commit intoniri-wm:mainfrom
mgabor3141:fix/reset-keymap-xkb-file

Conversation

@mgabor3141
Copy link

@mgabor3141 mgabor3141 commented Mar 4, 2026

Fixes the reset_keymap path described in #3557 (Bug 1).

Problem

When reset_keymap triggers (after a Wayland virtual keyboard event followed by a physical keyboard event), the keymap is recompiled via to_xkb_config(). However, to_xkb_config() does not include the file field — it only forwards rules, model, layout, variant, and options. This silently replaces file-based keymaps with default rules-based keymaps, losing all custom symbols and overrides.

Fix

Check for xkb.file first in the reset_keymap path and call set_xkb_file() directly, mirroring how the config-reload logic handles file-based keymaps.

Also makes set_xkb_file() pub(crate) so it can be called from input/mod.rs.

Changes

  • src/input/mod.rs: In the reset_keymap block, prioritize xkb.file over to_xkb_config()
  • src/niri.rs: Change set_xkb_file visibility from private to pub(crate)

Note

Issue #3557 also describes a second bug (config reload fallback permanently poisoning the keymap when set_xkb_file fails transiently). That is not addressed by this PR.

When reset_keymap triggers (after a virtual keyboard event followed by
a physical keyboard event), the keymap is recompiled from the user's
config. However, to_xkb_config() does not include the `file` field,
so file-based keymaps are silently replaced with default rules-based
keymaps, losing all custom symbols and overrides.

Fix by checking for xkb.file first and calling set_xkb_file() in the
reset path, mirroring the config-reload logic.

Also make set_xkb_file() pub(crate) so it can be called from
input/mod.rs.

Fixes niri-wm#3557
@mgabor3141 mgabor3141 changed the title fix: re-apply xkb.file keymap on virtual→physical keyboard reset fix: re-apply xkb.file keymap in reset_keymap path Mar 4, 2026
@YaLTeR
Copy link
Member

YaLTeR commented Mar 4, 2026

We're deleting this code soon

mgabor3141 pushed a commit to mgabor3141/dots that referenced this pull request Mar 5, 2026
Add reset-keymap-xkb-file.patch: the reset_keymap code path in
input/mod.rs calls to_xkb_config() which drops the file field,
silently replacing file-based keymaps with defaults. The patch
checks for xkb.file first and calls set_xkb_file() directly.

Also update numlock-xkb-file.patch to make set_xkb_file() pub(crate)
so it can be called from input/mod.rs.

Upstream: niri-wm/niri#3557
PR: niri-wm/niri#3558
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.

2 participants