feat: add support for wlr_pointer_gestures_v1
This commit is contained in:
3
cursor.c
3
cursor.c
@@ -8,6 +8,7 @@
|
|||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "idle.h"
|
#include "idle.h"
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
|
#include "gestures.h"
|
||||||
|
|
||||||
void diyac_cursor_focus(struct diyac_server *server)
|
void diyac_cursor_focus(struct diyac_server *server)
|
||||||
{
|
{
|
||||||
@@ -444,6 +445,7 @@ void diyac_init_cursor_manager(struct diyac_server *server)
|
|||||||
&server->seat.request_set_shape);
|
&server->seat.request_set_shape);
|
||||||
}
|
}
|
||||||
diyac_touch_init(&server->seat);
|
diyac_touch_init(&server->seat);
|
||||||
|
diyac_gestures_init(&server->seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void diyac_finish_cusor_manager(struct diyac_server *server)
|
void diyac_finish_cusor_manager(struct diyac_server *server)
|
||||||
@@ -459,4 +461,5 @@ void diyac_finish_cusor_manager(struct diyac_server *server)
|
|||||||
wl_list_remove(&server->seat.request_set_primary_selection.link);
|
wl_list_remove(&server->seat.request_set_primary_selection.link);
|
||||||
|
|
||||||
diyac_touch_drop(&server->seat);
|
diyac_touch_drop(&server->seat);
|
||||||
|
diyac_gestures_drop(&server->seat);
|
||||||
}
|
}
|
11
diyac.h
11
diyac.h
@@ -78,7 +78,16 @@ struct diyac_seat
|
|||||||
struct wl_listener touch_frame;
|
struct wl_listener touch_frame;
|
||||||
struct wl_list touch_points; /* struct touch_point.link */
|
struct wl_list touch_points; /* struct touch_point.link */
|
||||||
|
|
||||||
/*TODO: wlr_pointer_gestures_v1*/
|
/*wlr_pointer_gestures_v1*/
|
||||||
|
struct wlr_pointer_gestures_v1 *pointer_gestures;
|
||||||
|
struct wl_listener pinch_begin;
|
||||||
|
struct wl_listener pinch_update;
|
||||||
|
struct wl_listener pinch_end;
|
||||||
|
struct wl_listener swipe_begin;
|
||||||
|
struct wl_listener swipe_update;
|
||||||
|
struct wl_listener swipe_end;
|
||||||
|
struct wl_listener hold_begin;
|
||||||
|
struct wl_listener hold_end;
|
||||||
|
|
||||||
struct wl_listener new_input;
|
struct wl_listener new_input;
|
||||||
struct wl_listener request_cursor;
|
struct wl_listener request_cursor;
|
||||||
|
139
gestures.c
Normal file
139
gestures.c
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
#include <wlr/types/wlr_pointer_gestures_v1.h>
|
||||||
|
#include "gestures.h"
|
||||||
|
#include "idle.h"
|
||||||
|
|
||||||
|
static void gesture_pinch_begin(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct diyac_seat *seat = wl_container_of(listener, seat, pinch_begin);
|
||||||
|
struct wlr_pointer_pinch_begin_event *event = data;
|
||||||
|
|
||||||
|
diya_idle_manager_notify_activity(seat->wlr_seat);
|
||||||
|
// cursor_set_visible(seat, /* visible */ true);
|
||||||
|
|
||||||
|
wlr_pointer_gestures_v1_send_pinch_begin(seat->pointer_gestures,
|
||||||
|
seat->wlr_seat, event->time_msec, event->fingers);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gesture_pinch_update(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct diyac_seat *seat = wl_container_of(listener, seat, pinch_update);
|
||||||
|
struct wlr_pointer_pinch_update_event *event = data;
|
||||||
|
|
||||||
|
diya_idle_manager_notify_activity(seat->wlr_seat);
|
||||||
|
// cursor_set_visible(seat, /* visible */ true);
|
||||||
|
|
||||||
|
wlr_pointer_gestures_v1_send_pinch_update(seat->pointer_gestures,
|
||||||
|
seat->wlr_seat, event->time_msec, event->dx, event->dy,
|
||||||
|
event->scale, event->rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gesture_pinch_end(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct diyac_seat *seat = wl_container_of(listener, seat, pinch_end);
|
||||||
|
struct wlr_pointer_pinch_end_event *event = data;
|
||||||
|
|
||||||
|
diya_idle_manager_notify_activity(seat->wlr_seat);
|
||||||
|
// cursor_set_visible(seat, /* visible */ true);
|
||||||
|
|
||||||
|
wlr_pointer_gestures_v1_send_pinch_end(seat->pointer_gestures,
|
||||||
|
seat->wlr_seat, event->time_msec, event->cancelled);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gesture_swipe_begin(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct diyac_seat *seat = wl_container_of(listener, seat, swipe_begin);
|
||||||
|
struct wlr_pointer_swipe_begin_event *event = data;
|
||||||
|
|
||||||
|
diya_idle_manager_notify_activity(seat->wlr_seat);
|
||||||
|
// cursor_set_visible(seat, /* visible */ true);
|
||||||
|
|
||||||
|
wlr_pointer_gestures_v1_send_swipe_begin(seat->pointer_gestures,
|
||||||
|
seat->wlr_seat, event->time_msec, event->fingers);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gesture_swipe_update(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct diyac_seat *seat = wl_container_of(listener, seat, swipe_update);
|
||||||
|
struct wlr_pointer_swipe_update_event *event = data;
|
||||||
|
|
||||||
|
diya_idle_manager_notify_activity(seat->wlr_seat);
|
||||||
|
// cursor_set_visible(seat, /* visible */ true);
|
||||||
|
|
||||||
|
wlr_pointer_gestures_v1_send_swipe_update(seat->pointer_gestures,
|
||||||
|
seat->wlr_seat, event->time_msec, event->dx, event->dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gesture_swipe_end(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct diyac_seat *seat = wl_container_of(listener, seat, swipe_end);
|
||||||
|
struct wlr_pointer_swipe_end_event *event = data;
|
||||||
|
|
||||||
|
diya_idle_manager_notify_activity(seat->wlr_seat);
|
||||||
|
// cursor_set_visible(seat, /* visible */ true);
|
||||||
|
|
||||||
|
wlr_pointer_gestures_v1_send_swipe_end(seat->pointer_gestures,
|
||||||
|
seat->wlr_seat, event->time_msec, event->cancelled);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gesture_hold_begin(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct diyac_seat *seat = wl_container_of(listener, seat, hold_begin);
|
||||||
|
struct wlr_pointer_hold_begin_event *event = data;
|
||||||
|
|
||||||
|
diya_idle_manager_notify_activity(seat->wlr_seat);
|
||||||
|
// cursor_set_visible(seat, /* visible */ true);
|
||||||
|
|
||||||
|
wlr_pointer_gestures_v1_send_hold_begin(seat->pointer_gestures,
|
||||||
|
seat->wlr_seat, event->time_msec, event->fingers);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gesture_hold_end(struct wl_listener *listener, void *data)
|
||||||
|
{
|
||||||
|
struct diyac_seat *seat = wl_container_of(listener, seat, hold_end);
|
||||||
|
struct wlr_pointer_hold_end_event *event = data;
|
||||||
|
|
||||||
|
diya_idle_manager_notify_activity(seat->wlr_seat);
|
||||||
|
// cursor_set_visible(seat, /* visible */ true);
|
||||||
|
|
||||||
|
wlr_pointer_gestures_v1_send_hold_end(seat->pointer_gestures,
|
||||||
|
seat->wlr_seat, event->time_msec, event->cancelled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void diyac_gestures_init(struct diyac_seat *seat)
|
||||||
|
{
|
||||||
|
seat->pinch_begin.notify = gesture_pinch_begin;
|
||||||
|
wl_signal_add(&seat->cursor->events.pinch_begin, &seat->pinch_begin);
|
||||||
|
|
||||||
|
seat->pinch_update.notify = gesture_pinch_update;
|
||||||
|
wl_signal_add(&seat->cursor->events.pinch_update, &seat->pinch_update);
|
||||||
|
|
||||||
|
seat->pinch_end.notify = gesture_pinch_end;
|
||||||
|
wl_signal_add(&seat->cursor->events.pinch_end, &seat->pinch_end);
|
||||||
|
|
||||||
|
seat->swipe_begin.notify = gesture_swipe_begin;
|
||||||
|
wl_signal_add(&seat->cursor->events.swipe_begin, &seat->swipe_begin);
|
||||||
|
|
||||||
|
seat->swipe_update.notify = gesture_swipe_update;
|
||||||
|
wl_signal_add(&seat->cursor->events.swipe_update, &seat->swipe_update);
|
||||||
|
|
||||||
|
seat->swipe_end.notify = gesture_swipe_end;
|
||||||
|
wl_signal_add(&seat->cursor->events.swipe_end, &seat->swipe_end);
|
||||||
|
|
||||||
|
seat->hold_begin.notify = gesture_hold_begin;
|
||||||
|
wl_signal_add(&seat->cursor->events.hold_begin, &seat->hold_begin);
|
||||||
|
|
||||||
|
seat->hold_end.notify = gesture_hold_end;
|
||||||
|
wl_signal_add(&seat->cursor->events.hold_end, &seat->hold_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
void diyac_gestures_drop(struct diyac_seat *seat)
|
||||||
|
{
|
||||||
|
wl_list_remove(&seat->pinch_begin.link);
|
||||||
|
wl_list_remove(&seat->pinch_update.link);
|
||||||
|
wl_list_remove(&seat->pinch_end.link);
|
||||||
|
wl_list_remove(&seat->swipe_begin.link);
|
||||||
|
wl_list_remove(&seat->swipe_update.link);
|
||||||
|
wl_list_remove(&seat->swipe_end.link);
|
||||||
|
wl_list_remove(&seat->hold_begin.link);
|
||||||
|
wl_list_remove(&seat->hold_end.link);
|
||||||
|
}
|
8
gestures.h
Normal file
8
gestures.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef DIYAC_GESTURES_H
|
||||||
|
#define DIYAC_GESTURES_H
|
||||||
|
|
||||||
|
#include "diyac.h"
|
||||||
|
|
||||||
|
void diyac_gestures_init(struct diyac_seat *seat);
|
||||||
|
void diyac_gestures_drop(struct diyac_seat *seat);
|
||||||
|
#endif
|
@@ -67,6 +67,7 @@ src = [
|
|||||||
'session.c',
|
'session.c',
|
||||||
'idle.c',
|
'idle.c',
|
||||||
'touch.c',
|
'touch.c',
|
||||||
|
'gestures.c',
|
||||||
wayland_targets
|
wayland_targets
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user