gpui: Introduce PlatformKeyboardLayout
trait for human-friendly keyboard layout names (#29049)
This PR adds a new `PlatformKeyboardLayout` trait with two methods: `id(&self) -> &str` and `name(&self) -> &str`. The `id()` method returns a unique identifier for the keyboard layout, while `name()` provides a human-readable name. This distinction is especially important on Windows, where the `id` and `name` can be quite different. For example, the French layout has an `id` of `0000040C`, which is not human-readable, whereas the `name` would simply be `French`. Currently, the existing `keyboard_layout()` method returns what's essentially the same as `id()` in this new design. This PR implements the `name()` method for both Windows and macOS. On Linux, for now, `name()` still returns the same value as `id()`. Release Notes: - N/A
This commit is contained in:
parent
0454e7a22e
commit
f0ef3110d3
16 changed files with 197 additions and 68 deletions
|
@ -1224,9 +1224,9 @@ pub fn handle_keymap_file_changes(
|
|||
})
|
||||
.detach();
|
||||
|
||||
let mut current_mapping = settings::get_key_equivalents(cx.keyboard_layout());
|
||||
let mut current_mapping = settings::get_key_equivalents(cx.keyboard_layout().id());
|
||||
cx.on_keyboard_layout_change(move |cx| {
|
||||
let next_mapping = settings::get_key_equivalents(cx.keyboard_layout());
|
||||
let next_mapping = settings::get_key_equivalents(cx.keyboard_layout().id());
|
||||
if next_mapping != current_mapping {
|
||||
current_mapping = next_mapping;
|
||||
keyboard_layout_tx.unbounded_send(()).ok();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue