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

@ -505,12 +505,12 @@ impl State {
let new_under = State::surface_under(pos, &output, shell)
.map(|(target, pos)| (target, pos.as_logical()));
//We should only check size, not the surface, so that we can move the mouse over the OSD in confined mode
// if new_under.as_ref().and_then(|(under, _)| under.wl_surface())
// != surface.wl_surface()
// {
// return (false, None);
// }
// TODO: We might need a solution that allows constraints to bypass the surface without affecting the constraints themselves
if new_under.as_ref().and_then(|(under, _)| under.wl_surface())
!= surface.wl_surface()
{
return (false, None);
}
match surface {
PointerFocusTarget::WlSurface { surface, .. } => {
@ -2375,11 +2375,10 @@ impl State {
pointer: &PointerHandle<Self>,
mut location: Point<f64, Logical>,
) {
if let Some(client) = surface.client() {
let scale = self.client_compositor_state(&client).client_scale();
location.x /= scale;
location.y /= scale;
}
let Some(client) = surface.client() else {
return;
};
location = location.downscale(self.client_compositor_state(&client).client_scale());
let point_and_output = {
let shell = self.common.shell.read();