aboutsummaryrefslogtreecommitdiff
path: root/src/java.desktop/unix/native/libawt_wlawt/wakefield-client-protocol.h
blob: 3dc9714ad825a4cfde3ba7d05ec0cb65c4e7d834 (plain)
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
/* Generated by wayland-scanner 1.21.0 */

#ifndef WAKEFIELD_CLIENT_PROTOCOL_H
#define WAKEFIELD_CLIENT_PROTOCOL_H

#include <stdint.h>
#include <stddef.h>
#include "wayland-client.h"

#ifdef  __cplusplus
extern "C" {
#endif

/**
 * @page page_wakefield The wakefield protocol
 * @section page_ifaces_wakefield Interfaces
 * - @subpage page_iface_wakefield - provides capabilities necessary to for java.awt.Robot and such
 * @section page_copyright_wakefield Copyright
 * <pre>
 *
 * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
 * Copyright (c) 2022, JetBrains s.r.o.. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 * </pre>
 */
struct wakefield;
struct wl_buffer;
struct wl_surface;

#ifndef WAKEFIELD_INTERFACE
#define WAKEFIELD_INTERFACE
/**
 * @page page_iface_wakefield wakefield
 * @section page_iface_wakefield_desc Description
 * @section page_iface_wakefield_api API
 * See @ref iface_wakefield.
 */
/**
 * @defgroup iface_wakefield The wakefield interface
 */
extern const struct wl_interface wakefield_interface;
#endif

#ifndef WAKEFIELD_ERROR_ENUM
#define WAKEFIELD_ERROR_ENUM
enum wakefield_error {
	/**
	 * error code 0 reserved for the absence of error
	 */
	WAKEFIELD_ERROR_NO_ERROR = 0,
	/**
	 * supplied absolute coordinates point              outside of any output
	 */
	WAKEFIELD_ERROR_INVALID_COORDINATES = 1,
	/**
	 * the request could not be fulfilled due to memory allocation error
	 */
	WAKEFIELD_ERROR_OUT_OF_MEMORY = 2,
	/**
	 * a generic error code for internal errors
	 */
	WAKEFIELD_ERROR_INTERNAL = 3,
	/**
	 * (temporary?) color cannot be converted to RGB format
	 */
	WAKEFIELD_ERROR_FORMAT = 4,
};
#endif /* WAKEFIELD_ERROR_ENUM */

/**
 * @ingroup iface_wakefield
 * @struct wakefield_listener
 */
struct wakefield_listener {
	/**
	 * facilitates implementation of Frame.getLocation()
	 *
	 * This event reveals the absolute coordinates of the surface if
	 * error_code is zero. If error_code is non-zero, (x, y) are
	 * undefined. The surface argument always correspond to that of the
	 * get_surface_location request.
	 */
	void (*surface_location)(void *data,
				 struct wakefield *wakefield,
				 struct wl_surface *surface,
				 int32_t x,
				 int32_t y,
				 uint32_t error_code);
	/**
	 * facilitates implementation of Robot.getPixelColor()
	 *
	 * This event shows the color (24-bit, format r8g8b8) of the
	 * pixel with the given absolute coordinates. The (x, y) arguments
	 * correspond to that of the get_pixel_color request. If error_code
	 * is non-zero, the rgb argument is undefined and the error_code
	 * argument contains a code from the error enum.
	 */
	void (*pixel_color)(void *data,
			    struct wakefield *wakefield,
			    int32_t x,
			    int32_t y,
			    uint32_t rgb,
			    uint32_t error_code);
	/**
	 */
	void (*capture_ready)(void *data,
			      struct wakefield *wakefield,
			      struct wl_buffer *buffer,
			      uint32_t error_code);
};

/**
 * @ingroup iface_wakefield
 */
static inline int
wakefield_add_listener(struct wakefield *wakefield,
		       const struct wakefield_listener *listener, void *data)
{
	return wl_proxy_add_listener((struct wl_proxy *) wakefield,
				     (void (**)(void)) listener, data);
}

#define WAKEFIELD_DESTROY 0
#define WAKEFIELD_MOVE_SURFACE 1
#define WAKEFIELD_GET_SURFACE_LOCATION 2
#define WAKEFIELD_GET_PIXEL_COLOR 3
#define WAKEFIELD_SEND_KEY 4
#define WAKEFIELD_SEND_CURSOR 5
#define WAKEFIELD_SEND_BUTTON 6
#define WAKEFIELD_SEND_WHEEL 7
#define WAKEFIELD_CAPTURE_CREATE 8

/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_SURFACE_LOCATION_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_PIXEL_COLOR_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_CAPTURE_READY_SINCE_VERSION 1

/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_MOVE_SURFACE_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_GET_SURFACE_LOCATION_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_GET_PIXEL_COLOR_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_SEND_KEY_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_SEND_CURSOR_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_SEND_BUTTON_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_SEND_WHEEL_SINCE_VERSION 1
/**
 * @ingroup iface_wakefield
 */
#define WAKEFIELD_CAPTURE_CREATE_SINCE_VERSION 1

/** @ingroup iface_wakefield */
static inline void
wakefield_set_user_data(struct wakefield *wakefield, void *user_data)
{
	wl_proxy_set_user_data((struct wl_proxy *) wakefield, user_data);
}

/** @ingroup iface_wakefield */
static inline void *
wakefield_get_user_data(struct wakefield *wakefield)
{
	return wl_proxy_get_user_data((struct wl_proxy *) wakefield);
}

static inline uint32_t
wakefield_get_version(struct wakefield *wakefield)
{
	return wl_proxy_get_version((struct wl_proxy *) wakefield);
}

/**
 * @ingroup iface_wakefield
 */
static inline void
wakefield_destroy(struct wakefield *wakefield)
{
	wl_proxy_marshal_flags((struct wl_proxy *) wakefield,
			 WAKEFIELD_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wakefield), WL_MARSHAL_FLAG_DESTROY);
}

