From 781427a74ca30fd18a4754d5e7773d4c47f83a4c Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Tue, 24 Oct 2023 17:40:28 +0200 Subject: [PATCH] focus: Restore nested popup grabs --- src/shell/focus/mod.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/shell/focus/mod.rs b/src/shell/focus/mod.rs index 1e4b588d..16e9bdad 100644 --- a/src/shell/focus/mod.rs +++ b/src/shell/focus/mod.rs @@ -280,6 +280,31 @@ impl Common { } }; } else { + if let KeyboardFocusTarget::Popup(_) = target { + if let Some(popup_grab) = seat + .user_data() + .get::() + .and_then(|x| x.take()) + { + if !popup_grab.has_ended() { + if let Some(new) = popup_grab.current_grab() { + trace!("restore focus to previous popup grab"); + if let Some(keyboard) = seat.get_keyboard() { + keyboard.set_focus( + state, + Some(new.clone()), + SERIAL_COUNTER.next_serial(), + ); + } + ActiveFocus::set(&seat, Some(new)); + seat.user_data() + .get_or_insert::(PopupGrabData::default) + .set(Some(popup_grab)); + continue; + } + } + } + } trace!("Surface dead, focus fixup"); } } else {