130
130
wl_client_post_no_memory(struct wl_client *client);
132
/** \class wl_listener
134
* \brief A single listener for Wayland signals
136
* wl_listener provides the means to listen for wl_signal notifications. Many
137
* Wayland objects use wl_listener for notification of significant events like
138
* object destruction.
140
* Clients should create wl_listener objects manually and can register them as
141
* listeners to signals using #wl_signal_add, assuming the signal is
142
* directly accessible. For opaque structs like wl_event_loop, adding a
143
* listener should be done through provided accessor methods. A listener can
144
* only listen to one signal at a time.
147
* struct wl_listener your_listener;
149
* your_listener.notify = your_callback_method;
151
* \comment{Direct access}
152
* wl_signal_add(&some_object->destroy_signal, &your_listener);
154
* \comment{Accessor access}
155
* wl_event_loop *loop = ...;
156
* wl_event_loop_add_destroy_listener(loop, &your_listener);
159
* If the listener is part of a larger struct, #wl_container_of can be used
160
* to retrieve a pointer to it:
163
* void your_listener(struct wl_listener *listener, void *data)
165
* struct your_data *data = NULL;
167
* your_data = wl_container_of(listener, data, your_member_name);
171
* If you need to remove a listener from a signal, use #wl_list_remove.
174
* wl_list_remove(&your_listener.link);
132
179
struct wl_listener {
133
180
struct wl_list link;
134
181
wl_notify_func_t notify;
186
* \brief A source of a type of observable event
188
* Signals are recognized points where significant events can be observed.
189
* Compositors as well as the server can provide signals. Observers are
190
* wl_listener's that are added through #wl_signal_add. Signals are emitted
191
* using #wl_signal_emit, which will invoke all listeners until that
192
* listener is removed by #wl_list_remove (or whenever the signal is
195
* \sa wl_listener for more information on using wl_signal
137
197
struct wl_signal {
138
198
struct wl_list listener_list;
201
/** Initialize a new \ref wl_signal for use.
203
* \param signal The signal that will be initialized
205
* \memberof wl_signal
141
207
static inline void
142
208
wl_signal_init(struct wl_signal *signal)
144
210
wl_list_init(&signal->listener_list);
213
/** Add the specified listener to this signal.
215
* \param signal The signal that will emit events to the listener
216
* \param listener The listener to add
218
* \memberof wl_signal
147
220
static inline void
148
221
wl_signal_add(struct wl_signal *signal, struct wl_listener *listener)
150
223
wl_list_insert(signal->listener_list.prev, &listener->link);
226
/** Gets the listener struct for the specified callback.
228
* \param signal The signal that contains the specified listener
229
* \param notify The listener that is the target of this search
230
* \return the list item that corresponds to the specified listener, or NULL
233
* \memberof wl_signal
153
235
static inline struct wl_listener *
154
236
wl_signal_get(struct wl_signal *signal, wl_notify_func_t notify)
242
331
void wl_resource_post_event(struct wl_resource *resource,
243
332
uint32_t opcode, ...);
333
void wl_resource_post_event_array(struct wl_resource *resource,
334
uint32_t opcode, union wl_argument *args);
244
335
void wl_resource_queue_event(struct wl_resource *resource,
245
336
uint32_t opcode, ...);
337
void wl_resource_queue_event_array(struct wl_resource *resource,
338
uint32_t opcode, union wl_argument *args);
247
340
/* msg is a printf format string, variable args are its args. */
248
341
void wl_resource_post_error(struct wl_resource *resource,
264
357
const void *implementation,
266
359
wl_resource_destroy_func_t destroy);
361
wl_resource_set_dispatcher(struct wl_resource *resource,
362
wl_dispatcher_func_t dispatcher,
363
const void *implementation,
365
wl_resource_destroy_func_t destroy);
269
368
wl_resource_destroy(struct wl_resource *resource);
298
397
wl_resource_get_destroy_listener(struct wl_resource *resource,
299
398
wl_notify_func_t notify);
400
#define wl_resource_for_each(resource, list) \
401
for (resource = 0, resource = wl_resource_from_link((list)->next); \
402
wl_resource_get_link(resource) != (list); \
403
resource = wl_resource_from_link(wl_resource_get_link(resource)->next))
405
#define wl_resource_for_each_safe(resource, tmp, list) \
406
for (resource = 0, tmp = 0, \
407
resource = wl_resource_from_link((list)->next), \
408
tmp = wl_resource_from_link((list)->next->next); \
409
wl_resource_get_link(resource) != (list); \
411
tmp = wl_resource_from_link(wl_resource_get_link(resource)->next))
301
413
struct wl_shm_buffer;
303
415
struct wl_shm_buffer *