mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
cursor: emit hold gesture events
Recevie the hold gesture events from the libinput or Wayland backends, abstracted as pointer signals, and re-emit them from the cursor interface.
This commit is contained in:
parent
62e62b6942
commit
4c3e307ec8
2 changed files with 26 additions and 0 deletions
|
@ -58,6 +58,8 @@ struct wlr_cursor {
|
||||||
struct wl_signal pinch_begin;
|
struct wl_signal pinch_begin;
|
||||||
struct wl_signal pinch_update;
|
struct wl_signal pinch_update;
|
||||||
struct wl_signal pinch_end;
|
struct wl_signal pinch_end;
|
||||||
|
struct wl_signal hold_begin;
|
||||||
|
struct wl_signal hold_end;
|
||||||
|
|
||||||
struct wl_signal touch_up;
|
struct wl_signal touch_up;
|
||||||
struct wl_signal touch_down;
|
struct wl_signal touch_down;
|
||||||
|
|
|
@ -32,6 +32,8 @@ struct wlr_cursor_device {
|
||||||
struct wl_listener pinch_begin;
|
struct wl_listener pinch_begin;
|
||||||
struct wl_listener pinch_update;
|
struct wl_listener pinch_update;
|
||||||
struct wl_listener pinch_end;
|
struct wl_listener pinch_end;
|
||||||
|
struct wl_listener hold_begin;
|
||||||
|
struct wl_listener hold_end;
|
||||||
|
|
||||||
struct wl_listener touch_down;
|
struct wl_listener touch_down;
|
||||||
struct wl_listener touch_up;
|
struct wl_listener touch_up;
|
||||||
|
@ -100,6 +102,8 @@ struct wlr_cursor *wlr_cursor_create(void) {
|
||||||
wl_signal_init(&cur->events.pinch_begin);
|
wl_signal_init(&cur->events.pinch_begin);
|
||||||
wl_signal_init(&cur->events.pinch_update);
|
wl_signal_init(&cur->events.pinch_update);
|
||||||
wl_signal_init(&cur->events.pinch_end);
|
wl_signal_init(&cur->events.pinch_end);
|
||||||
|
wl_signal_init(&cur->events.hold_begin);
|
||||||
|
wl_signal_init(&cur->events.hold_end);
|
||||||
|
|
||||||
// touch signals
|
// touch signals
|
||||||
wl_signal_init(&cur->events.touch_up);
|
wl_signal_init(&cur->events.touch_up);
|
||||||
|
@ -160,6 +164,8 @@ static void cursor_device_destroy(struct wlr_cursor_device *c_device) {
|
||||||
wl_list_remove(&c_device->pinch_begin.link);
|
wl_list_remove(&c_device->pinch_begin.link);
|
||||||
wl_list_remove(&c_device->pinch_update.link);
|
wl_list_remove(&c_device->pinch_update.link);
|
||||||
wl_list_remove(&c_device->pinch_end.link);
|
wl_list_remove(&c_device->pinch_end.link);
|
||||||
|
wl_list_remove(&c_device->hold_begin.link);
|
||||||
|
wl_list_remove(&c_device->hold_end.link);
|
||||||
} else if (dev->type == WLR_INPUT_DEVICE_TOUCH) {
|
} else if (dev->type == WLR_INPUT_DEVICE_TOUCH) {
|
||||||
wl_list_remove(&c_device->touch_down.link);
|
wl_list_remove(&c_device->touch_down.link);
|
||||||
wl_list_remove(&c_device->touch_up.link);
|
wl_list_remove(&c_device->touch_up.link);
|
||||||
|
@ -488,6 +494,18 @@ static void handle_pointer_pinch_end(struct wl_listener *listener, void *data) {
|
||||||
wlr_signal_emit_safe(&device->cursor->events.pinch_end, event);
|
wlr_signal_emit_safe(&device->cursor->events.pinch_end, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_pointer_hold_begin(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_event_pointer_hold_begin *event = data;
|
||||||
|
struct wlr_cursor_device *device = wl_container_of(listener, device, hold_begin);
|
||||||
|
wlr_signal_emit_safe(&device->cursor->events.hold_begin, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_pointer_hold_end(struct wl_listener *listener, void *data) {
|
||||||
|
struct wlr_event_pointer_hold_end *event = data;
|
||||||
|
struct wlr_cursor_device *device = wl_container_of(listener, device, hold_end);
|
||||||
|
wlr_signal_emit_safe(&device->cursor->events.hold_end, event);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_touch_up(struct wl_listener *listener, void *data) {
|
static void handle_touch_up(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_event_touch_up *event = data;
|
struct wlr_event_touch_up *event = data;
|
||||||
struct wlr_cursor_device *device;
|
struct wlr_cursor_device *device;
|
||||||
|
@ -660,6 +678,12 @@ static struct wlr_cursor_device *cursor_device_create(
|
||||||
|
|
||||||
wl_signal_add(&device->pointer->events.pinch_end, &c_device->pinch_end);
|
wl_signal_add(&device->pointer->events.pinch_end, &c_device->pinch_end);
|
||||||
c_device->pinch_end.notify = handle_pointer_pinch_end;
|
c_device->pinch_end.notify = handle_pointer_pinch_end;
|
||||||
|
|
||||||
|
wl_signal_add(&device->pointer->events.hold_begin, &c_device->hold_begin);
|
||||||
|
c_device->hold_begin.notify = handle_pointer_hold_begin;
|
||||||
|
|
||||||
|
wl_signal_add(&device->pointer->events.hold_end, &c_device->hold_end);
|
||||||
|
c_device->hold_end.notify = handle_pointer_hold_end;
|
||||||
} else if (device->type == WLR_INPUT_DEVICE_TOUCH) {
|
} else if (device->type == WLR_INPUT_DEVICE_TOUCH) {
|
||||||
wl_signal_add(&device->touch->events.motion, &c_device->touch_motion);
|
wl_signal_add(&device->touch->events.motion, &c_device->touch_motion);
|
||||||
c_device->touch_motion.notify = handle_touch_motion;
|
c_device->touch_motion.notify = handle_touch_motion;
|
||||||
|
|
Loading…
Reference in a new issue