libweston: enable pointer constraints for fullscreen surfaces.

Signed-off-by: vanfanel <redwindwanderer@gmail.com>
This commit is contained in:
vanfanel 2024-03-04 10:42:02 +01:00
parent 215cceb45d
commit 90664b0f3b
1 changed files with 17 additions and 2 deletions

View File

@ -44,6 +44,7 @@
#include "shared/os-compatibility.h"
#include "shared/timespec-util.h"
#include <libweston/libweston.h>
#include <libweston/desktop.h>
#include "backend.h"
#include "libweston-internal.h"
#include "relative-pointer-unstable-v1-server-protocol.h"
@ -4968,8 +4969,22 @@ init_pointer_constraint(struct wl_resource *pointer_constraints_resource,
wl_resource_set_implementation(cr, implementation, constraint,
pointer_constraint_constrain_resource_destroyed);
if (constraint)
maybe_enable_pointer_constraint(constraint);
if (constraint) {
bool is_fullscreen = false;
if (weston_surface_is_desktop_surface(surface)) {
struct weston_desktop_surface *desktop_surface;
desktop_surface = weston_surface_get_desktop_surface(surface);
is_fullscreen = weston_desktop_surface_get_fullscreen(desktop_surface);
}
if (is_fullscreen && !is_pointer_constraint_enabled(constraint)) {
weston_view_update_transform(pointer->focus);
weston_pointer_set_focus(pointer, pointer->focus);
enable_pointer_constraint(constraint, pointer->focus);
maybe_warp_confined_pointer(constraint);
} else {
maybe_enable_pointer_constraint(constraint);
}
}
}
static void