From a8bbd1e35c9def37c15ea801c180a783512236e1 Mon Sep 17 00:00:00 2001 From: "Pedro M. de Echanove Pasquin" Date: Tue, 19 May 2026 21:40:20 +0200 Subject: [PATCH] =?UTF-8?q?input/keyboard:=20fall=20through=20to=20App::on?= =?UTF-8?q?=5Fkey=20when=20the=20Enter=20dispatch=20target=20widget=20has?= =?UTF-8?q?=20no=20submit/press=20message=20`handle=5Fkey=5Freturn`=20prev?= =?UTF-8?q?iously=20routed=20`Return`=20to=20either=20the=20focused=20or?= =?UTF-8?q?=20hovered=20widget's=20submit/press=20message=20and,=20only=20?= =?UTF-8?q?when=20neither=20index=20existed,=20fell=20through=20to=20`app.?= =?UTF-8?q?on=5Fkey=5Fwith=5Fmodifiers`.=20If=20a=20stale=20`hovered=5Fidx?= =?UTF-8?q?`=20(left=20over=20from=20a=20prior=20screen)=20pointed=20at=20?= =?UTF-8?q?a=20widget=20that=20exists=20in=20the=20new=20`widget=5Frects`?= =?UTF-8?q?=20but=20exposes=20no=20submit=20or=20press=20handler,=20`targe?= =?UTF-8?q?t.is=5Fsome()`=20was=20true=20and=20the=20message-less=20dispat?= =?UTF-8?q?ch=20silently=20swallowed=20the=20key=20=E2=80=94=20the=20`else?= =?UTF-8?q?`=20branch=20never=20ran=20and=20`App::on=5Fkey`=20never=20saw?= =?UTF-8?q?=20the=20keysym.=20This=20manifested=20in=20the=20eydos-loginma?= =?UTF-8?q?nager=20greeter=20as=20`Enter`=20on=20the=20Lock=20screen=20fai?= =?UTF-8?q?ling=20to=20fire=20`Message::Unlock`=20after=20a=20pause/resume?= =?UTF-8?q?=20cycle,=20until=20the=20user=20clicked=20something=20to=20ref?= =?UTF-8?q?resh=20`hovered=5Fidx`.=20Track=20whether=20the=20widget=20path?= =?UTF-8?q?=20actually=20pushed=20a=20message=20and,=20when=20it=20didn't,?= =?UTF-8?q?=20fall=20through=20to=20the=20app-level=20handler=20so=20the?= =?UTF-8?q?=20`Return`=20keysym=20still=20gets=20a=20chance=20to=20be=20in?= =?UTF-8?q?terpreted=20by=20the=20application's=20`on=5Fkey`.=20No=20behav?= =?UTF-8?q?iour=20change=20when=20the=20focused/hovered=20widget=20does=20?= =?UTF-8?q?provide=20a=20`submit=5Fmsg`=20or=20`press=5Fmsg`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/input/keyboard/mod.rs | 4 ++++ src/input/keyboard/text_keys.rs | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/input/keyboard/mod.rs b/src/input/keyboard/mod.rs index a3f35cf..5ebeded 100644 --- a/src/input/keyboard/mod.rs +++ b/src/input/keyboard/mod.rs @@ -45,6 +45,8 @@ impl KeyboardHandler for AppData ) { 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 KeyboardHandler for AppData _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 KeyboardHandler for AppData 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. diff --git a/src/input/keyboard/text_keys.rs b/src/input/keyboard/text_keys.rs index b7254a2..05cde38 100644 --- a/src/input/keyboard/text_keys.rs +++ b/src/input/keyboard/text_keys.rs @@ -54,6 +54,7 @@ impl AppData 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 AppData 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 ); + } } } }