Lines Matching full:proxy
83 struct wl_proxy proxy; member
98 /* id of the proxy that caused the error. There's no warranty
99 * that the proxy is still valid. It's up to client how it will
144 const struct wl_proxy *proxy; in adjust_closure_args_for_logging() local
156 proxy = (struct wl_proxy *)closure->args[i].o; in adjust_closure_args_for_logging()
157 closure->args[i].n = proxy ? proxy->object.id : 0; in adjust_closure_args_for_logging()
178 return "dead proxy on dispatch"; in get_discarded_reason_str()
192 * \param proxy proxy for the message
198 closure_log(struct wl_closure *closure, struct wl_proxy *proxy, bool send, in closure_log() argument
201 struct wl_display *display = proxy->display; in closure_log()
219 wl_closure_print(&adjusted_closure, &proxy->object, send, in closure_log()
229 message.proxy = proxy; in closure_log()
248 * \param id id of the proxy this message was meant for
283 unknown_closure.proxy = &unknown_proxy; in log_unknown_message()
402 wl_proxy_unref(struct wl_proxy *proxy) in wl_proxy_unref() argument
404 assert(proxy->refcount > 0); in wl_proxy_unref()
405 if (--proxy->refcount > 0) in wl_proxy_unref()
410 assert(proxy->flags & WL_PROXY_FLAG_DESTROYED); in wl_proxy_unref()
411 free(proxy); in wl_proxy_unref()
420 struct wl_proxy *proxy; in validate_closure_objects() local
429 proxy = (struct wl_proxy *) closure->args[i].o; in validate_closure_objects()
430 if (proxy && proxy->flags & WL_PROXY_FLAG_DESTROYED) in validate_closure_objects()
440 * proxies in its arguments, as well as its own proxy, and destroys the
447 struct wl_proxy *proxy; in destroy_queued_closure() local
457 proxy = (struct wl_proxy *) closure->args[i].o; in destroy_queued_closure()
458 if (proxy) in destroy_queued_closure()
459 wl_proxy_unref(proxy); in destroy_queued_closure()
466 wl_proxy_unref(closure->proxy); in destroy_queued_closure()
476 struct wl_proxy *proxy, *tmp; in wl_event_queue_release() local
483 wl_list_for_each_safe(proxy, tmp, &queue->proxy_list, in wl_event_queue_release()
487 proxy->object.interface->name, in wl_event_queue_release()
488 proxy->object.id); in wl_event_queue_release()
490 proxy->queue = NULL; in wl_event_queue_release()
491 wl_list_remove(&proxy->queue_link); in wl_event_queue_release()
492 wl_list_init(&proxy->queue_link); in wl_event_queue_release()
567 prepare_zombie(struct wl_proxy *proxy) in prepare_zombie() argument
569 const struct wl_interface *interface = proxy->object.interface; in prepare_zombie()
614 struct wl_proxy *proxy; in proxy_create() local
617 proxy = zalloc(sizeof *proxy); in proxy_create()
618 if (proxy == NULL) in proxy_create()
621 proxy->object.interface = interface; in proxy_create()
622 proxy->display = display; in proxy_create()
623 proxy->queue = factory->queue; in proxy_create()
624 proxy->refcount = 1; in proxy_create()
625 proxy->version = version; in proxy_create()
627 proxy->object.id = wl_map_insert_new(&display->objects, 0, proxy); in proxy_create()
628 if (proxy->object.id == 0) { in proxy_create()
629 free(proxy); in proxy_create()
633 wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link); in proxy_create()
635 return proxy; in proxy_create()
638 /** Create a proxy object with a given interface
640 * \param factory Factory proxy object
641 * \param interface Interface the proxy object should use
642 * \return A newly allocated proxy object or NULL on failure
644 * This function creates a new proxy object with the supplied interface. The
645 * proxy object will have an id assigned from the client id space. The id
649 * The proxy will inherit the display and event queue of the factory object.
661 struct wl_proxy *proxy; in wl_proxy_create() local
664 proxy = proxy_create(factory, interface, factory->version); in wl_proxy_create()
667 return proxy; in wl_proxy_create()
675 struct wl_proxy *proxy; in wl_proxy_create_for_id() local
678 proxy = zalloc(sizeof *proxy); in wl_proxy_create_for_id()
679 if (proxy == NULL) in wl_proxy_create_for_id()
682 proxy->object.interface = interface; in wl_proxy_create_for_id()
683 proxy->object.id = id; in wl_proxy_create_for_id()
684 proxy->display = display; in wl_proxy_create_for_id()
685 proxy->queue = factory->queue; in wl_proxy_create_for_id()
686 proxy->refcount = 1; in wl_proxy_create_for_id()
687 proxy->version = factory->version; in wl_proxy_create_for_id()
689 if (wl_map_insert_at(&display->objects, 0, id, proxy) == -1) { in wl_proxy_create_for_id()
690 free(proxy); in wl_proxy_create_for_id()
694 wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link); in wl_proxy_create_for_id()
696 return proxy; in wl_proxy_create_for_id()
700 proxy_destroy(struct wl_proxy *proxy) in proxy_destroy() argument
702 if (proxy->flags & WL_PROXY_FLAG_ID_DELETED) { in proxy_destroy()
703 wl_map_remove(&proxy->display->objects, proxy->object.id); in proxy_destroy()
704 } else if (proxy->object.id < WL_SERVER_ID_START) { in proxy_destroy()
705 struct wl_zombie *zombie = prepare_zombie(proxy); in proxy_destroy()
709 wl_map_insert_at(&proxy->display->objects, in proxy_destroy()
711 proxy->object.id, in proxy_destroy()
714 wl_map_insert_at(&proxy->display->objects, 0, in proxy_destroy()
715 proxy->object.id, NULL); in proxy_destroy()
718 proxy->flags |= WL_PROXY_FLAG_DESTROYED; in proxy_destroy()
720 proxy->queue = NULL; in proxy_destroy()
721 wl_list_remove(&proxy->queue_link); in proxy_destroy()
722 wl_list_init(&proxy->queue_link); in proxy_destroy()
724 wl_proxy_unref(proxy); in proxy_destroy()
728 wl_proxy_destroy_caller_locks(struct wl_proxy *proxy) in wl_proxy_destroy_caller_locks() argument
730 if (proxy->flags & WL_PROXY_FLAG_WRAPPER) in wl_proxy_destroy_caller_locks()
733 proxy_destroy(proxy); in wl_proxy_destroy_caller_locks()
736 /** Destroy a proxy object
738 * \param proxy The proxy to be destroyed
740 * \c proxy must not be a proxy wrapper.
750 wl_proxy_destroy(struct wl_proxy *proxy) in wl_proxy_destroy() argument
752 struct wl_display *display = proxy->display; in wl_proxy_destroy()
756 wl_proxy_destroy_caller_locks(proxy); in wl_proxy_destroy()
761 /** Set a proxy's listener
763 * \param proxy The proxy object
764 * \param implementation The listener to be added to proxy
765 * \param data User data to be associated with the proxy
768 * Set proxy's listener to \c implementation and its user data to
776 * \c proxy must not be a proxy wrapper.
781 wl_proxy_add_listener(struct wl_proxy *proxy, in wl_proxy_add_listener() argument
784 if (proxy->flags & WL_PROXY_FLAG_WRAPPER) in wl_proxy_add_listener()
785 wl_abort("Proxy %p is a wrapper\n", proxy); in wl_proxy_add_listener()
787 if (proxy->object.implementation || proxy->dispatcher) { in wl_proxy_add_listener()
788 wl_log("proxy %p already has listener\n", proxy); in wl_proxy_add_listener()
792 proxy->object.implementation = implementation; in wl_proxy_add_listener()
793 proxy->user_data = data; in wl_proxy_add_listener()
798 /** Get a proxy's listener
800 * \param proxy The proxy object
801 * \return The address of the proxy's listener or NULL if no listener is set
803 * Gets the address to the proxy's listener; which is the listener set with
812 wl_proxy_get_listener(struct wl_proxy *proxy) in wl_proxy_get_listener() argument
814 return proxy->object.implementation; in wl_proxy_get_listener()
817 /** Set a proxy's listener (with dispatcher)
819 * \param proxy The proxy object
820 * \param dispatcher The dispatcher to be used for this proxy
822 * \param data User data to be associated with the proxy
825 * Set proxy's listener to use \c dispatcher_func as its dispatcher and \c
833 * \c proxy must not be a proxy wrapper.
838 wl_proxy_add_dispatcher(struct wl_proxy *proxy, in wl_proxy_add_dispatcher() argument
842 if (proxy->flags & WL_PROXY_FLAG_WRAPPER) in wl_proxy_add_dispatcher()
843 wl_abort("Proxy %p is a wrapper\n", proxy); in wl_proxy_add_dispatcher()
845 if (proxy->object.implementation || proxy->dispatcher) { in wl_proxy_add_dispatcher()
846 wl_log("proxy %p already has listener\n", proxy); in wl_proxy_add_dispatcher()
850 proxy->object.implementation = implementation; in wl_proxy_add_dispatcher()
851 proxy->dispatcher = dispatcher; in wl_proxy_add_dispatcher()
852 proxy->user_data = data; in wl_proxy_add_dispatcher()
858 create_outgoing_proxy(struct wl_proxy *proxy, const struct wl_message *message, in create_outgoing_proxy() argument
874 new_proxy = proxy_create(proxy, interface, version); in create_outgoing_proxy()
888 * \param proxy The proxy object
891 * \param interface The interface to use for the new proxy
900 * created proxy will inherit their version from their parent.
910 wl_proxy_marshal_array_constructor(struct wl_proxy *proxy, in wl_proxy_marshal_array_constructor() argument
914 return wl_proxy_marshal_array_constructor_versioned(proxy, opcode, in wl_proxy_marshal_array_constructor()
916 proxy->version); in wl_proxy_marshal_array_constructor()
922 * \param proxy The proxy object
925 * \param interface The interface to use for the new proxy
926 * \param version The protocol object version for the new proxy
935 * created proxy will have the version specified.
945 wl_proxy_marshal_array_constructor_versioned(struct wl_proxy *proxy, in wl_proxy_marshal_array_constructor_versioned() argument
951 return wl_proxy_marshal_array_flags(proxy, opcode, interface, version, 0, args); in wl_proxy_marshal_array_constructor_versioned()
956 * \param proxy The proxy object
958 * \param interface The interface to use for the new proxy
959 * \param version The protocol object version of the new proxy
970 * created proxy will have the version specified.
972 * The flag WL_MARSHAL_FLAG_DESTROY may be passed to ensure the proxy
982 wl_proxy_marshal_flags(struct wl_proxy *proxy, uint32_t opcode, in wl_proxy_marshal_flags() argument
990 wl_argument_from_va_list(proxy->object.interface->methods[opcode].signature, in wl_proxy_marshal_flags()
994 return wl_proxy_marshal_array_flags(proxy, opcode, interface, version, flags, args); in wl_proxy_marshal_flags()
999 * \param proxy The proxy object
1001 * \param interface The interface to use for the new proxy
1002 * \param version The protocol object version for the new proxy
1013 * created proxy will have the version specified.
1015 * The flag WL_MARSHAL_FLAG_DESTROY may be passed to ensure the proxy
1028 wl_proxy_marshal_array_flags(struct wl_proxy *proxy, uint32_t opcode, in wl_proxy_marshal_array_flags() argument
1035 struct wl_display *disp = proxy->display; in wl_proxy_marshal_array_flags()
1039 message = &proxy->object.interface->methods[opcode]; in wl_proxy_marshal_array_flags()
1041 new_proxy = create_outgoing_proxy(proxy, message, in wl_proxy_marshal_array_flags()
1048 if (proxy->display->last_error) { in wl_proxy_marshal_array_flags()
1052 closure = wl_closure_marshal(&proxy->object, opcode, args, message); in wl_proxy_marshal_array_flags()
1055 display_fatal_error(proxy->display, errno); in wl_proxy_marshal_array_flags()
1059 closure_log(closure, proxy, true, WL_CLIENT_MESSAGE_NOT_DISCARDED); in wl_proxy_marshal_array_flags()
1061 if (wl_closure_send(closure, proxy->display->connection)) { in wl_proxy_marshal_array_flags()
1063 display_fatal_error(proxy->display, errno); in wl_proxy_marshal_array_flags()
1070 wl_proxy_destroy_caller_locks(proxy); in wl_proxy_marshal_array_flags()
1080 * \param proxy The proxy object
1094 wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) in wl_proxy_marshal() argument
1100 wl_argument_from_va_list(proxy->object.interface->methods[opcode].signature, in wl_proxy_marshal()
1104 wl_proxy_marshal_array_constructor(proxy, opcode, args, NULL); in wl_proxy_marshal()
1109 * \param proxy The proxy object
1111 * \param interface The interface to use for the new proxy
1123 * created proxy will inherit their version from their parent.
1130 wl_proxy_marshal_constructor(struct wl_proxy *proxy, uint32_t opcode, in wl_proxy_marshal_constructor() argument
1137 wl_argument_from_va_list(proxy->object.interface->methods[opcode].signature, in wl_proxy_marshal_constructor()
1141 return wl_proxy_marshal_array_constructor(proxy, opcode, in wl_proxy_marshal_constructor()
1148 * \param proxy The proxy object
1150 * \param interface The interface to use for the new proxy
1151 * \param version The protocol object version of the new proxy
1161 * created proxy will have the version specified.
1168 wl_proxy_marshal_constructor_versioned(struct wl_proxy *proxy, uint32_t opcode, in wl_proxy_marshal_constructor_versioned() argument
1176 wl_argument_from_va_list(proxy->object.interface->methods[opcode].signature, in wl_proxy_marshal_constructor_versioned()
1180 return wl_proxy_marshal_array_constructor_versioned(proxy, opcode, in wl_proxy_marshal_constructor_versioned()
1187 * \param proxy The proxy object
1202 wl_proxy_marshal_array(struct wl_proxy *proxy, uint32_t opcode, in wl_proxy_marshal_array() argument
1205 wl_proxy_marshal_array_constructor(proxy, opcode, args, NULL); in wl_proxy_marshal_array()
1213 struct wl_proxy *proxy = object; in display_handle_error() local
1217 if (proxy) { in display_handle_error()
1219 proxy->object.interface->name, in display_handle_error()
1220 proxy->object.id, in display_handle_error()
1223 object_id = proxy->object.id; in display_handle_error()
1224 interface = proxy->object.interface; in display_handle_error()
1239 struct wl_proxy *proxy; in display_handle_delete_id() local
1243 proxy = wl_map_lookup(&display->objects, id); in display_handle_delete_id()
1246 /* For zombie objects, the 'proxy' is actually the zombie in display_handle_delete_id()
1248 free(proxy); in display_handle_delete_id()
1250 } else if (proxy) { in display_handle_delete_id()
1251 proxy->flags |= WL_PROXY_FLAG_ID_DELETED; in display_handle_delete_id()
1371 display->proxy.object.id = in wl_display_connect_to_fd()
1374 if (display->proxy.object.id == 0) in wl_display_connect_to_fd()
1377 display->proxy.object.interface = &wl_display_interface; in wl_display_connect_to_fd()
1378 display->proxy.display = display; in wl_display_connect_to_fd()
1379 display->proxy.object.implementation = (void(**)(void)) &display_listener; in wl_display_connect_to_fd()
1380 display->proxy.user_data = display; in wl_display_connect_to_fd()
1381 display->proxy.queue = &display->default_queue; in wl_display_connect_to_fd()
1382 display->proxy.flags = 0; in wl_display_connect_to_fd()
1383 display->proxy.refcount = 1; in wl_display_connect_to_fd()
1392 * code newer than the headers that checks proxy in wl_display_connect_to_fd()
1393 * versions. When the proxy version is reported as 0 in wl_display_connect_to_fd()
1395 * the proxy version, and should do whatever fallback is in wl_display_connect_to_fd()
1402 display->proxy.version = 0; in wl_display_connect_to_fd()
1610 struct wl_proxy *proxy; in create_proxies() local
1628 proxy = wl_proxy_create_for_id(sender, id, in create_proxies()
1630 if (proxy == NULL) in create_proxies()
1632 closure->args[i].o = (struct wl_object *)proxy; in create_proxies()
1648 struct wl_proxy *proxy; in increase_closure_args_refcount() local
1657 proxy = (struct wl_proxy *) closure->args[i].o; in increase_closure_args_refcount()
1658 if (proxy) in increase_closure_args_refcount()
1659 proxy->refcount++; in increase_closure_args_refcount()
1666 closure->proxy->refcount++; in increase_closure_args_refcount()
1674 struct wl_proxy *proxy; in queue_event() local
1687 /* If our proxy is gone or a zombie, just eat the event (and any FDs, in queue_event()
1689 proxy = wl_map_lookup(&display->objects, id); in queue_event()
1690 if (!proxy || wl_object_is_zombie(&display->objects, id)) { in queue_event()
1706 if (opcode >= proxy->object.interface->event_count) { in queue_event()
1708 proxy->object.interface->name, opcode); in queue_event()
1712 message = &proxy->object.interface->events[opcode]; in queue_event()
1718 if (create_proxies(proxy, closure) < 0) { in queue_event()
1728 closure->proxy = proxy; in queue_event()
1731 if (proxy == &display->proxy) in queue_event()
1734 queue = proxy->queue; in queue_event()
1748 struct wl_proxy *proxy; in dispatch_event() local
1759 proxy = closure->proxy; in dispatch_event()
1760 proxy_destroyed = !!(proxy->flags & WL_PROXY_FLAG_DESTROYED); in dispatch_event()
1762 closure_log(closure, proxy, false, in dispatch_event()
1764 } else if (proxy->dispatcher) { in dispatch_event()
1765 closure_log(closure, proxy, false, in dispatch_event()
1769 wl_closure_dispatch(closure, proxy->dispatcher, in dispatch_event()
1770 &proxy->object, opcode); in dispatch_event()
1772 } else if (proxy->object.implementation) { in dispatch_event()
1773 closure_log(closure, proxy, false, in dispatch_event()
1778 &proxy->object, opcode, proxy->user_data); in dispatch_event()
1781 closure_log(closure, proxy, false, in dispatch_event()
2348 /** Set the user data associated with a proxy
2350 * \param proxy The proxy object
2351 * \param user_data The data to be associated with proxy
2353 * Set the user data associated with \c proxy. When events for this
2354 * proxy are received, \c user_data will be supplied to its listener.
2359 wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data) in wl_proxy_set_user_data() argument
2361 proxy->user_data = user_data; in wl_proxy_set_user_data()
2364 /** Get the user data associated with a proxy
2366 * \param proxy The proxy object
2367 * \return The user data associated with proxy
2372 wl_proxy_get_user_data(struct wl_proxy *proxy) in wl_proxy_get_user_data() argument
2374 return proxy->user_data; in wl_proxy_get_user_data()
2377 /** Get the protocol object version of a proxy object
2379 * \param proxy The proxy object
2380 * \return The protocol object version of the proxy or 0
2382 * Gets the protocol object version of a proxy object, or 0
2383 * if the proxy was created with unversioned API.
2394 wl_proxy_get_version(struct wl_proxy *proxy) in wl_proxy_get_version() argument
2396 return proxy->version; in wl_proxy_get_version()
2399 /** Get the id of a proxy object
2401 * \param proxy The proxy object
2402 * \return The id the object associated with the proxy
2407 wl_proxy_get_id(struct wl_proxy *proxy) in wl_proxy_get_id() argument
2409 return proxy->object.id; in wl_proxy_get_id()
2412 /** Set the tag of a proxy object
2414 * A toolkit or application can set a unique tag on a proxy in order to
2448 * \param proxy The proxy object
2455 wl_proxy_set_tag(struct wl_proxy *proxy, in wl_proxy_set_tag() argument
2458 proxy->tag = tag; in wl_proxy_set_tag()
2461 /** Get the tag of a proxy object
2465 * \param proxy The proxy object
2471 wl_proxy_get_tag(struct wl_proxy *proxy) in wl_proxy_get_tag() argument
2473 return proxy->tag; in wl_proxy_get_tag()
2476 /** Get the interface name (class) of a proxy object
2478 * \param proxy The proxy object
2479 * \return The interface name of the object associated with the proxy
2484 wl_proxy_get_class(struct wl_proxy *proxy) in wl_proxy_get_class() argument
2486 return proxy->object.interface->name; in wl_proxy_get_class()
2489 /** Assign a proxy to an event queue
2491 * \param proxy The proxy object
2492 * \param queue The event queue that will handle this proxy or NULL
2494 * Assign proxy to event queue. Events coming from \c proxy will be
2496 * default queue is set to the proxy.
2500 * proxy's old event queue after setting a new event queue.
2503 * possible for events to be queued to the proxy's old queue from a
2506 * To ensure that all events for a newly created proxy are dispatched
2507 * on a particular queue, it is necessary to use a proxy wrapper if
2511 * \note By default, the queue set in proxy is the one inherited from parent.
2518 wl_proxy_set_queue(struct wl_proxy *proxy, struct wl_event_queue *queue) in wl_proxy_set_queue() argument
2520 pthread_mutex_lock(&proxy->display->mutex); in wl_proxy_set_queue()
2522 wl_list_remove(&proxy->queue_link); in wl_proxy_set_queue()
2525 assert(proxy->display == queue->display); in wl_proxy_set_queue()
2526 proxy->queue = queue; in wl_proxy_set_queue()
2528 proxy->queue = &proxy->display->default_queue; in wl_proxy_set_queue()
2531 wl_list_insert(&proxy->queue->proxy_list, &proxy->queue_link); in wl_proxy_set_queue()
2533 pthread_mutex_unlock(&proxy->display->mutex); in wl_proxy_set_queue()
2536 /** Create a proxy wrapper for making queue assignments thread-safe
2538 * \param proxy The proxy object to be wrapped
2539 * \return A proxy wrapper for the given proxy or NULL on failure
2541 * A proxy wrapper is type of 'struct wl_proxy' instance that can be used when
2542 * sending requests instead of using the original proxy. A proxy wrapper does
2544 * object is still emitted on the original proxy. Trying to set an
2548 * Setting the proxy queue of the proxy wrapper will make new objects created
2549 * using the proxy wrapper use the set proxy queue.
2550 * Even though there is no implementation nor dispatcher, the proxy queue can
2552 * requests sent via the proxy wrapper.
2554 * A proxy wrapper can only be destroyed using wl_proxy_wrapper_destroy().
2556 * A proxy wrapper must be destroyed before the proxy it was created from.
2559 * necessary to use a proxy wrapper when sending requests on objects when the
2560 * intention is that a newly created proxy is to use a proxy queue different
2561 * from the proxy the request was sent on, as creating the new proxy and then
2564 * For example, a module that runs using its own proxy queue that needs to
2565 * do display roundtrip must wrap the wl_display proxy object before sending
2585 wl_proxy_create_wrapper(void *proxy) in wl_proxy_create_wrapper() argument
2587 struct wl_proxy *wrapped_proxy = proxy; in wl_proxy_create_wrapper()
2611 /** Destroy a proxy wrapper
2612 * \param proxy_wrapper The proxy wrapper to be destroyed
2622 wl_abort("Tried to destroy non-wrapper proxy with " in wl_proxy_wrapper_destroy()
2636 /** Safely converts an object into its corresponding proxy
2638 * \param object object to get the proxy for
2639 * \return A corresponding proxy, or NULL on failure.
2641 * Safely converts an object into its corresponding proxy.
2652 struct wl_proxy *proxy; in wl_proxy_from_object() local
2655 return wl_container_of(object, proxy, object); in wl_proxy_from_object()