pub fn input<T, F>(
        &self,
        keycode: u32,
        state: KeyState,
        serial: Serial,
        time: u32,
        filter: F,
    ) -> Option<T>
    where
        F: FnOnce(&ModifiersState, KeysymHandle<'_>) -> FilterResult<T>,
    {
        trace!(self.arc.logger, "Handling keystroke"; "keycode" => keycode, "state" => format_args!("{:?}", state));
        let mut guard = self.arc.internal.borrow_mut();
        let mods_changed = guard.key_input(keycode, state);
        let handle = KeysymHandle {
            // Offset the keycode by 8, as the evdev XKB rules reflect X's
            // broken keycode system, which starts at 8.
            keycode: keycode + 8,
            state: &guard.state,
            keymap: &guard.keymap,
        };

        trace!(self.arc.logger, "Calling input filter";
            "mods_state" => format_args!("{:?}", guard.mods_state), "sym" => xkb::keysym_get_name(handle.modified_sym())
        );

        if let FilterResult::Intercept(val) = filter(&guard.mods_state, handle) {
            // the filter returned false, we do not forward to client
            trace!(self.arc.logger, "Input was intercepted by filter");
            return Some(val);
        }

        // forward to client if no keybinding is triggered
        let modifiers = if mods_changed {
            Some(guard.serialize_modifiers())
        } else {
            None
        };
        let wl_state = match state {
            KeyState::Pressed => WlKeyState::Pressed,
            KeyState::Released => WlKeyState::Released,
        };
        guard.with_grab(
            move |mut handle, grab| {
                grab.input(&mut handle, keycode, wl_state, modifiers, serial, time);
            },
            self.arc.logger.clone(),
        );
        if guard.focus.is_some() {
            trace!(self.arc.logger, "Input forwarded to client");
        } else {
            trace!(self.arc.logger, "No client currently focused");
        }

        None
    }
/// Handle a keystroke
///
/// All keystrokes from the input backend should be fed _in order_ to this method of the
/// keyboard handler. It will internally track the state of the keymap.
///
/// The `filter` argument is expected to be a closure which will peek at the generated input
/// as interpreted by the keymap before it is forwarded to the focused client. If this closure
/// returns [`FilterResult::Forward`], the input will not be sent to the client. If it returns
/// [`FilterResult::Intercept`] a value can be passed to be returned by the whole function.
/// This mechanism can be used to implement compositor-level key bindings for example.
///
/// The module [`crate::wayland::seat::keysyms`] exposes definitions of all possible keysyms
/// to be compared against. This includes non-character keysyms, such as XF86 special keys.
Handle a keystroke
All keystrokes from the input backend should be fed _in order_ to this method of the
keyboard handler. It will internally track the state of the keymap.

The `filter` argument is expected to be a closure which will peek at the generated input
as interpreted by the keymap before it is forwarded to the focused client. If this closure
returns [`FilterResult::Forward`], the input will not be sent to the client. If it returns
[`FilterResult::Intercept`] a value can be passed to be returned by the whole function.
This mechanism can be used to implement compositor-level key bindings for example.


Handle a keystroke All keystrokes from the input backend should be fed _in order_ to this method of the keyboard handler . It will internally track the state of the keymap . The ` filter ` argument is expected to be a closure which will peek at the generated input as interpreted by the keymap before it is forwarded to the focused client . If this closure returns [ ` FilterResult :: Forward ` ] the input will not be sent to the client . If it returns [ ` FilterResult :: Intercept ` ] a value can be passed to be returned by the whole function . This mechanism can be used to implement compositor - level key bindings for example .
pub fn input<T, F>(
        &self,
        keycode: u32,
        state: KeyState,
        serial: Serial,
        time: u32,
        filter: F,
    ) -> Option<T>
    where
        F: FnOnce(&ModifiersState, KeysymHandle<'_>) -> FilterResult<T>,
    {
        trace!(self.arc.logger, "Handling keystroke"; "keycode" => keycode, "state" => format_args!("{:?}", state));
        let mut guard = self.arc.internal.borrow_mut();
        let mods_changed = guard.key_input(keycode, state);
        let handle = KeysymHandle {
            // Offset the keycode by 8, as the evdev XKB rules reflect X's
            // broken keycode system, which starts at 8.
            keycode: keycode + 8,
            state: &guard.state,
            keymap: &guard.keymap,
        };
        trace!(self.arc.logger, "Calling input filter";
            "mods_state" => format_args!("{:?}", guard.mods_state), "sym" => xkb::keysym_get_name(handle.modified_sym())
        );
        if let FilterResult::Intercept(val) = filter(&guard.mods_state, handle) {
            // the filter returned false, we do not forward to client
            trace!(self.arc.logger, "Input was intercepted by filter");
            return Some(val);
        }
        // forward to client if no keybinding is triggered
        let modifiers = if mods_changed {
            Some(guard.serialize_modifiers())
        } else {
            None
        };
        let wl_state = match state {
            KeyState::Pressed => WlKeyState::Pressed,
            KeyState::Released => WlKeyState::Released,
        };
        guard.with_grab(
            move |mut handle, grab| {
                grab.input(&mut handle, keycode, wl_state, modifiers, serial, time);
            },
            self.arc.logger.clone(),
        );
        if guard.focus.is_some() {
            trace!(self.arc.logger, "Input forwarded to client");
        } else {
            trace!(self.arc.logger, "No client currently focused");
        }
        None
    }
pub fn input < T , F > ( & self , keycode : u32 , state : KeyState , serial : Serial , time : u32 , filter : F , ) -> Option < T > where F : FnOnce ( & ModifiersState , KeysymHandle < ' _ > ) -> FilterResult < T > , { trace ! ( self arc logger " " " " keycode " " format_args ( " " state ) ) ; let mut guard = self . arc . internal . borrow_mut ( ) ; let mods_changed = guard . key_input ( keycode , state ) ; let handle = KeysymHandle { // Offset the keycode by 8, as the evdev XKB rules reflect X's // broken keycode system, which starts at 8. keycode : keycode + 8 , state : & guard . state , keymap : & guard . keymap , } ; trace ! ( self arc logger " " " " format_args ( " " guard mods_state ) " " xkb keysym_get_name ( handle modified_sym ( ) ) ) ; if let FilterResult :: Intercept ( val ) = filter ( & guard . mods_state , handle ) { // the filter returned false, we do not forward to client trace ! ( self arc logger " " ) ; return Some ( val ) ; } // forward to client if no keybinding is triggered let modifiers = if mods_changed { Some ( guard . serialize_modifiers ( ) ) } else { None } ; let wl_state = match state { KeyState :: Pressed => WlKeyState :: Pressed , KeyState :: Released => WlKeyState :: Released , } ; guard . with_grab ( move | mut handle , grab | { grab . input ( & mut handle , keycode , wl_state , modifiers , serial , time ) ; } , self . arc . logger . clone ( ) , ) ; if guard . focus . is_some ( ) { trace ! ( self arc logger " " ) ; } else { trace ! ( self arc logger " " ) ; } None }
Handle a keystroke
All keystrokes from the input backend should be fed _in order_ to this method of the
keyboard handler.
Handle a keystroke All keystrokes from the input backend should be fed _in order_ to this method of the keyboard handler .
&self
keycode
u32
state
KeyState
serial
Serial
time
u32
filter
F
&self
keycode
u32
state
KeyState
serial
Serial
time
u32
filter
F