wayland: implement new_constraint, remove_constraint and cursor_position_hint for PointerConstraintsHandler

new_constraint: check if the surface has pointer focus, keyboard focus, and if the pointer is within toplevel geometry or constraint region. If these conditions are met, then enable the constraint.

remove_constraint: apply last cursor position hint that saved in seat.

cursor_position_hint: save the cursor position hints provided by the client to the seat.
This commit is contained in:
Skygrango 2026-05-13 20:08:21 +08:00 committed by Ian Douglas Scott
parent 4fb7d49316
commit 208c2128cd
4 changed files with 156 additions and 42 deletions

View file

@ -737,22 +737,23 @@ impl WorkspaceSet {
surface: &WlSurface,
) -> Option<(Rectangle<i32, Local>, Point<i32, Logical>)> {
let mut root = surface.clone();
loop {
while let Some(parent) = get_parent(&root) {
while let Some(parent) = get_parent(&root) {
root = parent;
}
while smithay::wayland::compositor::get_role(&root) == Some(XDG_POPUP_ROLE) {
let parent = with_states(&root, |states| {
states
.data_map
.get::<XdgPopupSurfaceData>()
.and_then(|m| m.lock().unwrap().parent.as_ref().cloned())
});
if let Some(parent) = parent {
root = parent;
} else {
break;
}
if smithay::wayland::compositor::get_role(&root) == Some(XDG_POPUP_ROLE)
&& let Some(parent) = with_states(&root, |states| {
states
.data_map
.get::<XdgPopupSurfaceData>()
.and_then(|m| m.lock().unwrap().parent.as_ref().cloned())
})
{
root = parent;
continue;
}
break;
}
self.sticky_layer