};
//
+// TIZEN_ONLY(20230801) : support zwp pointer constraints protocol
+static void
+_locked_pointer_cb_locked(void *data, struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1 EINA_UNUSED)
+{
+ Ecore_Wl2_Input *input = (Ecore_Wl2_Input *)data;
+
+ // For Debug
+ ERR("[locked pointer] locked");
+ input->pointer_locked = EINA_TRUE;
+}
+
+static void
+_locked_pointer_cb_unlocked(void *data, struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1 EINA_UNUSED)
+{
+ Ecore_Wl2_Input *input = (Ecore_Wl2_Input *)data;
+
+ // For Debug
+ ERR("[locked pointer] unlocked");
+ input->pointer_locked = EINA_FALSE;
+}
+
+static const struct zwp_locked_pointer_v1_listener _locked_pointer_listener = {
+ _locked_pointer_cb_locked,
+ _locked_pointer_cb_unlocked,
+};
+//
+
static void
_keyboard_cb_keymap(void *data, struct wl_keyboard *keyboard EINA_UNUSED, unsigned int format, int fd, unsigned int size)
{
input->repeat.delay = input->repeat.horizontal.delay = input->repeat.vertical.delay = 0.4;
input->repeat.enabled = EINA_TRUE;
input->repeat.changed = EINA_FALSE;
+ input->want_lock_pointer = EINA_FALSE;
+ input->pointer_locked = EINA_FALSE;
wl_array_init(&input->data.selection.types);
wl_array_init(&input->data.drag.types);
return input;
}
+
+// TIZEN_ONLY(20230801) : support zwp pointer constraints protocol
+EAPI Eina_Bool
+ecore_wl2_window_pointer_constraints_lock_pointer(Ecore_Wl2_Window *win)
+{
+ Ecore_Wl2_Display *ewd;
+ Ecore_Wl2_Input *input;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(win, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(win->surface, EINA_FALSE);
+
+ ewd = win->display;
+ input = ecore_wl2_input_default_input_get(ewd);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
+
+ if (!ewd->wl.pointer_constraints)
+ {
+ ERR("Failed to lock pointer. constraints is NULL");
+ return EINA_FALSE;
+ }
+ if (!input->wl.locked_pointer)
+ {
+ INF("Pointer Constraint: lock pointer. (region: %p)", input->lock_region);
+ input->wl.locked_pointer =
+ zwp_pointer_constraints_v1_lock_pointer(ewd->wl.pointer_constraints,
+ win->surface,
+ input->wl.pointer,
+ input->lock_region,
+ ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
+ zwp_locked_pointer_v1_add_listener(input->wl.locked_pointer,
+ &_locked_pointer_listener, input);
+ }
+
+ if (input->wl.locked_pointer)
+ {
+ if (ewd->wl.relative_pointer_manager &&
+ !input->wl.relative_pointer)
+ {
+ input->wl.relative_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(
+ input->display->wl.relative_pointer_manager,
+ input->wl.pointer);
+ zwp_relative_pointer_v1_add_listener(input->wl.relative_pointer, &_relative_pointer_listener, input);
+ }
+ }
+ input->want_lock_pointer = EINA_TRUE;
+
+ return EINA_TRUE;
+}
+
+EAPI Eina_Bool
+ecore_wl2_window_pointer_constraints_unlock_pointer(Ecore_Wl2_Window *win)
+{
+ Ecore_Wl2_Display *ewd;
+ Ecore_Wl2_Input *input;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(win, EINA_FALSE);
+
+ ewd = win->display;
+ input = ecore_wl2_input_default_input_get(ewd);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
+
+ if (input->wl.locked_pointer)
+ {
+ INF("Pointer Constraint: Destroy locked pointer");
+ zwp_locked_pointer_v1_destroy(input->wl.locked_pointer);
+ input->wl.locked_pointer = NULL;
+ }
+ input->want_lock_pointer = EINA_FALSE;
+
+ return EINA_TRUE;
+}
+
+EAPI void
+ecore_wl2_window_locked_pointer_region_set(Ecore_Wl2_Window *win, int x, int y, int w, int h)
+{
+ Ecore_Wl2_Display *ewd;
+ Ecore_Wl2_Input *input;
+
+ EINA_SAFETY_ON_NULL_RETURN(win);
+
+ ewd = win->display;
+ input = ecore_wl2_input_default_input_get(ewd);
+ EINA_SAFETY_ON_NULL_RETURN(input);
+
+ if (input->lock_region)
+ {
+ wl_region_destroy(input->lock_region);
+ input->lock_region = NULL;
+ }
+
+ if ((w > 0) && (h > 0))
+ {
+ struct wl_region *region;
+
+ region = wl_compositor_create_region(ewd->wl.compositor);
+ if (!region)
+ {
+ ERR("Failed to create region of locked_pointer");
+ return;
+ }
+
+ input->lock_region = region;
+ wl_region_add(input->lock_region, x, y, w, h);
+
+ if (!input->wl.locked_pointer)
+ {
+ INF("No locked_pointer available. region (%d, %d) (w:%d, h:%d)", x, y, w, h);
+ return;
+ }
+
+ INF("Set region for locked_pointer (%d, %d) (w:%d, h:%d)", x, y, w, h);
+ zwp_locked_pointer_v1_set_region(input->wl.locked_pointer, input->lock_region);
+ }
+ else
+ {
+ if (!input->wl.locked_pointer)
+ {
+ INF("No locked_pointer available. region (%d, %d) (w:%d, h:%d)", x, y, w, h);
+ return;
+ }
+ INF("Set region for locked_pointer. NULL region");
+ zwp_locked_pointer_v1_set_region(input->wl.locked_pointer, NULL);
+ }
+}
+
+EAPI void
+ecore_wl2_window_locked_pointer_cursor_position_hint_set(Ecore_Wl2_Window *win, int x, int y)
+{
+ Ecore_Wl2_Display *ewd;
+ Ecore_Wl2_Input *input;
+
+ EINA_SAFETY_ON_NULL_RETURN(win);
+
+ ewd = win->display;
+ input = ecore_wl2_input_default_input_get(ewd);
+ EINA_SAFETY_ON_NULL_RETURN(input);
+
+ if (!input->wl.locked_pointer)
+ {
+ INF("No locked pointer available. cursor position hint (%d, %d)", x, y);
+ return;
+ }
+
+ INF("Set cursor position hint (%d, %d) for locked_pointer", x, y);
+ zwp_locked_pointer_v1_set_cursor_position_hint(input->wl.locked_pointer,
+ wl_fixed_from_int(x),
+ wl_fixed_from_int(y));
+}
+//