1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::translate::*;
use std::fmt;

glib::wrapper! {
    ///
    ///
    /// # Implements
    ///
    /// [`trait@gdk::prelude::KeymapExt`]
    #[doc(alias = "GdkX11Keymap")]
    pub struct X11Keymap(Object<ffi::GdkX11Keymap, ffi::GdkX11KeymapClass>) @extends gdk::Keymap;

    match fn {
        type_ => || ffi::gdk_x11_keymap_get_type(),
    }
}

impl X11Keymap {
    /// Extracts the group from the state field sent in an X Key event.
    /// This is only needed for code processing raw X events, since `GdkEventKey`
    /// directly includes an is_modifier field.
    /// ## `state`
    /// raw state returned from X
    ///
    /// # Returns
    ///
    /// the index of the active keyboard group for the event
    #[doc(alias = "gdk_x11_keymap_get_group_for_state")]
    #[doc(alias = "get_group_for_state")]
    pub fn group_for_state(&self, state: u32) -> i32 {
        unsafe { ffi::gdk_x11_keymap_get_group_for_state(self.to_glib_none().0, state) }
    }

    /// Determines whether a particular key code represents a key that
    /// is a modifier. That is, it’s a key that normally just affects
    /// the keyboard state and the behavior of other keys rather than
    /// producing a direct effect itself. This is only needed for code
    /// processing raw X events, since `GdkEventKey` directly includes
    /// an is_modifier field.
    /// ## `keycode`
    /// the hardware keycode from a key event
    ///
    /// # Returns
    ///
    /// [`true`] if the hardware keycode is a modifier key
    #[doc(alias = "gdk_x11_keymap_key_is_modifier")]
    pub fn key_is_modifier(&self, keycode: u32) -> bool {
        unsafe {
            from_glib(ffi::gdk_x11_keymap_key_is_modifier(
                self.to_glib_none().0,
                keycode,
            ))
        }
    }
}

impl fmt::Display for X11Keymap {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("X11Keymap")
    }
}