forge
Explore
Log in

Don't you dare go Hollow

skip keyboard focus for layer shell surfaces not...

Browse files at this commit

b16d7abb35ec35dba77de919ef56b9de5c4e9cafChristian MeisslParent: 2f17a30
...requesting keyboard interactivity
src/handlers/xdg_shell.rsmodified+20 -3
@@ -360,6 +360,17 @@ impl XdgShellHandler for State {
360 let keyboard = seat.get_keyboard().unwrap();360 let keyboard = seat.get_keyboard().unwrap();
361 let pointer = seat.get_pointer().unwrap();361 let pointer = seat.get_pointer().unwrap();
362 362
363+ let can_receive_keyboard_focus = self
364+ .niri
365+ .layout
366+ .active_output()
367+ .and_then(|output| {
368+ layer_map_for_output(output)
369+ .layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)
370+ .map(|layer_surface| layer_surface.can_receive_keyboard_focus())
371+ })
372+ .unwrap_or(true);
373+
363 let keyboard_grab_mismatches = keyboard.is_grabbed()374 let keyboard_grab_mismatches = keyboard.is_grabbed()
364 && !(keyboard.has_grab(serial)375 && !(keyboard.has_grab(serial)
365 || grab376 || grab
@@ -368,15 +379,21 @@ impl XdgShellHandler for State {
368 let pointer_grab_mismatches = pointer.is_grabbed()379 let pointer_grab_mismatches = pointer.is_grabbed()
369 && !(pointer.has_grab(serial)380 && !(pointer.has_grab(serial)
370 || grab.previous_serial().map_or(true, |s| pointer.has_grab(s)));381 || grab.previous_serial().map_or(true, |s| pointer.has_grab(s)));
371- if keyboard_grab_mismatches || pointer_grab_mismatches {382+ if (can_receive_keyboard_focus && keyboard_grab_mismatches) || pointer_grab_mismatches {
372 grab.ungrab(PopupUngrabStrategy::All);383 grab.ungrab(PopupUngrabStrategy::All);
373 return;384 return;
374 }385 }
375 386
376 trace!("new grab for root {:?}", root);387 trace!("new grab for root {:?}", root);
377- keyboard.set_grab(self, PopupKeyboardGrab::new(&grab), serial);388+ if can_receive_keyboard_focus {
389+ keyboard.set_grab(self, PopupKeyboardGrab::new(&grab), serial);
390+ }
378 pointer.set_grab(self, PopupPointerGrab::new(&grab), serial, Focus::Keep);391 pointer.set_grab(self, PopupPointerGrab::new(&grab), serial, Focus::Keep);
379- self.niri.popup_grab = Some(PopupGrabState { root, grab });392+ self.niri.popup_grab = Some(PopupGrabState {
393+ root,
394+ grab,
395+ has_keyboard_grab: can_receive_keyboard_focus,
396+ });
380 }397 }
381 398
382 fn maximize_request(&mut self, surface: ToplevelSurface) {399 fn maximize_request(&mut self, surface: ToplevelSurface) {
src/niri.rsmodified+3 -2
@@ -409,6 +409,7 @@ pub enum RedrawState {
409 pub struct PopupGrabState {409 pub struct PopupGrabState {
410 pub root: WlSurface,410 pub root: WlSurface,
411 pub grab: PopupGrab<State>,411 pub grab: PopupGrab<State>,
412+ pub has_keyboard_grab: bool,
412 }413 }
413 414
414 // The surfaces here are always toplevel surfaces focused as far as niri's logic is concerned, even415 // The surfaces here are always toplevel surfaces focused as far as niri's logic is concerned, even
@@ -865,7 +866,7 @@ impl State {
865 let layer_grab = self.niri.popup_grab.as_ref().and_then(|g| {866 let layer_grab = self.niri.popup_grab.as_ref().and_then(|g| {
866 layers867 layers
867 .layer_for_surface(&g.root, WindowSurfaceType::TOPLEVEL)868 .layer_for_surface(&g.root, WindowSurfaceType::TOPLEVEL)
868- .map(|l| (&g.root, l.layer()))869+ .and_then(|l| l.can_receive_keyboard_focus().then(|| (&g.root, l.layer())))
869 });870 });
870 let grab_on_layer = |layer: Layer| {871 let grab_on_layer = |layer: Layer| {
871 layer_grab872 layer_grab
@@ -984,7 +985,7 @@ impl State {
984 }985 }
985 986
986 if let Some(grab) = self.niri.popup_grab.as_mut() {987 if let Some(grab) = self.niri.popup_grab.as_mut() {
987- if Some(&grab.root) != focus.surface() {988+ if grab.has_keyboard_grab && Some(&grab.root) != focus.surface() {
988 trace!(989 trace!(
989 "grab root {:?} is not the new focus {:?}, ungrabbing",990 "grab root {:?} is not the new focus {:?}, ungrabbing",
990 grab.root,991 grab.root,