mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
backend/wayland: send hold gesture events
Receive hold gesture events using a Wayland listiner and emit the appropiate wlr_pointer signal.
This commit is contained in:
parent
52d2491931
commit
62e62b6942
3 changed files with 46 additions and 1 deletions
|
@ -224,7 +224,7 @@ static void registry_global(void *data, struct wl_registry *registry,
|
|||
&zxdg_decoration_manager_v1_interface, 1);
|
||||
} else if (strcmp(iface, zwp_pointer_gestures_v1_interface.name) == 0) {
|
||||
wl->zwp_pointer_gestures_v1 = wl_registry_bind(registry, name,
|
||||
&zwp_pointer_gestures_v1_interface, 1);
|
||||
&zwp_pointer_gestures_v1_interface, version < 3 ? version : 3);
|
||||
} else if (strcmp(iface, wp_presentation_interface.name) == 0) {
|
||||
wl->presentation = wl_registry_bind(registry, name,
|
||||
&wp_presentation_interface, 1);
|
||||
|
|
|
@ -504,6 +504,9 @@ static void pointer_destroy(struct wlr_pointer *wlr_pointer) {
|
|||
if (pointer->gesture_pinch != NULL) {
|
||||
zwp_pointer_gesture_pinch_v1_destroy(pointer->gesture_pinch);
|
||||
}
|
||||
if (pointer->gesture_hold != NULL) {
|
||||
zwp_pointer_gesture_hold_v1_destroy(pointer->gesture_hold);
|
||||
}
|
||||
if (pointer->relative_pointer != NULL) {
|
||||
zwp_relative_pointer_v1_destroy(pointer->relative_pointer);
|
||||
}
|
||||
|
@ -616,6 +619,38 @@ static const struct zwp_pointer_gesture_pinch_v1_listener gesture_pinch_impl = {
|
|||
.end = gesture_pinch_end,
|
||||
};
|
||||
|
||||
static void gesture_hold_begin(void *data,
|
||||
struct zwp_pointer_gesture_hold_v1 *zwp_pointer_gesture_hold_v1,
|
||||
uint32_t serial, uint32_t time,
|
||||
struct wl_surface *surface, uint32_t fingers) {
|
||||
struct wlr_wl_input_device *input_device = (struct wlr_wl_input_device *)data;
|
||||
struct wlr_input_device *wlr_dev = &input_device->wlr_input_device;
|
||||
struct wlr_event_pointer_hold_begin wlr_event = {
|
||||
.device = wlr_dev,
|
||||
.time_msec = time,
|
||||
.fingers = fingers,
|
||||
};
|
||||
input_device->fingers = fingers;
|
||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.hold_begin, &wlr_event);
|
||||
}
|
||||
|
||||
static void gesture_hold_end(void *data,
|
||||
struct zwp_pointer_gesture_hold_v1 *zwp_pointer_gesture_hold_v1,
|
||||
uint32_t serial, uint32_t time, int32_t cancelled) {
|
||||
struct wlr_wl_input_device *input_device = (struct wlr_wl_input_device *)data;
|
||||
struct wlr_input_device *wlr_dev = &input_device->wlr_input_device;
|
||||
struct wlr_event_pointer_hold_end wlr_event = {
|
||||
.device = wlr_dev,
|
||||
.time_msec = time,
|
||||
.cancelled = cancelled,
|
||||
};
|
||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.hold_end, &wlr_event);
|
||||
}
|
||||
|
||||
static const struct zwp_pointer_gesture_hold_v1_listener gesture_hold_impl = {
|
||||
.begin = gesture_hold_begin,
|
||||
.end = gesture_hold_end,
|
||||
};
|
||||
|
||||
static void relative_pointer_handle_relative_motion(void *data,
|
||||
struct zwp_relative_pointer_v1 *relative_pointer, uint32_t utime_hi,
|
||||
|
@ -690,12 +725,21 @@ void create_wl_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output) {
|
|||
wlr_pointer_init(wlr_dev->pointer, &pointer_impl);
|
||||
|
||||
if (backend->zwp_pointer_gestures_v1) {
|
||||
uint32_t version = zwp_pointer_gestures_v1_get_version(
|
||||
backend->zwp_pointer_gestures_v1);
|
||||
|
||||
pointer->gesture_swipe = zwp_pointer_gestures_v1_get_swipe_gesture(
|
||||
backend->zwp_pointer_gestures_v1, wl_pointer);
|
||||
zwp_pointer_gesture_swipe_v1_add_listener(pointer->gesture_swipe, &gesture_swipe_impl, dev);
|
||||
pointer->gesture_pinch = zwp_pointer_gestures_v1_get_pinch_gesture(
|
||||
backend->zwp_pointer_gestures_v1, wl_pointer);
|
||||
zwp_pointer_gesture_pinch_v1_add_listener(pointer->gesture_pinch, &gesture_pinch_impl, dev);
|
||||
|
||||
if (version >= ZWP_POINTER_GESTURES_V1_GET_HOLD_GESTURE) {
|
||||
pointer->gesture_hold = zwp_pointer_gestures_v1_get_hold_gesture(
|
||||
backend->zwp_pointer_gestures_v1, wl_pointer);
|
||||
zwp_pointer_gesture_hold_v1_add_listener(pointer->gesture_hold, &gesture_hold_impl, dev);
|
||||
}
|
||||
}
|
||||
|
||||
if (backend->zwp_relative_pointer_manager_v1) {
|
||||
|
|
|
@ -98,6 +98,7 @@ struct wlr_wl_pointer {
|
|||
struct wl_pointer *wl_pointer;
|
||||
struct zwp_pointer_gesture_swipe_v1 *gesture_swipe;
|
||||
struct zwp_pointer_gesture_pinch_v1 *gesture_pinch;
|
||||
struct zwp_pointer_gesture_hold_v1 *gesture_hold;
|
||||
struct zwp_relative_pointer_v1 *relative_pointer;
|
||||
enum wlr_axis_source axis_source;
|
||||
int32_t axis_discrete;
|
||||
|
|
Loading…
Reference in a new issue