forge
Explore
Log in

Don't you dare go Hollow

Allow pop-up grabs for bottom and background layers

Browse files at this commit

8e16be9e1150fed822fd671b3faf082a9b2641c0Ivan MolodetskikhParent: 300701f
src/handlers/xdg_shell.rsmodified+20 -11
@@ -289,6 +289,7 @@ impl XdgShellHandler for State {
289 289
290 let popup = PopupKind::Xdg(surface);290 let popup = PopupKind::Xdg(surface);
291 let Ok(root) = find_popup_root_surface(&popup) else {291 let Ok(root) = find_popup_root_surface(&popup) else {
292+ trace!("ignoring popup grab because no root surface");
292 return;293 return;
293 };294 };
294 295
@@ -297,30 +298,30 @@ impl XdgShellHandler for State {
297 // keyboard focus being at the wrong place.298 // keyboard focus being at the wrong place.
298 if self.niri.is_locked() {299 if self.niri.is_locked() {
299 if Some(&root) != self.niri.lock_surface_focus().as_ref() {300 if Some(&root) != self.niri.lock_surface_focus().as_ref() {
301+ trace!("ignoring popup grab because the session is locked");
300 let _ = PopupManager::dismiss_popup(&root, &popup);302 let _ = PopupManager::dismiss_popup(&root, &popup);
301 return;303 return;
302 }304 }
303 } else if self.niri.screenshot_ui.is_open() {305 } else if self.niri.screenshot_ui.is_open() {
306+ trace!("ignoring popup grab because the screenshot UI is open");
304 let _ = PopupManager::dismiss_popup(&root, &popup);307 let _ = PopupManager::dismiss_popup(&root, &popup);
305 return;308 return;
306 } else if let Some(output) = self.niri.layout.active_output() {309 } else if let Some(output) = self.niri.layout.active_output() {
307 let layers = layer_map_for_output(output);310 let layers = layer_map_for_output(output);
308 311
309- if let Some(layer_surface) =312+ if layers
310- layers.layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)313+ .layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)
314+ .is_none()
311 {315 {
312- if !matches!(layer_surface.layer(), Layer::Overlay | Layer::Top) {316+ // This is a grab for a regular window; check that there's no layer surface with a
313- let _ = PopupManager::dismiss_popup(&root, &popup);317+ // higher input priority.
314- return;
315- }
316 318
317- // FIXME: popup grabs for on-demand bottom and background layers.
318- } else {
319 if layers.layers_on(Layer::Overlay).any(|l| {319 if layers.layers_on(Layer::Overlay).any(|l| {
320 l.cached_state().keyboard_interactivity320 l.cached_state().keyboard_interactivity
321 == wlr_layer::KeyboardInteractivity::Exclusive321 == wlr_layer::KeyboardInteractivity::Exclusive
322 || Some(l) == self.niri.layer_shell_on_demand_focus.as_ref()322 || Some(l) == self.niri.layer_shell_on_demand_focus.as_ref()
323 }) {323 }) {
324+ trace!("ignoring toplevel popup grab because the overlay layer has focus");
324 let _ = PopupManager::dismiss_popup(&root, &popup);325 let _ = PopupManager::dismiss_popup(&root, &popup);
325 return;326 return;
326 }327 }
@@ -333,28 +334,35 @@ impl XdgShellHandler for State {
333 || Some(l) == self.niri.layer_shell_on_demand_focus.as_ref()334 || Some(l) == self.niri.layer_shell_on_demand_focus.as_ref()
334 })335 })
335 {336 {
337+ trace!("ignoring toplevel popup grab because the top layer has focus");
336 let _ = PopupManager::dismiss_popup(&root, &popup);338 let _ = PopupManager::dismiss_popup(&root, &popup);
337 return;339 return;
338 }340 }
339 341
340 let layout_focus = self.niri.layout.focus();342 let layout_focus = self.niri.layout.focus();
341 if Some(&root) != layout_focus.map(|win| win.toplevel().wl_surface()) {343 if Some(&root) != layout_focus.map(|win| win.toplevel().wl_surface()) {
344+ trace!("ignoring toplevel popup grab because another window has focus");
342 let _ = PopupManager::dismiss_popup(&root, &popup);345 let _ = PopupManager::dismiss_popup(&root, &popup);
343 return;346 return;
344 }347 }
345 }348 }
346 } else {349 } else {
350+ trace!("ignoring popup grab because no output is active");
347 let _ = PopupManager::dismiss_popup(&root, &popup);351 let _ = PopupManager::dismiss_popup(&root, &popup);
348 return;352 return;
349 }353 }
350 354
351 let seat = &self.niri.seat;355 let seat = &self.niri.seat;
352- let Ok(mut grab) = self356+ let mut grab = match self
353 .niri357 .niri
354 .popups358 .popups
355 .grab_popup(root.clone(), popup, seat, serial)359 .grab_popup(root.clone(), popup, seat, serial)
356- else {360+ {
357- return;361+ Ok(grab) => grab,
362+ Err(err) => {
363+ trace!("ignoring popup grab: {err:?}");
364+ return;
365+ }
358 };366 };
359 367
360 let keyboard = seat.get_keyboard().unwrap();368 let keyboard = seat.get_keyboard().unwrap();
@@ -380,6 +388,7 @@ impl XdgShellHandler for State {
380 && !(pointer.has_grab(serial)388 && !(pointer.has_grab(serial)
381 || grab.previous_serial().map_or(true, |s| pointer.has_grab(s)));389 || grab.previous_serial().map_or(true, |s| pointer.has_grab(s)));
382 if (can_receive_keyboard_focus && keyboard_grab_mismatches) || pointer_grab_mismatches {390 if (can_receive_keyboard_focus && keyboard_grab_mismatches) || pointer_grab_mismatches {
391+ trace!("ignoring popup grab because of current grab mismatch");
383 grab.ungrab(PopupUngrabStrategy::All);392 grab.ungrab(PopupUngrabStrategy::All);
384 return;393 return;
385 }394 }
src/niri.rsmodified+2 -0
@@ -920,6 +920,8 @@ impl State {
920 // fullscreen layout window. This will need tracking in grab() to avoid handing it out920 // fullscreen layout window. This will need tracking in grab() to avoid handing it out
921 // in the first place. Or a better way to structure this code.921 // in the first place. Or a better way to structure this code.
922 surface = surface.or_else(|| grab_on_layer(Layer::Top));922 surface = surface.or_else(|| grab_on_layer(Layer::Top));
923+ surface = surface.or_else(|| grab_on_layer(Layer::Bottom));
924+ surface = surface.or_else(|| grab_on_layer(Layer::Background));
923 925
924 surface = surface.or_else(|| focus_on_layer(Layer::Overlay));926 surface = surface.or_else(|| focus_on_layer(Layer::Overlay));
925 927