Struct wayland_server::EventLoop
[−]
[src]
pub struct EventLoop { /* fields omitted */ }
Methods
impl EventLoop
[src]
fn new() -> EventLoop
[src]
Create a new EventLoop
It is not associated to a wayland socket, and can be used for other event sources.
fn dispatch(&mut self, timeout: Option<u32>) -> IoResult<u32>
[src]
Dispatch pending requests to their respective handlers
If no request is pending, will block at most timeout
ms if specified,
or indefinitely if timeout
is None
.
Returns the number of requests dispatched or an error.
fn run(&mut self) -> IoResult<()>
[src]
Runs the event loop
This method will call repetitively the dispatch method,
until one of the handlers call the stop_loop
method
on the EventLoopHandle
.
If this event loop is attached to a display, it will also
flush the events to the clients between two calls to
dispatch()
.
Note that this method will block indefinitely on waiting events,
as such, if you need to avoid a complete block even if no events
are received, you should use the dispatch()
method instead and
set a timeout.
fn register_global<R: Resource, ID>(
&mut self,
version: i32,
callback: GlobalCallback<R, ID>,
idata: ID
) -> Global<R, ID>
[src]
&mut self,
version: i32,
callback: GlobalCallback<R, ID>,
idata: ID
) -> Global<R, ID>
Register a global object to the display.
Specify the version of the interface to advertize, as well as the callback that will receive requests to create an object.
This uses an "implementation data" mechanism similar to regular wayland objects.
Panics:
- if the event loop is not associated to a display
Methods from Deref<Target = EventLoopHandle>
fn register<R, ID>(
&mut self,
resource: &R,
implementation: R::Implementation,
idata: ID,
destructor: Option<fn(_: &R)>
) -> RegisterStatus where
R: Resource + Implementable<ID>,
ID: 'static,
[src]
&mut self,
resource: &R,
implementation: R::Implementation,
idata: ID,
destructor: Option<fn(_: &R)>
) -> RegisterStatus where
R: Resource + Implementable<ID>,
ID: 'static,
Register a resource to this event loop.
You are required to provide a valid implementation for this proxy as well as some associated implementation data. This implementation is expected to be a struct holding the various relevant function pointers.
This implementation data can typically contain indexes to state value that the implementation will need to work on.
If you provide a destructor function, it will be called whenever the resource is destroyed, be it at the client request or because the associated client was disconnected. You'd typically use this to cleanup resources
This overwrites any precedently set implementation for this proxy.
Returns appropriately and does nothing if this proxy is dead or already managed by something else than this library.
fn stop_loop(&mut self)
[src]
Stop looping
If the event loop this handle belongs to is currently running its run()
method, it'll stop and return as soon as the current dispatching session ends.
fn state(&mut self) -> &mut State
[src]
Get an handle to the internal state
The returned guard object allows you to get references to the handler objects you previously inserted in this event loop.
fn add_fd_event_source<ID: 'static>(
&mut self,
fd: RawFd,
implementation: FdEventSourceImpl<ID>,
idata: ID,
interest: FdInterest
) -> IoResult<FdEventSource<ID>>
[src]
&mut self,
fd: RawFd,
implementation: FdEventSourceImpl<ID>,
idata: ID,
interest: FdInterest
) -> IoResult<FdEventSource<ID>>
Add a File Descriptor event source to this event loop
The interest in read/write capability for this FD must be provided (and can be changed afterwards using the returned object), and the associated handler will be called whenever these capabilities are satisfied, during the dispatching of this event loop.
fn add_timer_event_source<ID>(
&mut self,
implementation: TimerEventSourceImpl<ID>,
idata: ID
) -> IoResult<TimerEventSource<ID>> where
ID: 'static,
[src]
&mut self,
implementation: TimerEventSourceImpl<ID>,
idata: ID
) -> IoResult<TimerEventSource<ID>> where
ID: 'static,
Add a timer event source to this event loop
It is a countdown, which can be reset using the struct returned by this function. When the countdown reaches 0, the registered handler is called in the dispatching of this event loop.
fn add_signal_event_source<ID>(
&mut self,
implementation: SignalEventSourceImpl<ID>,
idata: ID,
signal: Signal
) -> IoResult<SignalEventSource<ID>> where
ID: 'static,
[src]
&mut self,
implementation: SignalEventSourceImpl<ID>,
idata: ID,
signal: Signal
) -> IoResult<SignalEventSource<ID>> where
ID: 'static,
Add a signal event source to this event loop
This will listen for a given unix signal (by setting up a signalfd for it) and call the registered handler whenever the program receives this signal. Calls are made during the dispatching of this event loop.
Trait Implementations
impl Deref for EventLoop
[src]
type Target = EventLoopHandle
The resulting type after dereferencing.
fn deref(&self) -> &EventLoopHandle
[src]
Dereferences the value.
impl DerefMut for EventLoop
[src]
fn deref_mut(&mut self) -> &mut EventLoopHandle
[src]
Mutably dereferences the value.