// SPDX-License-Identifier: LGPL-2.1-only // Copyright (C) 2026 Liberux Labs, S. L. use crate::app::App; use crate::event_loop::{ AppData, SurfaceFocus }; use crate::Keysym; use crate::platform::Platform; use super::super::event::KeyInput; impl AppData { /// What a key does to the focused widget or the app, shared by a /// press, the runtime's repeat timer, the platform's own repeat and /// the built-in on-screen keyboard. pub( crate ) fn dispatch_key( &mut self, focus: SurfaceFocus, event: KeyInput ) { match event.keysym { Keysym::BackSpace => self.handle_key_backspace( focus, &event ), Keysym::Delete => self.handle_key_delete( focus, &event ), Keysym::Return | Keysym::KP_Enter => self.handle_key_return( focus, &event ), Keysym::Down | Keysym::Up => self.handle_key_arrow_vertical( focus, &event ), Keysym::Left | Keysym::Right => self.handle_key_arrow_horizontal( focus, &event ), Keysym::Home => self.handle_key_home( focus ), Keysym::End => self.handle_key_end( focus ), Keysym::a | Keysym::A if self.ctrl_pressed => self.handle_key_ctrl_a( focus ), Keysym::c | Keysym::C if self.ctrl_pressed => self.handle_key_ctrl_c( focus ), Keysym::x | Keysym::X if self.ctrl_pressed => self.handle_key_ctrl_x( focus ), Keysym::v | Keysym::V if self.ctrl_pressed => self.handle_key_ctrl_v( focus ), Keysym::Tab | Keysym::ISO_Left_Tab => self.handle_key_tab( focus, &event ), Keysym::Escape => self.handle_key_escape( focus, &event ), Keysym::XF86_Back => self.handle_back( focus ), Keysym::space => self.handle_key_space( focus, &event ), _ => self.handle_key_default( focus, &event ), } self.surface_mut( focus ).request_redraw(); } }