- Show the on-screen keyboard when the password dialog opens or reopens, and hide it on submit. Tapping the password field reopens it after a manual Hide. - Route Chandra Remote text commits (including Enter, Tab, and Backspace) into the password dialog while it is up. - Keymap: read hex keysyms (`0x31`, `0x20ac`, `0xffb7`) from libxkbcommon text-v1 keymaps, and accept `0x01000000`-range Unicode keysyms. - Keymap: keypad keys produce digits when NumLock (Mod2) is active. - Tests cover hex keysym parsing, NumLock keypad mapping, and the OSK/remote-text flow.
This commit is contained in:
1 parent
40c5d6722c
commit
851c39d827
5 files changed
+218
-12
No files matched your search
@@ -3,9 +3,10 @@
|
||||
/// The compositor sees keys as evdev codes; the characters they type depend on the keyboard
|
||||
/// layout, and a password typed on the wrong layout is the wrong password. So the auth dialog reads
|
||||
/// the xkb keymap (text format v1, what the host hands `WaylandServer::set_keymap`): the keycode
|
||||
/// names (`<AE01> = 10;`) and each key's symbols per group and level (`key <AE01> { [ 1, exclam ] };`),
|
||||
/// and maps keysym names to characters (ASCII and Latin-1 names, `Uxxxx`, `0x100xxxxx`). Without a
|
||||
/// keymap (nested windows, tests) a built-in US layout is used.
|
||||
/// names (`<AE01> = 10;`) and each key's symbols per group and level (`key <AE01> { [ 1, exclam ] };`
|
||||
/// or hex keysyms like `[ 0x31, 0x21 ]`), and maps keysym names and hex keysyms (`0x20..0x7e`,
|
||||
/// `0xa0..0xff`, `0x20ac`, keypad `0xff80..0xffb9`, `Uxxxx`, `0x01000000..0x0110ffff`) to
|
||||
/// characters. Without a keymap (nested windows, tests) a built-in US layout is used.
|
||||
|
||||
///| One key's keysym names: groups, then levels.
|
||||
struct KeySyms {
|
||||
@@ -375,8 +376,8 @@ fn names() -> Map[String, Int] {
|
||||
}
|
||||
|
||||
///|
|
||||
fn hex_value(s : String) -> Int? {
|
||||
let mut v = 0
|
||||
fn hex_u32(s : String) -> UInt? {
|
||||
let mut v = 0U
|
||||
if s.length() == 0 || s.length() > 8 {
|
||||
return None
|
||||
}
|
||||
@@ -390,7 +391,7 @@ fn hex_value(s : String) -> Int? {
|
||||
} else {
|
||||
return None
|
||||
}
|
||||
v = v * 16 + d
|
||||
v = v * 16U + d.reinterpret_as_uint()
|
||||
}
|
||||
Some(v)
|
||||
}
|
||||
@@ -401,10 +402,36 @@ pub fn keysym_char(name : String) -> Char? {
|
||||
Some(cp) => return Some(Int::unsafe_to_char(cp))
|
||||
None => ()
|
||||
}
|
||||
let cp = if name.length() >= 5 && name.has_prefix("U") {
|
||||
hex_value(name[1:].to_string())
|
||||
} else if (name.length() == 9 || name.length() == 10) && name.has_prefix("0x100") {
|
||||
hex_value(name[5:].to_string())
|
||||
let cp : Int? = if name.length() >= 5 && name.has_prefix("U") {
|
||||
match hex_u32(name[1:].to_string()) {
|
||||
Some(v) if v < 0x110000U => Some(v.reinterpret_as_int())
|
||||
_ => None
|
||||
}
|
||||
} else if name.length() >= 3 && (name.has_prefix("0x") || name.has_prefix("0X")) {
|
||||
match hex_u32(name[2:].to_string()) {
|
||||
Some(ks) =>
|
||||
if (ks >= 0x20U && ks <= 0x7eU) || (ks >= 0xa0U && ks <= 0xffU) {
|
||||
Some(ks.reinterpret_as_int())
|
||||
} else if ks >= 0x01000000U && ks <= 0x0110ffffU {
|
||||
Some((ks - 0x01000000U).reinterpret_as_int())
|
||||
} else if ks == 0x20acU {
|
||||
Some(0x20ac)
|
||||
} else if ks >= 0xffb0U && ks <= 0xffb9U {
|
||||
Some(0x30 + (ks - 0xffb0U).reinterpret_as_int())
|
||||
} else {
|
||||
match ks {
|
||||
0xffaeU => Some(0x2e)
|
||||
0xffabU => Some(0x2b)
|
||||
0xffadU => Some(0x2d)
|
||||
0xffaaU => Some(0x2a)
|
||||
0xffafU => Some(0x2f)
|
||||
0xff80U => Some(0x20)
|
||||
0xffacU => Some(0x2c)
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
None => None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -415,7 +442,7 @@ pub fn keysym_char(name : String) -> Char? {
|
||||
}
|
||||
}
|
||||
|
||||
///| Modifier bits of an xkb state (wl_keyboard.modifiers): Shift, Lock (Caps), Mod5 (AltGr).
|
||||
///| Modifier bits of an xkb state (wl_keyboard.modifiers): Shift, Lock (Caps), Ctrl, Alt, NumLock (Mod2), Mod5 (AltGr).
|
||||
pub let mask_shift : UInt = 1
|
||||
|
||||
///|
|
||||
@@ -427,6 +454,9 @@ pub let mask_ctrl : UInt = 4
|
||||
///|
|
||||
pub let mask_alt : UInt = 8
|
||||
|
||||
///|
|
||||
pub let mask_numlock : UInt = 0x10
|
||||
|
||||
///|
|
||||
pub let mask_altgr : UInt = 0x80
|
||||
|
||||
@@ -473,6 +503,12 @@ pub fn Keymap::char_for(self : Keymap, code : UInt, mods : UInt, group : UInt) -
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
// Keypad keys (evdev KP7..KPDL) flip between navigation and digits when NumLock is active.
|
||||
if code >= 71U && code <= 83U && (mods & mask_numlock) != 0U {
|
||||
if at(base) is None && at(base + 1) is Some(_) {
|
||||
level = base + (if shift { 0 } else { 1 })
|
||||
}
|
||||
}
|
||||
at(level)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user