E_FREE(e_comp_wl->evas_gl);
}
-static Eina_Bool
-_e_comp_wl_cb_mouse_move_preventer(void *d EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
-{
- static int saved_x = -1;
- static int saved_y = -1;
-
- E_Client *focus = e_client_focused_get();
-
- if ((!e_comp_wl->ptr_constraints.activated) ||
- (!focus) ||
- (e_comp_wl->ptr_constraints.ec != focus))
- {
- if (saved_x != -1 || saved_y != -1)
- {
- e_input_device_pointer_warp(NULL, saved_x, saved_y);
- saved_x = -1;
- saved_y = -1;
- }
-
- return ECORE_CALLBACK_RENEW;
- }
-
- if (saved_x == -1 || saved_y == -1)
- {
- saved_x = ev->x;
- saved_y = ev->y;
- }
-
- return ECORE_CALLBACK_DONE;
-}
-
/* public functions */
/**
if (!e_foreign_global_init(e_comp_wl->wl.disp))
ELOGF("COMP", "Failed to initialize the e_foreign global", NULL);
- /* prepend a mouse move event handler to prevent the mouse move event from being delivered to
- the other mouse move event handlers when a pointer constraint is activated */
- E_LIST_HANDLER_PREPEND(handlers, ECORE_EVENT_MOUSE_MOVE, _e_comp_wl_cb_mouse_move_preventer, NULL);
-
/* add event handlers to catch E events */
E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREEN_CHANGE, _e_comp_wl_cb_randr_change, NULL);
E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMP_OBJECT_ADD, _e_comp_wl_cb_comp_object_add, NULL);
static char *_env_e_default_xkb_variant = NULL;
static char *_env_e_default_xkb_opts = NULL;
+static Eina_Bool
+_e_comp_wl_input_is_position_inside_constraint_region(E_Comp_Wl_Pointer_Constraint *constraint,
+ wl_fixed_t fx,
+ wl_fixed_t fy);
+
static void
_e_comp_wl_input_update_seat_caps(struct wl_client *wc)
{
zwp_confined_pointer_v1_send_unconfined(resource);
else
ERR("unknown pointer constraint type (%d) !", type);
+
+ if (constraint->ec &&
+ constraint->has_hint_set &&
+ _e_comp_wl_input_is_position_inside_constraint_region(constraint,
+ constraint->hint_x,
+ constraint->hint_y))
+ {
+ E_Client *ec = constraint->ec;
+ int cx = ec->client.x + wl_fixed_to_int(constraint->hint_x);
+ int cy = ec->client.y + wl_fixed_to_int(constraint->hint_y);
+ INF("Pointer Constraint deactivated. Pointer Warp to (%d, %d)", cx, cy);
+ e_input_device_pointer_warp(NULL, cx, cy);
+ }
}
static void
}
E_Client *ec = constraint->ec;
+ wl_fixed_t cx = e_comp_wl->ptr.x - wl_fixed_from_int(ec->client.x);
+ wl_fixed_t cy = e_comp_wl->ptr.y - wl_fixed_from_int(ec->client.y);
if ((!e_comp_wl->ptr.ec) || (e_comp_wl->ptr.ec != ec)
|| (!ec->pointer_enter_sent))
return;
if (!_e_comp_wl_input_is_position_inside_constraint_region(constraint,
- e_comp_wl->ptr.x,
- e_comp_wl->ptr.y))
+ cx,
+ cy))
return;
_e_comp_wl_input_pointer_constraint_enable(constraint);
constraint->has_region_set = EINA_TRUE;
}
+ constraint->hint_x = e_comp_wl->ptr.x - wl_fixed_from_int(ec->client.x);
+ constraint->hint_y = e_comp_wl->ptr.y - wl_fixed_from_int(ec->client.y);
+ constraint->is_hint_pending = EINA_FALSE;
+ constraint->has_hint_set = EINA_TRUE;
+ ERR("Pointer Constraint created. cursor position hint (%d, %d)",
+ wl_fixed_to_int(constraint->hint_x),
+ wl_fixed_to_int(constraint->hint_y));
+
constraint->pointer_destroy_listener.notify =
_e_comp_wl_input_cb_pointer_constraints_pointer_destroyed;
constraint->surface_commit_listener.notify =
_e_comp_wl_input_cb_locked_pointer_destroy(struct wl_client *client,
struct wl_resource *resource)
{
- E_Comp_Wl_Pointer_Constraint *constraint;
- constraint = wl_resource_get_user_data(resource);
-
- if (constraint &&
- constraint->ec &&
- constraint->has_hint_set &&
- _e_comp_wl_input_is_position_inside_constraint_region(constraint,
- constraint->hint_x,
- constraint->hint_y))
- {
- E_Client *ec = constraint->ec;
- int cx = ec->client.x + wl_fixed_to_int(constraint->hint_x);
- int cy = ec->client.y + wl_fixed_to_int(constraint->hint_y);
- e_input_device_pointer_warp(NULL, cx, cy);
- }
-
wl_resource_destroy(resource);
}