Path: blob/master/thirdparty/linuxbsd_headers/wayland/wayland-client-core.h
9898 views
/*1* Copyright © 2008 Kristian Høgsberg2*3* Permission is hereby granted, free of charge, to any person obtaining4* a copy of this software and associated documentation files (the5* "Software"), to deal in the Software without restriction, including6* without limitation the rights to use, copy, modify, merge, publish,7* distribute, sublicense, and/or sell copies of the Software, and to8* permit persons to whom the Software is furnished to do so, subject to9* the following conditions:10*11* The above copyright notice and this permission notice (including the12* next paragraph) shall be included in all copies or substantial13* portions of the Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,16* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF17* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND18* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS19* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN20* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN21* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE22* SOFTWARE.23*/2425#ifndef WAYLAND_CLIENT_CORE_H26#define WAYLAND_CLIENT_CORE_H2728#include <stdint.h>29#include "wayland-util.h"30#include "wayland-version.h"3132#ifdef __cplusplus33extern "C" {34#endif3536/** \class wl_proxy37*38* \brief Represents a protocol object on the client side.39*40* A wl_proxy acts as a client side proxy to an object existing in the41* compositor. The proxy is responsible for converting requests made by the42* clients with \ref wl_proxy_marshal() into Wayland's wire format. Events43* coming from the compositor are also handled by the proxy, which will in44* turn call the handler set with \ref wl_proxy_add_listener().45*46* \note With the exception of function \ref wl_proxy_set_queue(), functions47* accessing a wl_proxy are not normally used by client code. Clients48* should normally use the higher level interface generated by the scanner to49* interact with compositor objects.50*51*/52struct wl_proxy;5354/** \class wl_display55*56* \brief Represents a connection to the compositor and acts as a proxy to57* the wl_display singleton object.58*59* A wl_display object represents a client connection to a Wayland60* compositor. It is created with either \ref wl_display_connect() or61* \ref wl_display_connect_to_fd(). A connection is terminated using62* \ref wl_display_disconnect().63*64* A wl_display is also used as the \ref wl_proxy for the wl_display65* singleton object on the compositor side.66*67* A wl_display object handles all the data sent from and to the68* compositor. When a \ref wl_proxy marshals a request, it will write its wire69* representation to the display's write buffer. The data is sent to the70* compositor when the client calls \ref wl_display_flush().71*72* Incoming data is handled in two steps: queueing and dispatching. In the73* queue step, the data coming from the display fd is interpreted and74* added to a queue. On the dispatch step, the handler for the incoming75* event set by the client on the corresponding \ref wl_proxy is called.76*77* A wl_display has at least one event queue, called the <em>default78* queue</em>. Clients can create additional event queues with \ref79* wl_display_create_queue() and assign \ref wl_proxy's to it. Events80* occurring in a particular proxy are always queued in its assigned queue.81* A client can ensure that a certain assumption, such as holding a lock82* or running from a given thread, is true when a proxy event handler is83* called by assigning that proxy to an event queue and making sure that84* this queue is only dispatched when the assumption holds.85*86* The default queue is dispatched by calling \ref wl_display_dispatch().87* This will dispatch any events queued on the default queue and attempt88* to read from the display fd if it's empty. Events read are then queued89* on the appropriate queues according to the proxy assignment.90*91* A user created queue is dispatched with \ref wl_display_dispatch_queue().92* This function behaves exactly the same as wl_display_dispatch()93* but it dispatches given queue instead of the default queue.94*95* A real world example of event queue usage is Mesa's implementation of96* eglSwapBuffers() for the Wayland platform. This function might need97* to block until a frame callback is received, but dispatching the default98* queue could cause an event handler on the client to start drawing99* again. This problem is solved using another event queue, so that only100* the events handled by the EGL code are dispatched during the block.101*102* This creates a problem where a thread dispatches a non-default103* queue, reading all the data from the display fd. If the application104* would call \em poll(2) after that it would block, even though there105* might be events queued on the default queue. Those events should be106* dispatched with \ref wl_display_dispatch_pending() or \ref107* wl_display_dispatch_queue_pending() before flushing and blocking.108*/109struct wl_display;110111/** \class wl_event_queue112*113* \brief A queue for \ref wl_proxy object events.114*115* Event queues allows the events on a display to be handled in a thread-safe116* manner. See \ref wl_display for details.117*118*/119struct wl_event_queue;120121/** Destroy proxy after marshalling122* @ingroup wl_proxy123*/124#define WL_MARSHAL_FLAG_DESTROY (1 << 0)125126void127wl_event_queue_destroy(struct wl_event_queue *queue);128129struct wl_proxy *130wl_proxy_marshal_flags(struct wl_proxy *proxy, uint32_t opcode,131const struct wl_interface *interface,132uint32_t version,133uint32_t flags, ...);134135struct wl_proxy *136wl_proxy_marshal_array_flags(struct wl_proxy *proxy, uint32_t opcode,137const struct wl_interface *interface,138uint32_t version,139uint32_t flags,140union wl_argument *args);141142void143wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);144145void146wl_proxy_marshal_array(struct wl_proxy *p, uint32_t opcode,147union wl_argument *args);148149struct wl_proxy *150wl_proxy_create(struct wl_proxy *factory,151const struct wl_interface *interface);152153void *154wl_proxy_create_wrapper(void *proxy);155156void157wl_proxy_wrapper_destroy(void *proxy_wrapper);158159struct wl_proxy *160wl_proxy_marshal_constructor(struct wl_proxy *proxy,161uint32_t opcode,162const struct wl_interface *interface,163...);164165struct wl_proxy *166wl_proxy_marshal_constructor_versioned(struct wl_proxy *proxy,167uint32_t opcode,168const struct wl_interface *interface,169uint32_t version,170...);171172struct wl_proxy *173wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,174uint32_t opcode, union wl_argument *args,175const struct wl_interface *interface);176177struct wl_proxy *178wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *proxy,179uint32_t opcode,180union wl_argument *args,181const struct wl_interface *interface,182uint32_t version);183184void185wl_proxy_destroy(struct wl_proxy *proxy);186187int188wl_proxy_add_listener(struct wl_proxy *proxy,189void (**implementation)(void), void *data);190191const void *192wl_proxy_get_listener(struct wl_proxy *proxy);193194int195wl_proxy_add_dispatcher(struct wl_proxy *proxy,196wl_dispatcher_func_t dispatcher_func,197const void * dispatcher_data, void *data);198199void200wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data);201202void *203wl_proxy_get_user_data(struct wl_proxy *proxy);204205uint32_t206wl_proxy_get_version(struct wl_proxy *proxy);207208uint32_t209wl_proxy_get_id(struct wl_proxy *proxy);210211void212wl_proxy_set_tag(struct wl_proxy *proxy,213const char * const *tag);214215const char * const *216wl_proxy_get_tag(struct wl_proxy *proxy);217218const char *219wl_proxy_get_class(struct wl_proxy *proxy);220221void222wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue);223224struct wl_display *225wl_display_connect(const char *name);226227struct wl_display *228wl_display_connect_to_fd(int fd);229230void231wl_display_disconnect(struct wl_display *display);232233int234wl_display_get_fd(struct wl_display *display);235236int237wl_display_dispatch(struct wl_display *display);238239int240wl_display_dispatch_queue(struct wl_display *display,241struct wl_event_queue *queue);242243int244wl_display_dispatch_queue_pending(struct wl_display *display,245struct wl_event_queue *queue);246247int248wl_display_dispatch_pending(struct wl_display *display);249250int251wl_display_get_error(struct wl_display *display);252253uint32_t254wl_display_get_protocol_error(struct wl_display *display,255const struct wl_interface **interface,256uint32_t *id);257258int259wl_display_flush(struct wl_display *display);260261int262wl_display_roundtrip_queue(struct wl_display *display,263struct wl_event_queue *queue);264265int266wl_display_roundtrip(struct wl_display *display);267268struct wl_event_queue *269wl_display_create_queue(struct wl_display *display);270271int272wl_display_prepare_read_queue(struct wl_display *display,273struct wl_event_queue *queue);274275int276wl_display_prepare_read(struct wl_display *display);277278void279wl_display_cancel_read(struct wl_display *display);280281int282wl_display_read_events(struct wl_display *display);283284void285wl_log_set_handler_client(wl_log_func_t handler);286287#ifdef __cplusplus288}289#endif290291#endif292293294