File: wlr_pointer.h

package info (click to toggle)
wlroots 0.19.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,592 kB
  • sloc: ansic: 75,766; xml: 2,739; sh: 33; makefile: 23
file content (152 lines) | stat: -rw-r--r-- 3,765 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * 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_H
#define WLR_TYPES_WLR_POINTER_H

#include <stdint.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <wlr/types/wlr_input_device.h>

#define WLR_POINTER_BUTTONS_CAP 16

struct wlr_pointer_impl;

struct wlr_pointer {
	struct wlr_input_device base;

	const struct wlr_pointer_impl *impl;

	char *output_name;

	uint32_t buttons[WLR_POINTER_BUTTONS_CAP];
	size_t button_count;

	struct {
		struct wl_signal motion; // struct wlr_pointer_motion_event
		struct wl_signal motion_absolute; // struct wlr_pointer_motion_absolute_event
		struct wl_signal button; // struct wlr_pointer_button_event
		struct wl_signal axis; // struct wlr_pointer_axis_event
		struct wl_signal frame;

		struct wl_signal swipe_begin; // struct wlr_pointer_swipe_begin_event
		struct wl_signal swipe_update; // struct wlr_pointer_swipe_update_event
		struct wl_signal swipe_end; // struct wlr_pointer_swipe_end_event

		struct wl_signal pinch_begin; // struct wlr_pointer_pinch_begin_event
		struct wl_signal pinch_update; // struct wlr_pointer_pinch_update_event
		struct wl_signal pinch_end; // struct wlr_pointer_pinch_end_event

		struct wl_signal hold_begin; // struct wlr_pointer_hold_begin_event
		struct wl_signal hold_end; // struct wlr_pointer_hold_end_event
	} events;

	void *data;
};

struct wlr_pointer_motion_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	double delta_x, delta_y;
	double unaccel_dx, unaccel_dy;
};

struct wlr_pointer_motion_absolute_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	// From 0..1
	double x, y;
};

struct wlr_pointer_button_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	uint32_t button;
	enum wl_pointer_button_state state;
};

#define WLR_POINTER_AXIS_DISCRETE_STEP 120

struct wlr_pointer_axis_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	enum wl_pointer_axis_source source;
	enum wl_pointer_axis orientation;
	enum wl_pointer_axis_relative_direction relative_direction;
	double delta;
	int32_t delta_discrete;
};

struct wlr_pointer_swipe_begin_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	uint32_t fingers;
};

struct wlr_pointer_swipe_update_event {
	struct wlr_pointer *pointer;
	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_pointer_swipe_end_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	bool cancelled;
};

struct wlr_pointer_pinch_begin_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	uint32_t fingers;
};

struct wlr_pointer_pinch_update_event {
	struct wlr_pointer *pointer;
	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_pointer_pinch_end_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	bool cancelled;
};

struct wlr_pointer_hold_begin_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	uint32_t fingers;
};

struct wlr_pointer_hold_end_event {
	struct wlr_pointer *pointer;
	uint32_t time_msec;
	bool cancelled;
};

/**
 * Get a struct wlr_pointer from a struct wlr_input_device.
 *
 * Asserts that the input device is a pointer.
 */
struct wlr_pointer *wlr_pointer_from_input_device(
	struct wlr_input_device *input_device);

#endif