input/keyboard: fall through to App::on_key when the Enter dispatch target widget has no submit/press message
`handle_key_return` previously routed `Return` to either the focused or hovered widget's submit/press message and, only when neither index existed, fell through to `app.on_key_with_modifiers`. If a stale `hovered_idx` (left over from a prior screen) pointed at a widget that exists in the new `widget_rects` but exposes no submit or press handler, `target.is_some()` was true and the message-less dispatch silently swallowed the key — the `else` branch never ran and `App::on_key` never saw the keysym. This manifested in the eydos-loginmanager greeter as `Enter` on the Lock screen failing to fire `Message::Unlock` after a pause/resume cycle, until the user clicked something to refresh `hovered_idx`. Track whether the widget path actually pushed a message and, when it didn't, fall through to the app-level handler so the `Return` keysym still gets a chance to be interpreted by the application's `on_key`. No behaviour change when the focused/hovered widget does provide a `submit_msg` or `press_msg`.
This commit is contained in:
@@ -45,6 +45,8 @@ impl<A: App> KeyboardHandler for AppData<A>
|
||||
)
|
||||
{
|
||||
let focus = self.focus_for_surface( surface ).unwrap_or( SurfaceFocus::Main );
|
||||
let _ = surface;
|
||||
eprintln!( "ltk: wl_keyboard.enter focus={:?}", focus );
|
||||
self.keyboard_focus = focus;
|
||||
self.surface_mut( focus ).request_redraw();
|
||||
if let Some( ref mut a ) = self.a11y { a.set_window_focus( true ); }
|
||||
@@ -59,6 +61,7 @@ impl<A: App> KeyboardHandler for AppData<A>
|
||||
_serial: u32,
|
||||
)
|
||||
{
|
||||
eprintln!( "ltk: wl_keyboard.leave" );
|
||||
self.stop_key_repeat();
|
||||
self.keyboard_focus = SurfaceFocus::Main;
|
||||
if let Some( ref mut a ) = self.a11y { a.set_window_focus( false ); }
|
||||
@@ -73,6 +76,7 @@ impl<A: App> KeyboardHandler for AppData<A>
|
||||
event: KeyEvent,
|
||||
)
|
||||
{
|
||||
eprintln!( "ltk: press_key keysym={:?} focus={:?}", event.keysym, self.keyboard_focus );
|
||||
let focus = self.keyboard_focus;
|
||||
// Raw observer hook (e.g. forwarding to an embedded WPE view).
|
||||
// Fires before the focus-aware dispatch.
|
||||
|
||||
@@ -54,6 +54,7 @@ impl<A: App> AppData<A>
|
||||
self.handle_text_insert( focus, "\n" );
|
||||
} else {
|
||||
let target = focused.or( self.surface( focus ).hovered_idx );
|
||||
let mut handled = false;
|
||||
if let Some( idx ) = target
|
||||
{
|
||||
let msg = find_handlers( &self.surface( focus ).widget_rects, idx )
|
||||
@@ -61,10 +62,15 @@ impl<A: App> AppData<A>
|
||||
if let Some( m ) = msg
|
||||
{
|
||||
self.pending_msgs.push( m );
|
||||
handled = true;
|
||||
}
|
||||
} else if let Some( msg ) = self.app.on_key_with_modifiers( event.keysym, self.ctrl_pressed, self.shift_pressed )
|
||||
}
|
||||
if !handled
|
||||
{
|
||||
self.pending_msgs.push( msg );
|
||||
if let Some( msg ) = self.app.on_key_with_modifiers( event.keysym, self.ctrl_pressed, self.shift_pressed )
|
||||
{
|
||||
self.pending_msgs.push( msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user