Expand description
Wayland proxy objects and helpers.
Proxies represent objects in the wayland protocol. Libwayland uses wl_proxy pointers
to represent proxies and wl-client provides safe types to handle them.
§Proxy types
There are four different types of proxies across two dimensions:
- In libwayland:
- A wrapper
wl_proxyis a proxy that was created by calling thewl_proxy_create_wrapperfunction. - A plain
wl_proxyis any other proxy.
- A wrapper
- In
wl-client:- An owned proxy is a proxy that will destroy the underlying
wl_proxywhen it is dropped. - A borrowed proxy is a proxy that only references a
wl_proxyand will never be used to destroy it.
- An owned proxy is a proxy that will destroy the underlying
Therefore, each proxy is
- an owned wrapper proxy,
- an owned plain proxy,
- a borrowed wrapper proxy, or
- a borrowed plain proxy.
§Owned proxies
Owned proxies are proxies created by wl-client. They have a Queue, also created by
wl-client, which can be accessed by calling queue.
When an owned proxy is used to create a new wayland object, the function returns a new owned proxy that is assigned to the same queue as its parent.
An owned proxy can be used to destroy the proxy by sending a destructor request or by
using the destroy function. Owned proxies are implicitly destroyed with the
destroy function in the following situations:
- When the last reference to the owned proxy is dropped.
- When the
QueueOwnerowning the proxy’s queue is dropped. This is explained in detail in the documentation ofQueue.
§Borrowed proxies
Borrowed proxies might or might not have been created by wl-client. Each owned proxy
derefs to a borrowed proxy but a borrowed proxy can also be created from raw
wl_proxy pointers.
Since the ownership of these proxies is unknown, they cannot be used to to destroy the proxy.
If a request is sent on a borrowed proxy that creates a new wayland object, the caller
must also pass in a Queue. The returned owned proxy will be assigned to this
queue.
§Creating wrapper proxies
When working with wayland objects created by foreign code, the foreign code usually
shares raw wl_proxy pointers. Given a Queue, it is possible to create a new
owned wrapper proxy by calling Queue::wrap_wl_proxy.
§Setting proxy event handlers
Event handlers can be attached to owned plain proxies by using one of the following functions:
set_event_handler- forSend + 'staticevent handlersset_event_handler_local- for'staticevent handlersset_event_handler_no_opScope::set_event_handler- forSend + 'scopeevent handlersScope::set_event_handler_local- for'scopeevent handlers
The _local variant allows setting event handlers that do not implement Send. The
_no_op variant can be used to destroy compositor-created resources if
the application is not otherwise interested in events.
Event handlers cannot be set on owned wrapper proxies.
For each proxy, the event handler can only be set once and once set it cannot be unset.
Modules§
- low_
level - Low-level proxy APIs.
Structs§
- Borrowed
Proxy Lock - A lock that ensures that a
UntypedBorrowedProxyis not changed.
Traits§
- Borrowed
Proxy - A borrowed proxy.
- Owned
Proxy - An owned proxy.
Functions§
- destroy
- Destroys a proxy without sending a wayland message.
- id
- Returns the wayland object ID of a proxy.
- is_
destroyed - Returns whether this proxy is destroyed.
- is_
not_ destroyed - Returns whether this proxy is not destroyed.
- lock
- Locks the proxy for concurrent destruction.
- queue
- Returns the queue of a proxy.
- set_
event_ handler - Sets the event handler of the proxy.
- set_
event_ handler_ local - Sets the
!Sendevent handler of the proxy. - set_
event_ handler_ no_ op - Sets the event handler of the proxy to ignore all events.
- version
- Returns the version of this proxy object.
- wl_
proxy - Returns the
wl_proxypointer of a proxy.