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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
/*
* Copyright © 2019 Advanced Driver Information Technology GmbH
* Copyright © 2020 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "wth-receiver-comm.h"
#include "wth-receiver-seat.h"
/*
* APIs to send touch events to waltham client
*/
void
waltham_touch_down(struct window *window, uint32_t serial,
uint32_t time, int32_t id,
wl_fixed_t x_w, wl_fixed_t y_w)
{
struct seat *seat = window->receiver_seat;
struct touch *touch = seat->touch;
struct surface *surface = window->receiver_surf;
if (!touch) {
fprintf(stderr, "We do not have touch device!\n");
return;
}
if (touch->obj) {
wthp_touch_send_down(touch->obj, serial, time, surface->obj, id, x_w, y_w);
}
return;
}
void
waltham_touch_up(struct window *window, uint32_t serial,
uint32_t time, int32_t id)
{
struct seat *seat = window->receiver_seat;
struct touch *touch = seat->touch;
if (!touch) {
fprintf(stderr, "We do not have touch device!\n");
return;
}
if (touch->obj) {
wthp_touch_send_up(touch->obj, serial, time, id);
}
return;
}
void
waltham_touch_motion(struct window *window, uint32_t time,
int32_t id, wl_fixed_t x_w, wl_fixed_t y_w)
{
struct seat *seat = window->receiver_seat;
struct touch *touch = seat->touch;
if (!touch) {
fprintf(stderr, "We do not have touch device!\n");
return;
}
if (touch->obj) {
wthp_touch_send_motion(touch->obj, time, id, x_w, y_w);
}
}
void
waltham_touch_frame(struct window *window)
{
struct seat *seat = window->receiver_seat;
struct touch *touch = seat->touch;
if (!touch) {
fprintf(stderr, "We do not have touch device!\n");
return;
}
if (touch->obj) {
wthp_touch_send_frame(touch->obj);
}
}
void
waltham_touch_cancel(struct window *window)
{
struct seat *seat = window->receiver_seat;
struct touch *touch = seat->touch;
if (!touch) {
fprintf(stderr, "We do not have touch device!\n");
return;
}
if (touch->obj) {
fprintf(stdout, "waltham_touch_cancel() sending cancel\n");
wthp_touch_send_cancel(touch->obj);
}
}
/*
* APIs to send pointer events to waltham client
*/
void
waltham_pointer_enter(struct window *window, uint32_t serial,
wl_fixed_t sx, wl_fixed_t sy)
{
struct surface *surface = window->receiver_surf;
struct seat *seat = window->receiver_seat;
struct pointer *pointer = seat->pointer;
if (!pointer) {
fprintf(stderr, "We do not have pointer device!\n");
return;
}
if (pointer && pointer->obj) {
fprintf(stdout, "waltham_pointer_enter() sending enter\n");
wthp_pointer_send_enter(pointer->obj, serial, surface->obj, sx, sy);
}
}
void
waltham_pointer_leave(struct window *window, uint32_t serial)
{
struct surface *surface = window->receiver_surf;
struct seat *seat = window->receiver_seat;
struct pointer *pointer = seat->pointer;
if (!pointer) {
fprintf(stderr, "We do not have pointer device!\n");
return;
}
if (pointer && pointer->obj) {
fprintf(stdout, "waltham_pointer_leave() sending leave\n");
wthp_pointer_send_leave(pointer->obj, serial, surface->obj);
}
}
void
waltham_pointer_motion(struct window *window, uint32_t time,
wl_fixed_t sx, wl_fixed_t sy)
{
struct seat *seat = window->receiver_seat;
struct pointer *pointer = seat->pointer;
if (!pointer) {
fprintf(stderr, "We do not have pointer device!\n");
return;
}
if (pointer && pointer->obj) {
fprintf(stdout, "waltham_pointer_motion() sending motion\n");
wthp_pointer_send_motion(pointer->obj, time, sx, sy);
}
}
void
waltham_pointer_button(struct window *window, uint32_t serial,
uint32_t time, uint32_t button,
uint32_t state)
{
struct seat *seat = window->receiver_seat;
struct pointer *pointer = seat->pointer;
if (!pointer) {
fprintf(stderr, "We do not have pointer device!\n");
return;
}
if (pointer && pointer->obj) {
fprintf(stdout, "waltham_pointer_button() sending button\n");
wthp_pointer_send_button(pointer->obj, serial, time, button, state);
}
}
void
waltham_pointer_axis(struct window *window, uint32_t time,
uint32_t axis, wl_fixed_t value)
{
struct seat *seat = window->receiver_seat;
struct pointer *pointer = seat->pointer;
if (!pointer) {
fprintf(stderr, "We do not have pointer device!\n");
return;
}
if (pointer && pointer->obj) {
fprintf(stdout, "waltham_pointer_axis() sending pointer_axis\n");
wthp_pointer_send_axis(pointer->obj, time, axis, value);
}
}
/*
* waltham seat implementation
*/
/*
* waltham touch implementation
*/
static void
touch_release(struct wthp_touch *wthp_touch)
{
struct touch *touch = wth_object_get_user_data((struct wth_object *)wthp_touch);
fprintf(stdout, "touch_release %p touch %p\n", wthp_touch, touch);
}
static const struct wthp_touch_interface touch_implementation = {
touch_release,
};
/*
* waltham pointer implementation
*/
static void
pointer_set_cursor(struct wthp_pointer *wthp_pointer, uint32_t serial, struct wthp_surface *surface,
int32_t hotspot_x, int32_t hotspot_y)
{
}
static void
pointer_release(struct wthp_pointer *wthp_pointer)
{
}
static const struct wthp_pointer_interface pointer_implementation = {
pointer_set_cursor,
pointer_release
};
static void
seat_get_pointer(struct wthp_seat *wthp_seat, struct wthp_pointer *wthp_pointer)
{
fprintf(stdout, "wthp_seat %p get_pointer(%p)\n", wthp_seat, wthp_pointer);
struct seat *seat = wth_object_get_user_data((struct wth_object *)wthp_seat);
struct pointer *pointer;
pointer = zalloc(sizeof *pointer);
if (!pointer) {
client_post_out_of_memory(seat->client);
return;
}
pointer->obj = wthp_pointer;
pointer->seat = seat;
seat->pointer = pointer;
wl_list_insert(&seat->client->pointer_list, &pointer->link);
wthp_pointer_set_interface(wthp_pointer, &pointer_implementation, pointer);
}
static void
seat_get_touch(struct wthp_seat *wthp_seat, struct wthp_touch *wthp_touch)
{
struct seat *seat = wth_object_get_user_data((struct wth_object *)wthp_seat);
struct touch *touch;
fprintf(stdout, "wthp_seat %p get_touch(%p)\n", wthp_seat, wthp_touch);
touch = zalloc(sizeof(*touch));
if (!touch) {
client_post_out_of_memory(seat->client);
return;
}
touch->obj = wthp_touch;
touch->seat = seat;
seat->touch = touch;
fprintf(stdout, "seat_get_touch() with obj %p\n", touch->obj);
wl_list_insert(&seat->client->touch_list, &touch->link);
wthp_touch_set_interface(wthp_touch, &touch_implementation, touch);
}
static void
seat_get_keyboard(struct wthp_seat *wthp_seat, struct wthp_keyboard *kid)
{
(void) wthp_seat;
(void) kid;
}
static void
seat_release(struct wthp_seat *wthp_seat)
{
}
static const struct wthp_seat_interface seat_implementation = {
seat_get_pointer,
seat_get_keyboard,
seat_get_touch,
seat_release,
};
void
seat_send_updated_caps(struct seat *seat)
{
enum wthp_seat_capability caps = 0;
caps |= WTHP_SEAT_CAPABILITY_POINTER;
fprintf(stdout, "WTHP_SEAT_CAPABILITY_POINTER %d\n", caps);
caps |= WTHP_SEAT_CAPABILITY_TOUCH;
fprintf(stdout, "WTHP_SEAT_CAPABILITY_TOUCH %d\n", caps);
wthp_seat_send_capabilities(seat->obj, caps);
}
void
client_bind_seat(struct client *c, struct wthp_seat *obj)
{
struct seat *seat;
seat = zalloc(sizeof *seat);
if (!seat) {
client_post_out_of_memory(c);
return;
}
seat->obj = obj;
seat->client = c;
wl_list_insert(&c->seat_list, &seat->link);
wthp_seat_set_interface(obj, &seat_implementation, seat);
seat_send_updated_caps(seat);
}
|