From 41f22cd86b0710f28c67941e5ef8085c524581c2 Mon Sep 17 00:00:00 2001 From: "duna.oh" Date: Tue, 26 Sep 2023 19:46:56 +0900 Subject: [PATCH] e_comp_wl_input: when pointer is locked, do not update seat->ptr.x/y. like grab Change-Id: Id6ea728470a3028c4cda4cce6425cb64dd57b57a --- src/bin/e_comp_wl_input.c | 49 +++++++++++++++----------- src/bin/e_input_evdev.c | 88 +++++++++++++++++++++++------------------------ 2 files changed, 73 insertions(+), 64 deletions(-) diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c index 7ee91cf..54dd3a5 100644 --- a/src/bin/e_comp_wl_input.c +++ b/src/bin/e_comp_wl_input.c @@ -33,8 +33,8 @@ struct _E_Comp_Wl_Pointer_Constraint Eina_Bool is_region_pending; Eina_Bool has_region_set; - wl_fixed_t hint_x; - wl_fixed_t hint_y; + int hint_x; + int hint_y; wl_fixed_t hint_x_pending; wl_fixed_t hint_y_pending; Eina_Bool is_hint_pending; @@ -624,17 +624,14 @@ _e_comp_wl_input_pointer_constraint_notify_deactivated(E_Comp_Wl_Pointer_Constra else ERR("unknown pointer constraint type (%d) !", type); + INF("Pointer Constraint deactivated."); + if (constraint->ec && - constraint->has_hint_set && - _e_comp_wl_input_is_position_inside_constraint_region(constraint, - constraint->hint_x, - constraint->hint_y)) + constraint->has_hint_set) { - 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); + + INF("Pointer Constraint. Pointer Warp to (%d, %d)", constraint->hint_x, constraint->hint_y); + e_input_device_pointer_warp(NULL, constraint->hint_x, constraint->hint_y); } } @@ -713,6 +710,8 @@ _e_comp_wl_input_pointer_constraint_notify_activated(E_Comp_Wl_Pointer_Constrain zwp_confined_pointer_v1_send_confined(resource); else ERR("unknown pointer constraint type (%d) !", type); + + INF("Pointer Constraint activated."); } static void @@ -796,6 +795,7 @@ _e_comp_wl_input_cb_pointer_constraints_surface_committed(struct wl_listener *li E_Comp_Wl_Pointer_Constraint *constraint = container_of(listener, E_Comp_Wl_Pointer_Constraint, surface_commit_listener); + int new_x, new_y;; if (ec != constraint->ec) return; @@ -803,8 +803,23 @@ _e_comp_wl_input_cb_pointer_constraints_surface_committed(struct wl_listener *li if (constraint->is_hint_pending) { constraint->is_hint_pending = EINA_FALSE; - constraint->hint_x = constraint->hint_x_pending; - constraint->hint_y = constraint->hint_y_pending; + + new_x = ec->client.x + wl_fixed_to_int(constraint->hint_x_pending); + new_y = ec->client.y + wl_fixed_to_int(constraint->hint_y_pending); + + if (evas_object_map_enable_get(ec->frame)) + { + e_comp_wl_map_inv_coord_get(ec, new_x, new_y, &constraint->hint_x, &constraint->hint_y); + WRN("Pointer Constraint. Committed. hint (%d, %d) -> map_inv_coord (%d, %d)", + new_x, new_y, constraint->hint_x, constraint->hint_y); + } + else + { + constraint->hint_x = new_x; + constraint->hint_y = new_y; + WRN("Pointer Constraint. Committed. hint (%d, %d)", + constraint->hint_x, constraint->hint_y); + } } if (constraint->is_region_pending) @@ -915,13 +930,7 @@ _e_comp_wl_input_pointer_constraint_create(E_Client *ec, 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)); + ERR("Pointer Constraint created."); constraint->pointer_destroy_listener.notify = _e_comp_wl_input_cb_pointer_constraints_pointer_destroyed; diff --git a/src/bin/e_input_evdev.c b/src/bin/e_input_evdev.c index ac91a5c..1c0aa6d 100644 --- a/src/bin/e_input_evdev.c +++ b/src/bin/e_input_evdev.c @@ -1000,6 +1000,50 @@ _device_pointer_motion_send(E_Input_Evdev *edev, struct libinput_event_pointer * } else { + double seat_dx, seat_dy, temp; + if (edev->disable_acceleration) + { + seat_dx = dx[1]; + seat_dy = dy[1]; + } + else + { + seat_dx = dx[0]; + seat_dy = dy[0]; + } + + if (edev->seat->ptr.swap) + { + temp = seat_dx; + seat_dx = seat_dy; + seat_dy = temp; + } + if (edev->seat->ptr.invert_x) + seat_dx *= -1; + if (edev->seat->ptr.invert_y) + seat_dy *= -1; + + edev->seat->ptr.dx += seat_dx; + edev->seat->ptr.dy += seat_dy; + + edev->mouse.dx = edev->seat->ptr.dx; + edev->mouse.dy = edev->seat->ptr.dy; + + if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix && + floor(edev->seat->ptr.dy) == edev->seat->ptr.iy) + { + return; + } + + edev->seat->ptr.ix = edev->seat->ptr.dx; + edev->seat->ptr.iy = edev->seat->ptr.dy; + + if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) || + (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER)) + { + return; + } + _device_pointer_motion(edev, event); } } @@ -1010,7 +1054,6 @@ _device_handle_pointer_motion(struct libinput_device *device, struct libinput_ev E_Input_Evdev *edev; double delta_x[2]; /* delta_x[0] for accelerated, delta_x[1] for unaccelerated */ double delta_y[2]; /* delta_y[0] for accelerated, delta_y[1] for unaccelerated */ - double dx, dy, temp; if (!(edev = libinput_device_get_user_data(device))) { @@ -1022,49 +1065,6 @@ _device_handle_pointer_motion(struct libinput_device *device, struct libinput_ev delta_y[0] = libinput_event_pointer_get_dy(event); delta_y[1] = libinput_event_pointer_get_dy_unaccelerated(event); - if (edev->disable_acceleration) - { - dx = delta_x[1]; - dy = delta_y[1]; - } - else - { - dx = delta_x[0]; - dy = delta_y[0]; - } - - if (edev->seat->ptr.swap) - { - temp = dx; - dx = dy; - dy = temp; - } - if (edev->seat->ptr.invert_x) - dx *= -1; - if (edev->seat->ptr.invert_y) - dy *= -1; - - edev->seat->ptr.dx += dx; - edev->seat->ptr.dy += dy; - - edev->mouse.dx = edev->seat->ptr.dx; - edev->mouse.dy = edev->seat->ptr.dy; - - if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix && - floor(edev->seat->ptr.dy) == edev->seat->ptr.iy) - { - return; - } - - edev->seat->ptr.ix = edev->seat->ptr.dx; - edev->seat->ptr.iy = edev->seat->ptr.dy; - - if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) || - (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER)) - { - return; - } - _device_pointer_motion_send(edev, event, &delta_x[0], &delta_y[0]); } -- 2.7.4