Lines Matching refs:proxy
82 struct wl_proxy proxy;
97 /* id of the proxy that caused the error. There's no warranty
98 * that the proxy is still valid. It's up to client how it will
231 struct wl_proxy *proxy;
240 proxy = (struct wl_proxy *) closure->args[i].o;
241 if (proxy) {
242 if (proxy->flags & WL_PROXY_FLAG_DESTROYED)
245 proxy->refcount--;
246 if (!proxy->refcount)
247 free(proxy);
260 struct wl_proxy *proxy;
270 proxy = closure->proxy;
271 proxy_destroyed = !!(proxy->flags & WL_PROXY_FLAG_DESTROYED);
273 proxy->refcount--;
274 if (proxy_destroyed && !proxy->refcount)
275 free(proxy);
331 struct wl_proxy *proxy;
334 proxy = zalloc(sizeof *proxy);
335 if (proxy == NULL)
338 proxy->object.interface = interface;
339 proxy->display = display;
340 proxy->queue = factory->queue;
341 proxy->refcount = 1;
342 proxy->version = version;
344 proxy->object.id = wl_map_insert_new(&display->objects, 0, proxy);
346 return proxy;
349 /** Create a proxy object with a given interface
351 * \param factory Factory proxy object
352 * \param interface Interface the proxy object should use
353 * \return A newly allocated proxy object or NULL on failure
355 * This function creates a new proxy object with the supplied interface. The
356 * proxy object will have an id assigned from the client id space. The id
360 * The proxy will inherit the display and event queue of the factory object.
372 struct wl_proxy *proxy;
375 proxy = proxy_create(factory, interface, factory->version);
378 return proxy;
386 struct wl_proxy *proxy;
389 proxy = zalloc(sizeof *proxy);
390 if (proxy == NULL)
393 proxy->object.interface = interface;
394 proxy->object.id = id;
395 proxy->display = display;
396 proxy->queue = factory->queue;
397 proxy->refcount = 1;
398 proxy->version = factory->version;
400 wl_map_insert_at(&display->objects, 0, id, proxy);
402 return proxy;
406 proxy_destroy(struct wl_proxy *proxy)
408 if (proxy->flags & WL_PROXY_FLAG_ID_DELETED)
409 wl_map_remove(&proxy->display->objects, proxy->object.id);
410 else if (proxy->object.id < WL_SERVER_ID_START)
411 wl_map_insert_at(&proxy->display->objects, 0,
412 proxy->object.id, WL_ZOMBIE_OBJECT);
414 wl_map_insert_at(&proxy->display->objects, 0,
415 proxy->object.id, NULL);
418 proxy->flags |= WL_PROXY_FLAG_DESTROYED;
420 proxy->refcount--;
421 if (!proxy->refcount)
422 free(proxy);
425 /** Destroy a proxy object
427 * \param proxy The proxy to be destroyed
429 * \c proxy must not be a proxy wrapper.
434 wl_proxy_destroy(struct wl_proxy *proxy)
436 struct wl_display *display = proxy->display;
438 if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
442 proxy_destroy(proxy);
446 /** Set a proxy's listener
448 * \param proxy The proxy object
449 * \param implementation The listener to be added to proxy
450 * \param data User data to be associated with the proxy
453 * Set proxy's listener to \c implementation and its user data to
461 * \c proxy must not be a proxy wrapper.
466 wl_proxy_add_listener(struct wl_proxy *proxy,
469 if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
470 wl_abort("Proxy %p is a wrapper\n", proxy);
472 if (proxy->object.implementation || proxy->dispatcher) {
473 wl_log("proxy %p already has listener\n", proxy);
477 proxy->object.implementation = implementation;
478 proxy->user_data = data;
483 /** Get a proxy's listener
485 * \param proxy The proxy object
486 * \return The address of the proxy's listener or NULL if no listener is set
488 * Gets the address to the proxy's listener; which is the listener set with
497 wl_proxy_get_listener(struct wl_proxy *proxy)
499 return proxy->object.implementation;
502 /** Set a proxy's listener (with dispatcher)
504 * \param proxy The proxy object
505 * \param dispatcher The dispatcher to be used for this proxy
507 * \param data User data to be associated with the proxy
510 * Set proxy's listener to use \c dispatcher_func as its dispatcher and \c
518 * \c proxy must not be a proxy wrapper.
523 wl_proxy_add_dispatcher(struct wl_proxy *proxy,
527 if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
528 wl_abort("Proxy %p is a wrapper\n", proxy);
530 if (proxy->object.implementation || proxy->dispatcher) {
531 wl_log("proxy %p already has listener\n", proxy);
535 proxy->object.implementation = implementation;
536 proxy->dispatcher = dispatcher;
537 proxy->user_data = data;
543 create_outgoing_proxy(struct wl_proxy *proxy, const struct wl_message *message,
559 new_proxy = proxy_create(proxy, interface, version);
573 * \param proxy The proxy object
576 * \param interface The interface to use for the new proxy
585 * created proxy will inherit their version from their parent.
595 wl_proxy_marshal_array_constructor(struct wl_proxy *proxy,
599 return wl_proxy_marshal_array_constructor_versioned(proxy, opcode,
601 proxy->version);
607 * \param proxy The proxy object
610 * \param interface The interface to use for the new proxy
611 * \param version The protocol object version for the new proxy
620 * created proxy will have the version specified.
630 wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *proxy,
640 pthread_mutex_lock(&proxy->display->mutex);
642 message = &proxy->object.interface->methods[opcode];
644 new_proxy = create_outgoing_proxy(proxy, message,
651 closure = wl_closure_marshal(&proxy->object, opcode, args, message);
656 wl_closure_print(closure, &proxy->object, true);
658 if (wl_closure_send(closure, proxy->display->connection))
664 pthread_mutex_unlock(&proxy->display->mutex);
672 * \param proxy The proxy object
686 wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
692 wl_argument_from_va_list(proxy->object.interface->methods[opcode].signature,
696 wl_proxy_marshal_array_constructor(proxy, opcode, args, NULL);
701 * \param proxy The proxy object
703 * \param interface The interface to use for the new proxy
715 * created proxy will inherit their version from their parent.
722 wl_proxy_marshal_constructor(struct wl_proxy *proxy, uint32_t opcode,
729 wl_argument_from_va_list(proxy->object.interface->methods[opcode].signature,
733 return wl_proxy_marshal_array_constructor(proxy, opcode,
740 * \param proxy The proxy object
742 * \param interface The interface to use for the new proxy
743 * \param version The protocol object version of the new proxy
753 * created proxy will have the version specified.
760 wl_proxy_marshal_constructor_versioned(struct wl_proxy *proxy, uint32_t opcode,
768 wl_argument_from_va_list(proxy->object.interface->methods[opcode].signature,
772 return wl_proxy_marshal_array_constructor_versioned(proxy, opcode,
779 * \param proxy The proxy object
794 wl_proxy_marshal_array(struct wl_proxy *proxy, uint32_t opcode,
797 wl_proxy_marshal_array_constructor(proxy, opcode, args, NULL);
805 struct wl_proxy *proxy = object;
809 if (proxy) {
811 proxy->object.interface->name,
812 proxy->object.id,
815 object_id = proxy->object.id;
816 interface = proxy->object.interface;
831 struct wl_proxy *proxy;
835 proxy = wl_map_lookup(&display->objects, id);
837 if (!proxy)
840 if (proxy && proxy != WL_ZOMBIE_OBJECT)
841 proxy->flags |= WL_PROXY_FLAG_ID_DELETED;
943 display->proxy.object.interface = &wl_display_interface;
944 display->proxy.object.id =
946 display->proxy.display = display;
947 display->proxy.object.implementation = (void(**)(void)) &display_listener;
948 display->proxy.user_data = display;
949 display->proxy.queue = &display->default_queue;
950 display->proxy.flags = 0;
951 display->proxy.refcount = 1;
960 * code newer than the headers that checks proxy
961 * versions. When the proxy version is reported as 0
963 * the proxy version, and should do whatever fallback is
970 display->proxy.version = 0;
1156 struct wl_proxy *proxy;
1174 proxy = wl_proxy_create_for_id(sender, id,
1176 if (proxy == NULL)
1178 closure->args[i].o = (struct wl_object *)proxy;
1194 struct wl_proxy *proxy;
1203 proxy = (struct wl_proxy *) closure->args[i].o;
1204 if (proxy)
1205 proxy->refcount++;
1218 struct wl_proxy *proxy;
1230 proxy = wl_map_lookup(&display->objects, id);
1231 if (proxy == WL_ZOMBIE_OBJECT) {
1234 } else if (proxy == NULL) {
1239 message = &proxy->object.interface->events[opcode];
1245 if (create_proxies(proxy, closure) < 0) {
1256 proxy->refcount++;
1257 closure->proxy = proxy;
1259 if (proxy == &display->proxy)
1262 queue = proxy->queue;
1273 struct wl_proxy *proxy;
1286 proxy = closure->proxy;
1287 proxy_destroyed = !!(proxy->flags & WL_PROXY_FLAG_DESTROYED);
1289 proxy->refcount--;
1291 if (!proxy->refcount)
1292 free(proxy);
1300 if (proxy->dispatcher) {
1302 wl_closure_print(closure, &proxy->object, false);
1304 wl_closure_dispatch(closure, proxy->dispatcher,
1305 &proxy->object, opcode);
1306 } else if (proxy->object.implementation) {
1308 wl_closure_print(closure, &proxy->object, false);
1311 &proxy->object, opcode, proxy->user_data);
1879 /** Set the user data associated with a proxy
1881 * \param proxy The proxy object
1882 * \param user_data The data to be associated with proxy
1884 * Set the user data associated with \c proxy. When events for this
1885 * proxy are received, \c user_data will be supplied to its listener.
1890 wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data)
1892 proxy->user_data = user_data;
1895 /** Get the user data associated with a proxy
1897 * \param proxy The proxy object
1898 * \return The user data associated with proxy
1903 wl_proxy_get_user_data(struct wl_proxy *proxy)
1905 return proxy->user_data;
1908 /** Get the protocol object version of a proxy object
1910 * \param proxy The proxy object
1911 * \return The protocol object version of the proxy or 0
1913 * Gets the protocol object version of a proxy object, or 0
1914 * if the proxy was created with unversioned API.
1925 wl_proxy_get_version(struct wl_proxy *proxy)
1927 return proxy->version;
1930 /** Get the id of a proxy object
1932 * \param proxy The proxy object
1933 * \return The id the object associated with the proxy
1938 wl_proxy_get_id(struct wl_proxy *proxy)
1940 return proxy->object.id;
1943 /** Get the interface name (class) of a proxy object
1945 * \param proxy The proxy object
1946 * \return The interface name of the object associated with the proxy
1951 wl_proxy_get_class(struct wl_proxy *proxy)
1953 return proxy->object.interface->name;
1956 /** Assign a proxy to an event queue
1958 * \param proxy The proxy object
1959 * \param queue The event queue that will handle this proxy or NULL
1961 * Assign proxy to event queue. Events coming from \c proxy will be
1963 * default queue is set to the proxy.
1965 * \note By default, the queue set in proxy is the one inherited from parent.
1972 wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue)
1975 proxy->queue = queue;
1977 proxy->queue = &proxy->display->default_queue;
1980 /** Create a proxy wrapper for making queue assignments thread-safe
1982 * \param proxy The proxy object to be wrapped
1983 * \return A proxy wrapper for the given proxy or NULL on failure
1985 * A proxy wrapper is type of 'struct wl_proxy' instance that can be used when
1986 * sending requests instead of using the original proxy. A proxy wrapper does
1988 * object is still emitted on the original proxy. Trying to set an
1992 * Setting the proxy queue of the proxy wrapper will make new objects created
1993 * using the proxy wrapper use the set proxy queue.
1994 * Even though there is no implementation nor dispatcher, the proxy queue can
1996 * requests sent via the proxy wrapper.
1998 * A proxy wrapper can only be destroyed using wl_proxy_wrapper_destroy().
2000 * A proxy wrapper must be destroyed before the proxy it was created from.
2003 * necessary to use a proxy wrapper when sending requests on objects when the
2004 * intention is that a newly created proxy is to use a proxy queue different
2005 * from the proxy the request was sent on, as creating the new proxy and then
2008 * For example, a module that runs using its own proxy queue that needs to
2009 * do display roundtrip must wrap the wl_display proxy object before sending
2029 wl_proxy_create_wrapper(void *proxy)
2031 struct wl_proxy *wrapped_proxy = proxy;
2053 /** Destroy a proxy wrapper
2054 * \param proxy_wrapper The proxy wrapper to be destroyed
2064 wl_abort("Tried to destroy non-wrapper proxy with "