AtlatestRepositorysigil-ui
1
/*2
* Copyright © 2008 Kristian Høgsberg3
*4
* Permission is hereby granted, free of charge, to any person obtaining5
* a copy of this software and associated documentation files (the6
* "Software"), to deal in the Software without restriction, including7
* without limitation the rights to use, copy, modify, merge, publish,8
* distribute, sublicense, and/or sell copies of the Software, and to9
* permit persons to whom the Software is furnished to do so, subject to10
* the following conditions:11
*12
* The above copyright notice and this permission notice (including the13
* next paragraph) shall be included in all copies or substantial14
* portions of the Software.15
*16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,17
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF18
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND19
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS20
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN21
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN22
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE23
* SOFTWARE.24
*/26
#ifndef WAYLAND_CLIENT_CORE_H27
#define WAYLAND_CLIENT_CORE_H29
#include <stdint.h>30
#include "wayland-util.h"31
#include "wayland-version.h"33
#ifdef __cplusplus34
extern "C" {35
#endif37
struct timespec;39
/** \class wl_proxy40
*41
* \brief Represents a protocol object on the client side.42
*43
* A wl_proxy acts as a client side proxy to an object existing in the44
* compositor. The proxy is responsible for converting requests made by the45
* clients with \ref wl_proxy_marshal() into Wayland's wire format. Events46
* coming from the compositor are also handled by the proxy, which will in47
* turn call the handler set with \ref wl_proxy_add_listener().48
*49
* \note With the exception of function \ref wl_proxy_set_queue(), functions50
* accessing a wl_proxy are not normally used by client code. Clients51
* should normally use the higher level interface generated by the scanner to52
* interact with compositor objects.53
*54
*/55
struct wl_proxy;57
/** \class wl_display58
*59
* \brief Represents a connection to the compositor and acts as a proxy to60
* the wl_display singleton object.61
*62
* A wl_display object represents a client connection to a Wayland63
* compositor. It is created with either \ref wl_display_connect() or64
* \ref wl_display_connect_to_fd(). A connection is terminated using65
* \ref wl_display_disconnect().66
*67
* A wl_display is also used as the \ref wl_proxy for the wl_display68
* singleton object on the compositor side.69
*70
* A wl_display object handles all the data sent from and to the71
* compositor. When a \ref wl_proxy marshals a request, it will write its wire72
* representation to the display's write buffer. The data is sent to the73
* compositor when the client calls \ref wl_display_flush().74
*75
* Incoming data is handled in two steps: queueing and dispatching. In the76
* queue step, the data coming from the display fd is interpreted and77
* added to a queue. On the dispatch step, the handler for the incoming78
* event set by the client on the corresponding \ref wl_proxy is called.79
*80
* A wl_display has at least one event queue, called the <em>default81
* queue</em>. Clients can create additional event queues with \ref82
* wl_display_create_queue() and assign \ref wl_proxy's to it. Events83
* occurring in a particular proxy are always queued in its assigned queue.84
* A client can ensure that a certain assumption, such as holding a lock85
* or running from a given thread, is true when a proxy event handler is86
* called by assigning that proxy to an event queue and making sure that87
* this queue is only dispatched when the assumption holds.88
*89
* The default queue is dispatched by calling \ref wl_display_dispatch().90
* This will dispatch any events queued on the default queue and attempt91
* to read from the display fd if it's empty. Events read are then queued92
* on the appropriate queues according to the proxy assignment.93
*94
* A user created queue is dispatched with \ref wl_display_dispatch_queue().95
* This function behaves exactly the same as wl_display_dispatch()96
* but it dispatches given queue instead of the default queue.97
*98
* A real world example of event queue usage is Mesa's implementation of99
* eglSwapBuffers() for the Wayland platform. This function might need100
* to block until a frame callback is received, but dispatching the default101
* queue could cause an event handler on the client to start drawing102
* again. This problem is solved using another event queue, so that only103
* the events handled by the EGL code are dispatched during the block.104
*105
* This creates a problem where a thread dispatches a non-default106
* queue, reading all the data from the display fd. If the application107
* would call \em poll(2) after that it would block, even though there108
* might be events queued on the default queue. Those events should be109
* dispatched with \ref wl_display_dispatch_pending() or \ref110
* wl_display_dispatch_queue_pending() before flushing and blocking.111
*/112
struct wl_display;114
/** \class wl_event_queue115
*116
* \brief A queue for \ref wl_proxy object events.117
*118
* Event queues allows the events on a display to be handled in a thread-safe119
* manner. See \ref wl_display for details.120
*121
*/122
struct wl_event_queue;124
/** Destroy proxy after marshalling125
* \relates wl_proxy126
*/127
#define WL_MARSHAL_FLAG_DESTROY (1 << 0)129
void130
wl_event_queue_destroy(struct wl_event_queue *queue);132
struct wl_proxy *133
wl_proxy_marshal_flags(struct wl_proxy *proxy, uint32_t opcode,134
const struct wl_interface *interface,135
uint32_t version,136
uint32_t flags, ...);138
struct wl_proxy *139
wl_proxy_marshal_array_flags(struct wl_proxy *proxy, uint32_t opcode,140
const struct wl_interface *interface,141
uint32_t version,142
uint32_t flags,143
union wl_argument *args);145
void146
wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);148
void149
wl_proxy_marshal_array(struct wl_proxy *p, uint32_t opcode,150
union wl_argument *args);152
struct wl_proxy *153
wl_proxy_create(struct wl_proxy *factory,154
const struct wl_interface *interface);156
void *157
wl_proxy_create_wrapper(void *proxy);159
void160
wl_proxy_wrapper_destroy(void *proxy_wrapper);162
struct wl_proxy *163
wl_proxy_marshal_constructor(struct wl_proxy *proxy,164
uint32_t opcode,165
const struct wl_interface *interface,166
...);168
struct wl_proxy *169
wl_proxy_marshal_constructor_versioned(struct wl_proxy *proxy,170
uint32_t opcode,171
const struct wl_interface *interface,172
uint32_t version,173
...);175
struct wl_proxy *176
wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,177
uint32_t opcode, union wl_argument *args,178
const struct wl_interface *interface);180
struct wl_proxy *181
wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *proxy,182
uint32_t opcode,183
union wl_argument *args,184
const struct wl_interface *interface,185
uint32_t version);187
void188
wl_proxy_destroy(struct wl_proxy *proxy);190
int191
wl_proxy_add_listener(struct wl_proxy *proxy,192
void (**implementation)(void), void *data);194
const void *195
wl_proxy_get_listener(struct wl_proxy *proxy);197
int198
wl_proxy_add_dispatcher(struct wl_proxy *proxy,199
wl_dispatcher_func_t dispatcher_func,200
const void * dispatcher_data, void *data);202
void203
wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data);205
void *206
wl_proxy_get_user_data(struct wl_proxy *proxy);208
uint32_t209
wl_proxy_get_version(struct wl_proxy *proxy);211
uint32_t212
wl_proxy_get_id(struct wl_proxy *proxy);214
void215
wl_proxy_set_tag(struct wl_proxy *proxy,216
const char * const *tag);218
const char * const *219
wl_proxy_get_tag(struct wl_proxy *proxy);221
const char *222
wl_proxy_get_class(struct wl_proxy *proxy);224
const struct wl_interface *225
wl_proxy_get_interface(struct wl_proxy *proxy);227
struct wl_display *228
wl_proxy_get_display(struct wl_proxy *proxy);230
void231
wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue);233
struct wl_event_queue *234
wl_proxy_get_queue(const struct wl_proxy *proxy);236
const char *237
wl_event_queue_get_name(const struct wl_event_queue *queue);239
struct wl_display *240
wl_display_connect(const char *name);242
struct wl_display *243
wl_display_connect_to_fd(int fd);245
void246
wl_display_disconnect(struct wl_display *display);248
int249
wl_display_get_fd(struct wl_display *display);251
int252
wl_display_dispatch(struct wl_display *display);254
int255
wl_display_dispatch_queue(struct wl_display *display,256
struct wl_event_queue *queue);258
int259
wl_display_dispatch_timeout(struct wl_display *display,260
const struct timespec *timeout);262
int263
wl_display_dispatch_queue_timeout(struct wl_display *display,264
struct wl_event_queue *queue,265
const struct timespec *timeout);267
int268
wl_display_dispatch_queue_pending(struct wl_display *display,269
struct wl_event_queue *queue);271
int272
wl_display_dispatch_pending(struct wl_display *display);274
int275
wl_display_get_error(struct wl_display *display);277
uint32_t278
wl_display_get_protocol_error(struct wl_display *display,279
const struct wl_interface **interface,280
uint32_t *id);282
int283
wl_display_flush(struct wl_display *display);285
int286
wl_display_roundtrip_queue(struct wl_display *display,287
struct wl_event_queue *queue);289
int290
wl_display_roundtrip(struct wl_display *display);292
struct wl_event_queue *293
wl_display_create_queue(struct wl_display *display);295
struct wl_event_queue *296
wl_display_create_queue_with_name(struct wl_display *display,297
const char *name);299
int300
wl_display_prepare_read_queue(struct wl_display *display,301
struct wl_event_queue *queue);303
int304
wl_display_prepare_read(struct wl_display *display);306
void307
wl_display_cancel_read(struct wl_display *display);309
int310
wl_display_read_events(struct wl_display *display);312
void313
wl_log_set_handler_client(wl_log_func_t handler);315
void316
wl_display_set_max_buffer_size(struct wl_display *display,317
size_t max_buffer_size);319
#ifdef __cplusplus320
}321
#endif323
#endif