shell: disable WindowUI detection if constraint is active

This commit is contained in:
Skygrango 2026-05-27 14:17:01 +08:00 committed by Ian Douglas Scott
parent 208c2128cd
commit 203cad8cbd
8 changed files with 69 additions and 24 deletions

View file

@ -269,10 +269,13 @@ impl CosmicMapped {
&self,
relative_pos: Point<f64, Logical>,
surface_type: WindowSurfaceType,
seat: &Seat<State>,
) -> Option<(PointerFocusTarget, Point<f64, Logical>)> {
match &self.element {
CosmicMappedInternal::Stack(stack) => stack.focus_under(relative_pos, surface_type),
CosmicMappedInternal::Window(window) => window.focus_under(relative_pos, surface_type),
CosmicMappedInternal::Window(window) => {
window.focus_under(relative_pos, surface_type, Some(seat))
}
_ => unreachable!(),
}
}

View file

@ -57,7 +57,7 @@ use smithay::{
Buffer, IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial, Size, Transform,
user_data::UserDataMap,
},
wayland::seat::WaylandFocus,
wayland::{pointer_constraints::with_pointer_constraint, seat::WaylandFocus},
};
use std::{
borrow::Cow,
@ -274,12 +274,25 @@ impl CosmicWindow {
&self,
mut relative_pos: Point<f64, Logical>,
surface_type: WindowSurfaceType,
seat: Option<&Seat<State>>,
) -> Option<(PointerFocusTarget, Point<f64, Logical>)> {
let has_constraint = if let Some(seat) = seat
&& let Some(pointer) = seat.get_pointer()
&& let Some(surface) = self.wl_surface()
&& with_pointer_constraint(&surface, &pointer, |constraint| {
constraint.is_some_and(|c| c.is_active())
}) {
true
} else {
false
};
self.0.with_program(|p| {
let mut offset = Point::from((0., 0.));
let mut window_ui = None;
let has_ssd = p.has_ssd(false);
if (has_ssd || p.has_tiled_state())
if (!has_constraint && (has_ssd || p.has_tiled_state()))
&& surface_type.contains(WindowSurfaceType::TOPLEVEL)
{
let geo = p.window.geometry();
@ -877,7 +890,8 @@ impl SpaceElement for CosmicWindow {
})
}
fn is_in_input_region(&self, point: &Point<f64, Logical>) -> bool {
self.focus_under(*point, WindowSurfaceType::ALL).is_some()
self.focus_under(*point, WindowSurfaceType::ALL, None)
.is_some()
}
fn set_activate(&self, activated: bool) {
if self

View file

@ -953,6 +953,7 @@ impl Drop for MoveGrab {
if let Some((target, offset)) = mapped.focus_under(
current_location - position.as_logical().to_f64(),
WindowSurfaceType::ALL,
&seat,
) {
pointer.motion(
state,

View file

@ -731,7 +731,11 @@ impl FloatingLayout {
self.space.element_geometry(elem).map(RectExt::as_local)
}
pub fn popup_element_under(&self, location: Point<f64, Local>) -> Option<KeyboardFocusTarget> {
pub fn popup_element_under(
&self,
location: Point<f64, Local>,
seat: &Seat<State>,
) -> Option<KeyboardFocusTarget> {
self.space
.elements()
.rev()
@ -752,6 +756,7 @@ impl FloatingLayout {
if e.focus_under(
point.as_logical(),
WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE,
seat,
)
.is_some()
{
@ -765,6 +770,7 @@ impl FloatingLayout {
pub fn toplevel_element_under(
&self,
location: Point<f64, Local>,
seat: &Seat<State>,
) -> Option<KeyboardFocusTarget> {
self.space
.elements()
@ -786,6 +792,7 @@ impl FloatingLayout {
if e.focus_under(
point.as_logical(),
WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE,
seat,
)
.is_some()
{
@ -799,6 +806,7 @@ impl FloatingLayout {
pub fn popup_surface_under(
&self,
location: Point<f64, Local>,
seat: &Seat<State>,
) -> Option<(PointerFocusTarget, Point<f64, Local>)> {
self.space
.elements()
@ -820,6 +828,7 @@ impl FloatingLayout {
e.focus_under(
point.as_logical(),
WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE,
seat,
)
.map(|(surface, surface_offset)| {
(surface, render_location + surface_offset.as_local())
@ -830,6 +839,7 @@ impl FloatingLayout {
pub fn toplevel_surface_under(
&self,
location: Point<f64, Local>,
seat: &Seat<State>,
) -> Option<(PointerFocusTarget, Point<f64, Local>)> {
self.space
.elements()
@ -851,6 +861,7 @@ impl FloatingLayout {
e.focus_under(
point.as_logical(),
WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE,
seat,
)
.map(|(surface, surface_offset)| {
(surface, render_location + surface_offset.as_local())

View file

@ -3145,6 +3145,7 @@ impl TilingLayout {
pub fn popup_element_under(
&self,
location_f64: Point<f64, Local>,
seat: &Seat<State>,
) -> Option<KeyboardFocusTarget> {
let location = location_f64.to_i32_round();
@ -3157,6 +3158,7 @@ impl TilingLayout {
.focus_under(
(location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64(),
WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE,
seat,
)
.is_some()
{
@ -3170,6 +3172,7 @@ impl TilingLayout {
pub fn toplevel_element_under(
&self,
location_f64: Point<f64, Local>,
seat: &Seat<State>,
) -> Option<KeyboardFocusTarget> {
let location = location_f64.to_i32_round();
@ -3182,6 +3185,7 @@ impl TilingLayout {
.focus_under(
(location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64(),
WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE,
seat,
)
.is_some()
{
@ -3196,6 +3200,7 @@ impl TilingLayout {
&self,
location_f64: Point<f64, Local>,
overview: OverviewMode,
seat: &Seat<State>,
) -> Option<(PointerFocusTarget, Point<f64, Local>)> {
let location = location_f64.to_i32_round();
@ -3210,6 +3215,7 @@ impl TilingLayout {
if let Some((target, surface_offset)) = mapped.focus_under(
(location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64(),
WindowSurfaceType::POPUP | WindowSurfaceType::SUBSURFACE,
seat,
) {
return Some((
target,
@ -3227,6 +3233,7 @@ impl TilingLayout {
&self,
location_f64: Point<f64, Local>,
overview: OverviewMode,
seat: &Seat<State>,
) -> Option<(PointerFocusTarget, Point<f64, Local>)> {
let tree = &self.queue.trees.back().unwrap().0;
let root = tree.root_node_id()?;
@ -3243,6 +3250,7 @@ impl TilingLayout {
if let Some((target, surface_offset)) = mapped.focus_under(
(location_f64 - geo.loc.to_f64()).as_logical() + mapped.geometry().loc.to_f64(),
WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE,
seat,
) {
return Some((
target,
@ -3293,6 +3301,7 @@ impl TilingLayout {
.focus_under(
test_point,
WindowSurfaceType::TOPLEVEL | WindowSurfaceType::SUBSURFACE,
seat,
)
.map(|(surface, surface_offset)| {
(

View file

@ -3714,7 +3714,11 @@ impl Shell {
if old_mapped.is_maximized(false) {
new_mapped.set_maximized(false);
}
start_data.set_focus(new_mapped.focus_under((0., 0.).into(), WindowSurfaceType::ALL));
start_data.set_focus(new_mapped.focus_under(
(0., 0.).into(),
WindowSurfaceType::ALL,
seat,
));
new_mapped
} else {
old_mapped.clone()
@ -4185,7 +4189,7 @@ impl Shell {
let element_offset = (new_loc - geometry.loc).as_logical();
let focus = mapped
.focus_under(element_offset.to_f64(), WindowSurfaceType::ALL)
.focus_under(element_offset.to_f64(), WindowSurfaceType::ALL, seat)
.map(|(target, surface_offset)| (target, (surface_offset + element_offset.to_f64())));
start_data.set_location(new_loc.as_logical().to_f64());
start_data.set_focus(focus.clone());

View file

@ -791,8 +791,8 @@ impl Workspace {
}
self.floating_layer
.popup_element_under(location)
.or_else(|| self.tiling_layer.popup_element_under(location))
.popup_element_under(location, seat)
.or_else(|| self.tiling_layer.popup_element_under(location, seat))
.or_else(|| {
if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_)))
&& let Some(fullscreen) = self.fullscreen.as_ref()
@ -841,8 +841,8 @@ impl Workspace {
}
self.floating_layer
.toplevel_element_under(location)
.or_else(|| self.tiling_layer.toplevel_element_under(location))
.toplevel_element_under(location, seat)
.or_else(|| self.tiling_layer.toplevel_element_under(location, seat))
.or_else(|| {
if last_focused.is_none_or(|t| !matches!(t, FocusTarget::Fullscreen(_)))
&& let Some(fullscreen) = self.fullscreen.as_ref()
@ -895,8 +895,11 @@ impl Workspace {
.as_ref()
.filter(|f| last_focused.is_some_and(|t| t == &f.surface))
.and_then(check_fullscreen)
.or_else(|| self.floating_layer.popup_surface_under(location))
.or_else(|| self.tiling_layer.popup_surface_under(location, overview))
.or_else(|| self.floating_layer.popup_surface_under(location, seat))
.or_else(|| {
self.tiling_layer
.popup_surface_under(location, overview, seat)
})
.or_else(|| {
self.fullscreen
.as_ref()
@ -941,8 +944,11 @@ impl Workspace {
.as_ref()
.filter(|f| last_focused.is_some_and(|t| t == &f.surface))
.and_then(check_fullscreen)
.or_else(|| self.floating_layer.toplevel_surface_under(location))
.or_else(|| self.tiling_layer.toplevel_surface_under(location, overview))
.or_else(|| self.floating_layer.toplevel_surface_under(location, seat))
.or_else(|| {
self.tiling_layer
.toplevel_surface_under(location, overview, seat)
})
.or_else(|| {
self.fullscreen
.as_ref()