Skip to content

gpui: Hide XF86 keybindings from menus and keybinding hints#50540

Merged
ConradIrwin merged 3 commits intozed-industries:mainfrom
Dnreikronos:hide-xf86-keybindings-in-menus
Mar 13, 2026
Merged

gpui: Hide XF86 keybindings from menus and keybinding hints#50540
ConradIrwin merged 3 commits intozed-industries:mainfrom
Dnreikronos:hide-xf86-keybindings-in-menus

Conversation

@Dnreikronos
Copy link
Copy Markdown
Contributor

Closes #50436

Before you mark this PR as ready for review, make sure that you have:

  • Added a solid test coverage and/or screenshots from doing manual testing
  • Done a self-review taking into account security and performance aspects
  • Aligned any UI changes with the UI checklist

Release Notes:

  • Fixed XF86 multimedia key names ("New", "Save", "Open") being shown as keybinding hints in menus instead of the actual keyboard shortcuts.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 2, 2026
@Dnreikronos
Copy link
Copy Markdown
Contributor Author

Dnreikronos commented Mar 2, 2026

Summary

XF86 multimedia keysyms (XF86New, XF86Save, XF86Open, etc.) are mapped to key names like "New", "Save", "Open" on the Linux platform layer. When Zed
picks the highest-precedence binding to display in menus and keybinding hints, it can select these XF86 bindings over useful ones like Ctrl+N, resulting in confusing labels "New" as a shortcut looks like the UI is broken, not like a keybinding.

What changed

  • Added is_xf86_key() in keystroke.rs to identify XF86 multimedia key names (new, open, save, cut, copy, paste).
  • Added has_xf86_keystroke() on KeyBinding to check if any keystroke in a binding is an XF86 key.
  • Filtered XF86 bindings out of highest_precedence_binding_for_action in key_dispatch.rs — this is the method used by menus and keybinding hints to decide what to display.
  • Added two unit tests covering both the filtering and dispatch behavior.

Impact

  • Menus and keybinding hints no longer show XF86 key names. They fall through to the next non-XF86 binding (e.g. Ctrl+N) or show nothing if no
    alternative exists.
  • Key dispatch is untouched — if a user actually presses an XF86 key, it still triggers the bound action.
  • bindings_for_action (the full list, used by the keymap editor) still includes XF86 bindings.

Trade-offs

  • Users with rare XF86 keyboards will no longer see those bindings in menus, so they can't discover them through the UI. This is acceptable because:
    (1) these keyboards are essentially extinct, (2) the keys still work when pressed, and (3) the bindings are still visible in the keymap settings.
  • The is_xf86_key check uses a hardcoded list of key names. If new XF86 keysyms are added to the platform layer in the future, the list would need to
    be updated. An alternative would be tagging keystrokes as XF86 at the platform layer, but that's a larger refactor for minimal gain.

@Dnreikronos
Copy link
Copy Markdown
Contributor Author

Open to recommendations about that.

@ConradIrwin
Copy link
Copy Markdown
Member

@Dnreikronos Instead of doing this, can we re-order the keymap file to acheieve the same effect - that must be what we do with other cases where there are multiple bindings for one action.

@Dnreikronos
Copy link
Copy Markdown
Contributor Author

@Dnreikronos Instead of doing this, can we re-order the keymap file to acheieve the same effect - that must be what we do with other cases where there are multiple bindings for one action.

Thanks a lot!
I was id doubt about how to do that the best way as possible!!

@Dnreikronos
Copy link
Copy Markdown
Contributor Author

@Dnreikronos Instead of doing this, can we re-order the keymap file to acheieve the same effect - that must be what we do with other cases where there are multiple bindings for one action.

Hi @ConradIrwin!
Can you analyze the changes again, please?

@ConradIrwin
Copy link
Copy Markdown
Member

Looks good! I don't think we need those tests.

Are there other keys except save that need moving?

@Dnreikronos
Copy link
Copy Markdown
Contributor Author

Looks good! I don't think we need those tests.

Are there other keys except save that need moving?

No, save in ContextEditor was the only one in the wrong order. Back when the XF86 keys were first added (a22d8ef), they all went after the regular bindings. But aacd80e ("Prefer later bindings in keymap section for display in UI") reordered everything on the same day, it just missed this one spot in ContextEditor.

I also removed the two tests as you suggested!

@ConradIrwin
Copy link
Copy Markdown
Member

Thanks! And glad it ended up being a simple fix.

@ConradIrwin ConradIrwin enabled auto-merge (squash) March 13, 2026 01:51
@ConradIrwin ConradIrwin merged commit 8e04523 into zed-industries:main Mar 13, 2026
28 checks passed
tommyming pushed a commit to tommyming/zed that referenced this pull request Mar 13, 2026
…stries#50540)

Closes zed-industries#50436

Before you mark this PR as ready for review, make sure that you have:
- [x] Added a solid test coverage and/or screenshots from doing manual
testing
- [x] Done a self-review taking into account security and performance
aspects
- [ ] Aligned any UI changes with the [UI
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)

Release Notes:

- Fixed XF86 multimedia key names ("New", "Save", "Open") being shown as
keybinding hints in menus instead of the actual keyboard shortcuts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't show XF86 keybindings in menus

2 participants