Struct wayland_client::Display [−][src]
pub struct Display { /* fields omitted */ }A connection to a wayland server
This object both represent the connection to the server, and as such
must be kept alive as long as you are connected, and contains the
primary WlDisplay wayland object, from which you can create all
your need objects. The inner Proxy<WlDisplay> can be accessed via
Deref.
Methods
impl Display[src]
impl Displaypub unsafe fn from_external_display(
display_ptr: *mut wl_display
) -> (Display, EventQueue)[src]
pub unsafe fn from_external_display(
display_ptr: *mut wl_display
) -> (Display, EventQueue)Create a Display and Event Queue from an external display
This allows you to interface with an already-existing wayland connection, for example provided by a GUI toolkit.
To avoid interferences with the owner of the connection, wayland-client will
create a new event queue and register a wrapper of the wl_display to this queue,
then provide them to you. You can then use them as if they came from a direct
wayland connection.
Note that if you need to retrieve the actual wl_display back (rather than its wrapper),
you must use the get_display_ptr() method.
pub fn get_display_ptr(&self) -> *mut wl_display[src]
pub fn get_display_ptr(&self) -> *mut wl_displayRetrieve the wl_display pointer
If this Display was created from an external wl_display, its c_ptr() method will
return a wrapper to the actual display. While this is perfectly good as a wl_proxy
pointer, to send requests, this is not the actual wl_display and cannot be used as such.
This method will give you the wl_display.
pub fn connect_to_env() -> Result<(Display, EventQueue), ConnectError>[src]
pub fn connect_to_env() -> Result<(Display, EventQueue), ConnectError>Attempt to connect to a wayland server using the contents of the environment variables
If the WAYLAND_DISPLAY variable is set, it will try to connect to the socket it points
to. Otherwise, it will default to wayland-0.
On success, you are given the Display object as well as the main EventQueue hosting
the WlDisplay wayland object.
This requires the XDG_RUNTIME_DIR variable to be properly set.
pub fn connect_to_name<S: Into<OsString>>(
name: S
) -> Result<(Display, EventQueue), ConnectError>[src]
pub fn connect_to_name<S: Into<OsString>>(
name: S
) -> Result<(Display, EventQueue), ConnectError>Attempt to connect to a wayland server socket with given name
On success, you are given the Display object as well as the main EventQueue hosting
the WlDisplay wayland object.
This requires the XDG_RUNTIME_DIR variable to be properly set.
pub fn flush(&self) -> Result<i32>[src]
pub fn flush(&self) -> Result<i32>Non-blocking write to the server
Outgoing messages to the server are buffered by the library for efficiency. This method flushes the internal buffer to the server socket.
Will write as many pending requests as possible to the server socket. Never blocks: if not all
requests coul be written, will return an io error WouldBlock.
On success returns the number of written requests.
pub fn create_event_queue(&self) -> EventQueue[src]
pub fn create_event_queue(&self) -> EventQueueCreate a new event queue associated with this wayland connection
Methods from Deref<Target = Proxy<WlDisplay>>
pub fn send(&self, msg: I::Request)[src]
pub fn send(&self, msg: I::Request)Send a request through this object
This is the generic method to send requests.
Several requests require the creation of new objects using
the child() method, which if done wrong can cause protocol
errors (in which case the server will terminate your connexion).
Thus unless your know exactly what you are doing, you should use
the helper methods provided by the various RequestsTrait for
each interface, which handle this correctly for you.
pub fn is_alive(&self) -> bool[src]
pub fn is_alive(&self) -> boolCheck if the object associated with this proxy is still alive
Will return false if either:
- The object has been destroyed
- The object is not managed by this library (see the
from_c_ptrmethod)
pub fn version(&self) -> u32[src]
pub fn version(&self) -> u32Retrieve the interface version of this wayland object instance
Returns 0 on dead objects
pub fn set_user_data(&self, ptr: *mut ())[src]
pub fn set_user_data(&self, ptr: *mut ())Associate an arbitrary payload to this object
The pointer you associate here can be retrieved from any other proxy to the same wayland object.
Setting or getting user data is done as an atomic operation. You are responsible for the correct initialization of this pointer, synchronisation of access, and destruction of the contents at the appropriate time.
pub fn get_user_data(&self) -> *mut ()[src]
pub fn get_user_data(&self) -> *mut ()Retrieve the arbitrary payload associated to this object
See set_user_data for explanations.
pub fn is_external(&self) -> bool[src]
pub fn is_external(&self) -> boolCheck whether this proxy is managed by the library or not
See from_c_ptr for details.
pub fn equals(&self, other: &Proxy<I>) -> bool[src]
pub fn equals(&self, other: &Proxy<I>) -> boolCheck if the other proxy refers to the same underlying wayland object
pub fn c_ptr(&self) -> *mut wl_proxy[src]
pub fn c_ptr(&self) -> *mut wl_proxyGet a raw pointer to the underlying wayland object
Retrieve a pointer to the object from the libwayland-client.so library.
You will mostly need it to interface with C libraries needing access
to wayland objects (to initialize an opengl context for example).
pub fn make_wrapper(&self, queue: &QueueToken) -> Result<Proxy<I>, ()>[src]
pub fn make_wrapper(&self, queue: &QueueToken) -> Result<Proxy<I>, ()>Create a wrapper for this object for queue management
As assigning a proxy to an event queue can be a racy operation in contextes involving multiple thread, this provides a facility to do this safely.
The wrapper object created behaves like a regular Proxy, except that
all objects created as the result of its requests will be assigned to
the queue associated to the provided token, rather than the queue of
their parent. This does not change the queue of the proxy itself.
pub fn child<C: Interface>(&self) -> NewProxy<C>[src]
pub fn child<C: Interface>(&self) -> NewProxy<C>Create a new child object
This creates a new wayland object, considered as a child of this object. It will notably inherit its interface version.
The created object should immediatly be implemented and sent in a request to the server, to keep the object list properly synchronized. Failure to do so will likely cause a protocol error.
pub fn is_implemented_with<Impl>(&self) -> bool where
Impl: Implementation<Proxy<I>, I::Event> + 'static, [src]
pub fn is_implemented_with<Impl>(&self) -> bool where
Impl: Implementation<Proxy<I>, I::Event> + 'static, Check whether this proxy has been implemented with given type
Always returns false if the proxy is no longer alive