1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-19 02:37:51 +03:00

window: point to re-integrated xkbcommon

refs: https://github.com/rust-x-bindings/xkbcommon-rs/pull/30
This commit is contained in:
Wez Furlong 2022-05-09 17:24:20 -07:00
parent 8523a1b0e7
commit e5a483ff8b
3 changed files with 24 additions and 29 deletions

25
Cargo.lock generated
View File

@ -2066,16 +2066,6 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memmap"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]]
name = "memmap2"
version = "0.2.3"
@ -2094,6 +2084,15 @@ dependencies = [
"libc",
]
[[package]]
name = "memmap2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "057a3db23999c867821a7a59feb06a578fcb03685e983dff90daf9e7d24ac08f"
dependencies = [
"libc",
]
[[package]]
name = "memmem"
version = "0.1.1"
@ -5193,11 +5192,11 @@ dependencies = [
[[package]]
name = "xkbcommon"
version = "0.6.0"
source = "git+https://github.com/wez/xkbcommon-rs.git?rev=69a29877e99369b4ec74703d3193b6dd694145e9#69a29877e99369b4ec74703d3193b6dd694145e9"
version = "0.5.0-beta.0"
source = "git+https://github.com/wez/xkbcommon-rs.git?branch=key-by-name#546ba7dbf2ace214b9947fc4646a0f4afd70cb0a"
dependencies = [
"libc",
"memmap",
"memmap2 0.5.3",
"xcb",
]

View File

@ -68,7 +68,7 @@ dirs-next = "2.0"
filedescriptor = { version="0.8", path = "../filedescriptor" }
x11 = {version ="2.19", features = ["xlib_xcb"]}
xcb = {version="1.1", features=["render", "randr", "xkb", "xlib_xcb"]}
xkbcommon = { version = "0.6", features = ["x11", "wayland"], git="https://github.com/wez/xkbcommon-rs.git", rev="69a29877e99369b4ec74703d3193b6dd694145e9"}
xkbcommon = { version = "0.5.0-beta.0", features = ["x11", "wayland"], git="https://github.com/wez/xkbcommon-rs.git", branch="key-by-name"}
#xkbcommon = { version = "0.6", features = ["x11", "wayland"], path="../../xkbcommon-rs" }
mio = {version="0.8", features=["os-ext"]}
libc = "0.2"

View File

@ -7,7 +7,8 @@ use anyhow::{anyhow, ensure};
use libc;
use std::cell::RefCell;
use std::collections::HashMap;
use std::ffi::CStr;
use std::ffi::{CStr, OsStr};
use std::os::unix::ffi::OsStrExt;
use wezterm_input_types::PhysKeyCode;
use xkb::compose::Status as ComposeStatus;
use xkbcommon::xkb;
@ -141,12 +142,9 @@ impl Keyboard {
let state = xkb::State::new(&keymap);
let locale = query_lc_ctype()?;
let table = xkb::compose::Table::new_from_locale(
&context,
locale.to_str()?,
xkb::compose::COMPILE_NO_FLAGS,
)
.map_err(|_| anyhow!("Failed to acquire compose table from locale"))?;
let table =
xkb::compose::Table::new_from_locale(&context, locale, xkb::compose::COMPILE_NO_FLAGS)
.map_err(|_| anyhow!("Failed to acquire compose table from locale"))?;
let compose_state = xkb::compose::State::new(&table, xkb::compose::STATE_NO_FLAGS);
let phys_code_map = build_physkeycode_map(&keymap);
@ -184,12 +182,9 @@ impl Keyboard {
let locale = query_lc_ctype()?;
let table = xkb::compose::Table::new_from_locale(
&context,
locale.to_str()?,
xkb::compose::COMPILE_NO_FLAGS,
)
.map_err(|_| anyhow!("Failed to acquire compose table from locale"))?;
let table =
xkb::compose::Table::new_from_locale(&context, locale, xkb::compose::COMPILE_NO_FLAGS)
.map_err(|_| anyhow!("Failed to acquire compose table from locale"))?;
let compose_state = xkb::compose::State::new(&table, xkb::compose::STATE_NO_FLAGS);
{
@ -487,10 +482,11 @@ impl Keyboard {
}
}
fn query_lc_ctype() -> anyhow::Result<&'static CStr> {
fn query_lc_ctype() -> anyhow::Result<&'static OsStr> {
let ptr = unsafe { libc::setlocale(libc::LC_CTYPE, std::ptr::null()) };
ensure!(!ptr.is_null(), "failed to query locale");
unsafe { Ok(CStr::from_ptr(ptr)) }
let cstr = unsafe { CStr::from_ptr(ptr) };
Ok(OsStr::from_bytes(cstr.to_bytes()))
}
fn build_physkeycode_map(keymap: &xkb::Keymap) -> HashMap<xkb::Keycode, PhysKeyCode> {