mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-20 13:50:14 +01:00
seat: add wlr_seat_touch_notify_clear_focus
This is needed for cases where the touch operation goes over a region where no surfaces are present. In this case, we'd want to notify the touch grabs (for example DnD grabs) that no focus is currently focused.
This commit is contained in:
parent
03b465f324
commit
0e9c6ddefa
4 changed files with 38 additions and 1 deletions
|
|
@ -140,6 +140,8 @@ struct wlr_touch_grab_interface {
|
||||||
// Send wl_touch.cancel
|
// Send wl_touch.cancel
|
||||||
void (*wl_cancel)(struct wlr_seat_touch_grab *grab,
|
void (*wl_cancel)(struct wlr_seat_touch_grab *grab,
|
||||||
struct wlr_seat_client *seat_client);
|
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);
|
struct wlr_seat_client *seat_client);
|
||||||
|
|
||||||
void wlr_seat_touch_notify_frame(struct wlr_seat *seat);
|
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.
|
* How many touch points are currently down for the seat.
|
||||||
|
|
|
||||||
|
|
@ -334,6 +334,12 @@ static void drag_handle_touch_cancel(struct wlr_seat_touch_grab *grab) {
|
||||||
drag_destroy(drag);
|
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
|
static const struct wlr_touch_grab_interface
|
||||||
data_device_touch_drag_interface = {
|
data_device_touch_drag_interface = {
|
||||||
.down = drag_handle_touch_down,
|
.down = drag_handle_touch_down,
|
||||||
|
|
@ -341,6 +347,7 @@ static const struct wlr_touch_grab_interface
|
||||||
.motion = drag_handle_touch_motion,
|
.motion = drag_handle_touch_motion,
|
||||||
.enter = drag_handle_touch_enter,
|
.enter = drag_handle_touch_enter,
|
||||||
.cancel = drag_handle_touch_cancel,
|
.cancel = drag_handle_touch_cancel,
|
||||||
|
.clear_focus = drag_handle_clear_focus,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void drag_handle_keyboard_enter(struct wlr_seat_keyboard_grab *grab,
|
static void drag_handle_keyboard_enter(struct wlr_seat_keyboard_grab *grab,
|
||||||
|
|
|
||||||
|
|
@ -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);
|
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 = {
|
const struct wlr_touch_grab_interface default_touch_grab_impl = {
|
||||||
.down = default_touch_down,
|
.down = default_touch_down,
|
||||||
.up = default_touch_up,
|
.up = default_touch_up,
|
||||||
|
|
@ -52,6 +58,7 @@ const struct wlr_touch_grab_interface default_touch_grab_impl = {
|
||||||
.frame = default_touch_frame,
|
.frame = default_touch_frame,
|
||||||
.cancel = default_touch_cancel,
|
.cancel = default_touch_cancel,
|
||||||
.wl_cancel = default_touch_wl_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,
|
static void handle_point_focus_destroy(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct wlr_touch_point *point =
|
struct wlr_touch_point *point =
|
||||||
|
|
|
||||||
|
|
@ -174,13 +174,19 @@ static void xdg_touch_grab_cancel(struct wlr_seat_touch_grab *grab) {
|
||||||
wlr_seat_touch_end_grab(grab->seat);
|
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 = {
|
static const struct wlr_touch_grab_interface xdg_touch_grab_impl = {
|
||||||
.down = xdg_touch_grab_down,
|
.down = xdg_touch_grab_down,
|
||||||
.up = xdg_touch_grab_up,
|
.up = xdg_touch_grab_up,
|
||||||
.motion = xdg_touch_grab_motion,
|
.motion = xdg_touch_grab_motion,
|
||||||
.enter = xdg_touch_grab_enter,
|
.enter = xdg_touch_grab_enter,
|
||||||
.frame = xdg_touch_grab_frame,
|
.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) {
|
static void destroy_xdg_popup_grab(struct wlr_xdg_popup_grab *xdg_grab) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue