1 /*
2  * This an unstable interface of wlroots. No guarantees are made regarding the
3  * future consistency of this API.
4  */
5 #ifndef WLR_USE_UNSTABLE
6 #error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
7 #endif
8 
9 #ifndef WLR_TYPES_WLR_POINTER_H
10 #define WLR_TYPES_WLR_POINTER_H
11 
12 #include <stdint.h>
13 #include <wayland-server-core.h>
14 #include <wlr/types/wlr_input_device.h>
15 
16 struct wlr_pointer_impl;
17 
18 struct wlr_pointer {
19 	const struct wlr_pointer_impl *impl;
20 
21 	struct {
22 		struct wl_signal motion;
23 		struct wl_signal motion_absolute;
24 		struct wl_signal button;
25 		struct wl_signal axis;
26 		struct wl_signal frame;
27 		struct wl_signal swipe_begin;
28 		struct wl_signal swipe_update;
29 		struct wl_signal swipe_end;
30 		struct wl_signal pinch_begin;
31 		struct wl_signal pinch_update;
32 		struct wl_signal pinch_end;
33 	} events;
34 
35 	void *data;
36 };
37 
38 struct wlr_event_pointer_motion {
39 	struct wlr_input_device *device;
40 	uint32_t time_msec;
41 	double delta_x, delta_y;
42 	double unaccel_dx, unaccel_dy;
43 };
44 
45 struct wlr_event_pointer_motion_absolute {
46 	struct wlr_input_device *device;
47 	uint32_t time_msec;
48 	// From 0..1
49 	double x, y;
50 };
51 
52 struct wlr_event_pointer_button {
53 	struct wlr_input_device *device;
54 	uint32_t time_msec;
55 	uint32_t button;
56 	enum wlr_button_state state;
57 };
58 
59 enum wlr_axis_source {
60 	WLR_AXIS_SOURCE_WHEEL,
61 	WLR_AXIS_SOURCE_FINGER,
62 	WLR_AXIS_SOURCE_CONTINUOUS,
63 	WLR_AXIS_SOURCE_WHEEL_TILT,
64 };
65 
66 enum wlr_axis_orientation {
67 	WLR_AXIS_ORIENTATION_VERTICAL,
68 	WLR_AXIS_ORIENTATION_HORIZONTAL,
69 };
70 
71 struct wlr_event_pointer_axis {
72 	struct wlr_input_device *device;
73 	uint32_t time_msec;
74 	enum wlr_axis_source source;
75 	enum wlr_axis_orientation orientation;
76 	double delta;
77 	int32_t delta_discrete;
78 };
79 
80 struct wlr_event_pointer_swipe_begin {
81 	struct wlr_input_device *device;
82 	uint32_t time_msec;
83 	uint32_t fingers;
84 };
85 
86 struct wlr_event_pointer_swipe_update {
87 	struct wlr_input_device *device;
88 	uint32_t time_msec;
89 	uint32_t fingers;
90 	// Relative coordinates of the logical center of the gesture
91 	// compared to the previous event.
92 	double dx, dy;
93 };
94 
95 struct wlr_event_pointer_swipe_end {
96 	struct wlr_input_device *device;
97 	uint32_t time_msec;
98 	bool cancelled;
99 };
100 
101 struct wlr_event_pointer_pinch_begin {
102 	struct wlr_input_device *device;
103 	uint32_t time_msec;
104 	uint32_t fingers;
105 };
106 
107 struct wlr_event_pointer_pinch_update {
108 	struct wlr_input_device *device;
109 	uint32_t time_msec;
110 	uint32_t fingers;
111 	// Relative coordinates of the logical center of the gesture
112 	// compared to the previous event.
113 	double dx, dy;
114 	// Absolute scale compared to the begin event
115 	double scale;
116 	// Relative angle in degrees clockwise compared to the previous event.
117 	double rotation;
118 };
119 
120 struct wlr_event_pointer_pinch_end {
121 	struct wlr_input_device *device;
122 	uint32_t time_msec;
123 	bool cancelled;
124 };
125 
126 #endif
127