/**
 * @ingroup iface_wakefield
 *
 * This instructs the window manager to position the given wl_surface
 * at the given absolute coordinates. The subsequent get_surface_location
 * request will return these coordinates unless the surface was moved by
 * a third party.
 */
static inline void
wakefield_move_surface(struct wakefield *wakefield, struct wl_surface *surface, int32_t x, int32_t y)
{
	wl_proxy_marshal_flags((struct wl_proxy *) wakefield,
			 WAKEFIELD_MOVE_SURFACE, NULL, wl_proxy_get_version((struct wl_proxy *) wakefield), 0, surface, x, y);
}

/**
 * @ingroup iface_wakefield
 *
 * This requests a surface_location event for the given surface.
 */
static inline void
wakefield_get_surface_location(struct wakefield *wakefield, struct wl_surface *surface)
{
	wl_proxy_marshal_flags((struct wl_proxy *) wakefield,
			 WAKEFIELD_GET_SURFACE_LOCATION, NULL, wl_proxy_get_version((struct wl_proxy *) wakefield), 0, surface);
}

/**
 * @ingroup iface_wakefield
 *
 * This requests a pixel_color event at the given absolute coordinates.
 */
static inline void
wakefield_get_pixel_color(struct wakefield *wakefield, int32_t x, int32_t y)
{
	wl_proxy_marshal_flags((struct wl_proxy *) wakefield,
			 WAKEFIELD_GET_PIXEL_COLOR, NULL, wl_proxy_get_version((struct wl_proxy *) wakefield), 0, x, y);
}

/**
 * @ingroup iface_wakefield
 *
 * This requests an emulation of a key press by its Linux event key code.
 */
static inline void
wakefield_send_key(struct wakefield *wakefield, uint32_t key, uint32_t state)
{
	wl_proxy_marshal_flags((struct wl_proxy *) wakefield,
			 WAKEFIELD_SEND_KEY, NULL, wl_proxy_get_version((struct wl_proxy *) wakefield), 0, key, state);
}

/**
 * @ingroup iface_wakefield
 *
 * This requests an emulation of the mouse cursor being moved to the specified screen coordinates.
 */
static inline void
wakefield_send_cursor(struct wakefield *wakefield, int32_t x, int32_t y)
{
	wl_proxy_marshal_flags((struct wl_proxy *) wakefield,
			 WAKEFIELD_SEND_CURSOR, NULL, wl_proxy_get_version((struct wl_proxy *) wakefield), 0, x, y);
}

/**
 * @ingroup iface_wakefield
 *
 * This requests an emulation of a mouse button press by its Linux event code.
 */
static inline void
wakefield_send_button(struct wakefield *wakefield, uint32_t button, uint32_t state)
{
	wl_proxy_marshal_flags((struct wl_proxy *) wakefield,
			 WAKEFIELD_SEND_BUTTON, NULL, wl_proxy_get_version((struct wl_proxy *) wakefield), 0, button, state);
}

/**
 * @ingroup iface_wakefield
 *
 * This requests an emulation of a rotation of a mouse scroll wheel.
 */
static inline void
wakefield_send_wheel(struct wakefield *wakefield, int32_t amount)
{
	wl_proxy_marshal_flags((struct wl_proxy *) wakefield,
			 WAKEFIELD_SEND_WHEEL, NULL, wl_proxy_get_version((struct wl_proxy *) wakefield), 0, amount);
}

/**
 * @ingroup iface_wakefield
 */
static inline void
wakefield_capture_create(struct wakefield *wakefield, struct wl_buffer *buffer, int32_t x, int32_t y)
{
	wl_proxy_marshal_flags((struct wl_proxy *) wakefield,
			 WAKEFIELD_CAPTURE_CREATE, NULL, wl_proxy_get_version((struct wl_proxy *) wakefield), 0, buffer, x, y);
}

#ifdef  __cplusplus
}
#endif

#endif