feature(keyboard): support user-defined xkb layouts
Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>
This commit is contained in:
parent
3182327417
commit
4a311f15a4
1 changed files with 17 additions and 0 deletions
|
|
@ -84,6 +84,7 @@ pub type Description = String;
|
||||||
pub enum LayoutSource {
|
pub enum LayoutSource {
|
||||||
Base,
|
Base,
|
||||||
Extra,
|
Extra,
|
||||||
|
Custom,
|
||||||
}
|
}
|
||||||
|
|
||||||
const KB_REPEAT_DELAY_DEFAULT: u32 = 600;
|
const KB_REPEAT_DELAY_DEFAULT: u32 = 600;
|
||||||
|
|
@ -332,6 +333,22 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
)
|
)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
// Add user-defined layouts if any are found
|
||||||
|
let user_layouts = xkb_data::user_keyboard_layouts();
|
||||||
|
match user_layouts {
|
||||||
|
Ok(ref custom) => {
|
||||||
|
sorted_layouts.extend(
|
||||||
|
custom
|
||||||
|
.layouts()
|
||||||
|
.iter()
|
||||||
|
.map(|layout| (layout, LayoutSource::Custom)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(why) => {
|
||||||
|
tracing::error!(?why, "failed to get user keyboard layouts");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sorted_layouts.sort_unstable_by(|(a, _), (b, _)| {
|
sorted_layouts.sort_unstable_by(|(a, _), (b, _)| {
|
||||||
match (a.name(), b.name()) {
|
match (a.name(), b.name()) {
|
||||||
// Place US at the top of the list as it's the default
|
// Place US at the top of the list as it's the default
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue