Implement the pointer-gestures-unstable-v1 protocol

This protocol relays touchpad gesture events produced by libinput to
supporting clients (e.g. Evince, Eye of GNOME).
This commit is contained in:
Greg V 2019-01-26 01:51:38 +03:00 committed by emersion
parent 018727b1fc
commit 9fe8e37961
16 changed files with 790 additions and 0 deletions

View file

@ -54,6 +54,18 @@ void handle_pointer_button(struct libinput_event *event,
struct libinput_device *device);
void handle_pointer_axis(struct libinput_event *event,
struct libinput_device *device);
void handle_pointer_swipe_begin(struct libinput_event *event,
struct libinput_device *device);
void handle_pointer_swipe_update(struct libinput_event *event,
struct libinput_device *device);
void handle_pointer_swipe_end(struct libinput_event *event,
struct libinput_device *device);
void handle_pointer_pinch_begin(struct libinput_event *event,
struct libinput_device *device);
void handle_pointer_pinch_update(struct libinput_event *event,
struct libinput_device *device);
void handle_pointer_pinch_end(struct libinput_event *event,
struct libinput_device *device);
struct wlr_switch *create_libinput_switch(
struct libinput_device *device);

View file

@ -39,6 +39,12 @@ struct roots_cursor {
struct wl_listener button;
struct wl_listener axis;
struct wl_listener frame;
struct wl_listener swipe_begin;
struct wl_listener swipe_update;
struct wl_listener swipe_end;
struct wl_listener pinch_begin;
struct wl_listener pinch_update;
struct wl_listener pinch_end;
struct wl_listener touch_down;
struct wl_listener touch_up;

View file

@ -15,6 +15,7 @@
#include <wlr/types/wlr_list.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/types/wlr_relative_pointer_v1.h>
@ -67,6 +68,7 @@ struct roots_desktop {
struct wlr_presentation *presentation;
struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager_v1;
struct wlr_relative_pointer_manager_v1 *relative_pointer_manager;
struct wlr_pointer_gestures_v1 *pointer_gestures;
struct wl_listener new_output;
struct wl_listener layout_change;

View file

@ -25,6 +25,7 @@ install_headers(
'wlr_output_layout.h',
'wlr_output.h',
'wlr_pointer_constraints_v1.h',
'wlr_pointer_gestures_v1.h',
'wlr_pointer.h',
'wlr_presentation_time.h',
'wlr_primary_selection.h',

View file

@ -52,6 +52,12 @@ struct wlr_cursor {
struct wl_signal button;
struct wl_signal axis;
struct wl_signal frame;
struct wl_signal swipe_begin;
struct wl_signal swipe_update;
struct wl_signal swipe_end;
struct wl_signal pinch_begin;
struct wl_signal pinch_update;
struct wl_signal pinch_end;
struct wl_signal touch_up;
struct wl_signal touch_down;

View file

@ -24,6 +24,12 @@ struct wlr_pointer {
struct wl_signal button;
struct wl_signal axis;
struct wl_signal frame;
struct wl_signal swipe_begin;
struct wl_signal swipe_update;
struct wl_signal swipe_end;
struct wl_signal pinch_begin;
struct wl_signal pinch_update;
struct wl_signal pinch_end;
} events;
void *data;
@ -71,4 +77,50 @@ struct wlr_event_pointer_axis {
int32_t delta_discrete;
};
struct wlr_event_pointer_swipe_begin {
struct wlr_input_device *device;
uint32_t time_msec;
uint32_t fingers;
};
struct wlr_event_pointer_swipe_update {
struct wlr_input_device *device;
uint32_t time_msec;
uint32_t fingers;
// Relative coordinates of the logical center of the gesture
// compared to the previous event.
double dx, dy;
};
struct wlr_event_pointer_swipe_end {
struct wlr_input_device *device;
uint32_t time_msec;
bool cancelled;
};
struct wlr_event_pointer_pinch_begin {
struct wlr_input_device *device;
uint32_t time_msec;
uint32_t fingers;
};
struct wlr_event_pointer_pinch_update {
struct wlr_input_device *device;
uint32_t time_msec;
uint32_t fingers;
// Relative coordinates of the logical center of the gesture
// compared to the previous event.
double dx, dy;
// Absolute scale compared to the begin event
double scale;
// Relative angle in degrees clockwise compared to the previous event.
double rotation;
};
struct wlr_event_pointer_pinch_end {
struct wlr_input_device *device;
uint32_t time_msec;
bool cancelled;
};
#endif

View file

@ -0,0 +1,73 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_TYPES_WLR_POINTER_GESTURES_V1_H
#define WLR_TYPES_WLR_POINTER_GESTURES_V1_H
#include <wayland-server.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_surface.h>
struct wlr_pointer_gestures_v1 {
struct wl_global *global;
struct wl_list resources; // wl_resource_get_link
struct wl_list swipes; // wl_resource_get_link
struct wl_list pinches; // wl_resource_get_link
struct wl_listener display_destroy;
struct {
struct wl_signal destroy;
} events;
void *data;
};
struct wlr_pointer_gestures_v1 *wlr_pointer_gestures_v1_create(
struct wl_display *display);
void wlr_pointer_gestures_v1_send_swipe_begin(
struct wlr_pointer_gestures_v1 *gestures,
struct wlr_seat *seat,
uint32_t time_msec,
uint32_t fingers);
void wlr_pointer_gestures_v1_send_swipe_update(
struct wlr_pointer_gestures_v1 *gestures,
struct wlr_seat *seat,
uint32_t time_msec,
double dx,
double dy);
void wlr_pointer_gestures_v1_send_swipe_end(
struct wlr_pointer_gestures_v1 *gestures,
struct wlr_seat *seat,
uint32_t time_msec,
bool cancelled);
void wlr_pointer_gestures_v1_send_pinch_begin(
struct wlr_pointer_gestures_v1 *gestures,
struct wlr_seat *seat,
uint32_t time_msec,
uint32_t fingers);
void wlr_pointer_gestures_v1_send_pinch_update(
struct wlr_pointer_gestures_v1 *gestures,
struct wlr_seat *seat,
uint32_t time_msec,
double dx,
double dy,
double scale,
double rotation);
void wlr_pointer_gestures_v1_send_pinch_end(
struct wlr_pointer_gestures_v1 *gestures,
struct wlr_seat *seat,
uint32_t time_msec,
bool cancelled);
void wlr_pointer_gestures_v1_destroy(
struct wlr_pointer_gestures_v1 *pointer_gestures_v1);
#endif