Skip to content

feat(xkb): remember and restore keyboard layout per window - #2691

Open
6insanes wants to merge 1 commit into
pop-os:masterfrom
6insanes:per-window-keyboard-layout
Open

feat(xkb): remember and restore keyboard layout per window#2691
6insanes wants to merge 1 commit into
pop-os:masterfrom
6insanes:per-window-keyboard-layout

Conversation

@6insanes

@6insanes 6insanes commented Aug 2, 2026

Copy link
Copy Markdown

Adds an opt-in per_window_layout flag to XkbConfig. When enabled, the active xkb layout group is saved for the window losing keyboard focus and restored for the window gaining it, so each window keeps its own layout instead of sharing one global layout across the whole session — matching GNOME's "Use different sources for different windows".

Behavior

  • Off by default, no behavior change unless explicitly enabled.
  • A window that has never had focus before (or was just mapped) simply inherits whichever layout is currently active — no jarring reset to layout 0.
  • Only applies to actual windows (Element/Fullscreen focus targets). Popups, layer-shell surfaces (panel/dock), the window-group focus target, and the lock screen are intentionally excluded, so opening a context menu or tooltip never touches the layout.
  • The existing zcosmic_keyboard_layout_v1 protocol and panel indicator need no changes — they already broadcast whatever the seat's active layout is, which this PR keeps in sync with the focused window.

Testing
Manually tested on real hardware (KMS session on a spare VT, and now daily-driven in a real session) with 2 layouts (en/ru) and Alt+Shift switching: opening/switching between multiple windows correctly saves and restores each window's own layout.

Closes pop-os/cosmic-epoch#3092.
Related: pop-os/cosmic-settings#1038 (UI toggle) — companion PR for the settings checkbox will follow once this lands, since it needs this field to exist in a published cosmic-comp-config revision.

  • I have disclosed use of any AI generated code in my commit messages.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

@6insanes

6insanes commented Aug 2, 2026

Copy link
Copy Markdown
Author

FYI for maintainers: the settings-side UI (a toggle for this in cosmic-settings' Keyboard → Input Sources page, closing pop-os/cosmic-settings#1038) is already implemented and tested locally. I'm holding off on opening that PR until this one lands, since it needs cosmic-comp-config to have a published revision with the new per_window_layout field — happy to open it right away once this merges.

Adds an opt-in per_window_layout flag to XkbConfig. When enabled, the
active xkb layout group is saved to the outgoing focus target and
restored for the incoming one on every keyboard focus change, so each
window keeps its own layout instead of sharing one global layout
across the whole session.

This change was implemented by Claude Code (Anthropic), directed,
reviewed, and tested by the author.

Closes pop-os/cosmic-epoch#3092
@6insanes
6insanes force-pushed the per-window-keyboard-layout branch from 3ac6871 to cddb5b8 Compare August 2, 2026 14:39
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.

Per-window / per-workspace keyboard layout

1 participant