Keysym

Struct Keysym 

Source
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”, e.g. “UA1B2”.

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

Source

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());
Source

pub fn is_invalid(&self) -> bool

Whether a Keysym is invalid.

See is_valid().

Source

pub fn get_code(&self) -> u32

Gets the Keysym as a u32.

Source

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());
Source

pub fn get_name(&self) -> Option<String>

Gets name name of the keysym.

§Examples
use rustwlc::xkb::{Keysym, NameFlags};

let key = Keysym::from_name("a".to_string(), NameFlags::None).unwrap();

assert_eq!(key.get_name(), Some("a".to_string()));
Source

pub fn to_utf8(&self) -> Option<String>

Gets the Unicode/UTF8 representation of this keysym.

Source

pub fn to_utf32(&self) -> u32

Gets the Unicode/UTF32 representation of this keysym.

Trait Implementations§

Source§

impl Clone for Keysym

Source§

fn clone(&self) -> Keysym

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Keysym

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<u32> for Keysym

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl Hash for Keysym

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Keysym

Source§

fn eq(&self, other: &Keysym) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Keysym

Source§

impl StructuralPartialEq for Keysym

Auto Trait Implementations§

§

impl Freeze for Keysym

§

impl RefUnwindSafe for Keysym

§

impl Send for Keysym

§

impl Sync for Keysym

§

impl Unpin for Keysym

§

impl UnwindSafe for Keysym

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.