ltk/input/keyboard/
mod.rsuse crate::app::App;
use crate::event_loop::{ AppData, SurfaceFocus };
use crate::Keysym;
use crate::platform::Platform;
use super::event::KeyInput;
pub( super ) mod back;
pub( super ) mod dispatch;
pub( super ) mod text_keys;
pub( super ) mod shortcuts;
pub( super ) mod nav;
impl<A: App, P: Platform> AppData<A, P>
{
pub( crate ) fn keyboard_enter( &mut self, focus: SurfaceFocus )
{
self.keyboard_focus = focus;
self.surface_mut( focus ).request_redraw();
if let Some( ref mut a ) = self.a11y { a.set_window_focus( true ); }
}
pub( crate ) fn keyboard_leave( &mut self )
{
self.stop_key_repeat();
self.keyboard_focus = SurfaceFocus::Main;
self.app.on_keyboard_leave();
if let Some( ref mut a ) = self.a11y { a.set_window_focus( false ); }
}
pub( crate ) fn key_press( &mut self, key: KeyInput )
{
let focus = self.keyboard_focus;
if key.keysym != Keysym::XF86_Back
{
let raw = key.raw( true, self.ctrl_pressed, self.shift_pressed, self.alt_pressed );
self.app.on_raw_key_event( &raw );
}
self.stop_key_repeat();
if key.keysym != Keysym::XF86_Back && self.app.claims_keyboard() { return; }
self.dispatch_key( focus, key.clone() );
self.start_key_repeat( focus, key );
}
pub( crate ) fn key_release( &mut self, key: &KeyInput )
{
if key.keysym != Keysym::XF86_Back
{
let raw = key.raw( false, self.ctrl_pressed, self.shift_pressed, self.alt_pressed );
self.app.on_raw_key_event( &raw );
}
if self.key_repeat.as_ref().is_some_and( |state| state.event.keysym == key.keysym )
{
self.stop_key_repeat();
}
}
pub( crate ) fn key_repeated( &mut self, key: KeyInput )
{
self.stop_key_repeat();
if key.keysym != Keysym::XF86_Back && self.app.claims_keyboard() { return; }
let focus = self.keyboard_focus;
self.dispatch_key( focus, key );
}
pub( crate ) fn modifiers_changed( &mut self, ctrl: bool, shift: bool, alt: bool )
{
self.shift_pressed = shift;
self.ctrl_pressed = ctrl;
self.alt_pressed = alt;
self.app.on_modifiers( ctrl, shift, alt );
}
pub( crate ) fn set_repeat_info( &mut self, rate: u32, delay: u32 )
{
self.compositor_repeat_rate = rate;
self.compositor_repeat_delay = delay;
if rate == 0 { self.stop_key_repeat(); }
}
}