diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 74b4341dd..670b4458b 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -140,6 +140,8 @@ struct wlr_touch_grab_interface { // Send wl_touch.cancel void (*wl_cancel)(struct wlr_seat_touch_grab *grab, struct wlr_seat_client *seat_client); + void (*clear_focus)(struct wlr_seat_touch_grab *grab, uint32_t time_msec, + struct wlr_touch_point *point); }; /** @@ -685,6 +687,8 @@ void wlr_seat_touch_notify_cancel(struct wlr_seat *seat, struct wlr_seat_client *seat_client); void wlr_seat_touch_notify_frame(struct wlr_seat *seat); +void wlr_seat_touch_notify_clear_focus(struct wlr_seat *seat, + uint32_t time_msec, int32_t touch_id); /** * How many touch points are currently down for the seat. diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c index df0ce3b83..dbf30a321 100644 --- a/types/data_device/wlr_drag.c +++ b/types/data_device/wlr_drag.c @@ -334,6 +334,12 @@ static void drag_handle_touch_cancel(struct wlr_seat_touch_grab *grab) { drag_destroy(drag); } +static void drag_handle_clear_focus(struct wlr_seat_touch_grab *grab, uint32_t time_msec, + struct wlr_touch_point *point) { + struct wlr_drag *drag = grab->data; + drag_set_focus(drag, NULL, 0, 0); +} + static const struct wlr_touch_grab_interface data_device_touch_drag_interface = { .down = drag_handle_touch_down, @@ -341,6 +347,7 @@ static const struct wlr_touch_grab_interface .motion = drag_handle_touch_motion, .enter = drag_handle_touch_enter, .cancel = drag_handle_touch_cancel, + .clear_focus = drag_handle_clear_focus, }; static void drag_handle_keyboard_enter(struct wlr_seat_keyboard_grab *grab, diff --git a/types/seat/wlr_seat_touch.c b/types/seat/wlr_seat_touch.c index 192ae5890..217c19e70 100644 --- a/types/seat/wlr_seat_touch.c +++ b/types/seat/wlr_seat_touch.c @@ -44,6 +44,12 @@ static void default_touch_wl_cancel(struct wlr_seat_touch_grab *grab, wlr_seat_touch_send_cancel(grab->seat, seat_client); } +static void default_touch_clear_focus(struct wlr_seat_touch_grab *grab, uint32_t time_msec, + struct wlr_touch_point *point) { + wlr_seat_touch_point_clear_focus(grab->seat, time_msec, point->touch_id); +} + + const struct wlr_touch_grab_interface default_touch_grab_impl = { .down = default_touch_down, .up = default_touch_up, @@ -52,6 +58,7 @@ const struct wlr_touch_grab_interface default_touch_grab_impl = { .frame = default_touch_frame, .cancel = default_touch_cancel, .wl_cancel = default_touch_wl_cancel, + .clear_focus = default_touch_clear_focus, }; @@ -256,6 +263,19 @@ void wlr_seat_touch_notify_cancel(struct wlr_seat *seat, } } +void wlr_seat_touch_notify_clear_focus(struct wlr_seat *seat, + uint32_t time, int32_t touch_id) { + struct wlr_seat_touch_grab *grab = seat->touch_state.grab; + struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id); + if (!point) { + return; + } + + if (grab->interface->clear_focus) { + grab->interface->clear_focus(grab, time, point); + } +} + static void handle_point_focus_destroy(struct wl_listener *listener, void *data) { struct wlr_touch_point *point = diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c index 25c07c8c5..0c3b9fe44 100644 --- a/types/xdg_shell/wlr_xdg_popup.c +++ b/types/xdg_shell/wlr_xdg_popup.c @@ -174,13 +174,19 @@ static void xdg_touch_grab_cancel(struct wlr_seat_touch_grab *grab) { wlr_seat_touch_end_grab(grab->seat); } +static void xdg_touch_grab_clear_focus(struct wlr_seat_touch_grab *grab, uint32_t time_msec, + struct wlr_touch_point *point) { + wlr_seat_touch_point_clear_focus(grab->seat, time_msec, point->touch_id); +} + static const struct wlr_touch_grab_interface xdg_touch_grab_impl = { .down = xdg_touch_grab_down, .up = xdg_touch_grab_up, .motion = xdg_touch_grab_motion, .enter = xdg_touch_grab_enter, .frame = xdg_touch_grab_frame, - .cancel = xdg_touch_grab_cancel + .cancel = xdg_touch_grab_cancel, + .clear_focus = xdg_touch_grab_clear_focus, }; static void destroy_xdg_popup_grab(struct wlr_xdg_popup_grab *xdg_grab) {