pub struct Keysym(/* private fields */);Expand description
An xkb keysym.
§From xkb
A number used to represent the symbols generated from a key on a keyboard.
A key, represented by a keycode, may generate different symbols according to keyboard state. For example, on a QWERTY keyboard, pressing the key labled <A> generates the symbol ‘a’. If the Shift key is held, it generates the symbol ‘A’. If a different layout is used, say Greek, it generates the symbol ‘α’. And so on.
Each such symbol is represented by a keysym. Note that keysyms are somewhat more general, in that they can also represent some “function”, such as “Left” or “Right” for the arrow keys. For more information, see: http://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#keysym_encoding
Specifically named keysyms can be found in the
xkbcommon/xkbcommon-keysyms.h header file. Their name does not include
the XKB_KEY_ prefix.
Besides those, any Unicode/ISO 10646 character in the range U0100 to
U10FFFF can be represented by a keysym value in the range 0x01000100 to
0x0110FFFF. The name of Unicode keysyms is “U
The name of other unnamed keysyms is the hexadecimal representation of their value, e.g. “0xabcd1234”. Keysym names are case-sensitive.
Implementations§
Source§impl Keysym
impl Keysym
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Whether this keysym is a valid keysym.
This checks whether the Keysym’s value isn’t 0 or 0xffffffff.
Tested on libxkbcommon 0.5.0-1, keysyms less than 0x20000000
stopped having meaningful names (.get_name() returned None).
§Validity
If a call to Keysym::from_name(some_name) returns a Some(named_sym)
, named_sym.is_valid() will return true.
In general, whenever a Keysym sym passes sym.is_valid(),
sym.get_name() will be a Some (for keysyms less than 0x20000000).
In addition, if sym.get_name() is a Some(name),
Keysym::from_name(name) will also return a valid Keysym.
§Examples
use rustwlc::xkb::Keysym;
let sym = Keysym::from(0x41); // Something
assert!(sym.is_valid());Sourcepub fn is_invalid(&self) -> bool
pub fn is_invalid(&self) -> bool
Whether a Keysym is invalid.
See is_valid().
Sourcepub fn from_name(name: String, flags: NameFlags) -> Option<Keysym>
pub fn from_name(name: String, flags: NameFlags) -> Option<Keysym>
Gets the Keysym for the given name.
§Arguments
name: The name of a keysym. See docs for get_name.
This function will accept any name returned by that function.
flags: A set of flags controlling how the search is done. If the KeyboardFlags::CaseInsensitive flag is used and two keysym names differ only by case, then the lower-case keysym is returned. For instance, for KEY_a and KEY_A, this function would return KEY_a for the case-insensitive search. If this functionality is needed, it is recommended to first call this function without this flag, and if that fails, only then to try with this flag, while possibly warning the user that they have misspelled the name, and might get wrong results.
returns: The keysym. If the name is invalid, returns None.
§Examples
use rustwlc::xkb::{Keysym, NameFlags};
let key_match_a = Keysym::from_name("a".to_string(), NameFlags::None);
assert!(key_match_a.is_some());
let key_a = key_match_a.unwrap();
assert!(key_a.is_valid());