[−][src]Struct winit::event_loop::EventLoop
Provides a way to retrieve events from the system and from the windows that were registered to the events loop.
An EventLoop
can be seen more or less as a "context". Calling EventLoop::new()
initializes everything that will be required to create windows. For example on Linux creating
an events loop opens a connection to the X or Wayland server.
To wake up an EventLoop
from a another thread, see the EventLoopProxy
docs.
Note that the EventLoop
cannot be shared across threads (due to platform-dependant logic
forbidding it), as such it is neither Send
nor Sync
. If you need cross-thread access, the
Window
created from this EventLoop
can be sent to an other thread, and the
EventLoopProxy
allows you to wake up an EventLoop
from an other thread.
Methods
impl EventLoop<()>
[src]
impl<T> EventLoop<T>
[src]
pub fn new_user_event() -> EventLoop<T>
[src]
Builds a new event loop.
Usage will result in display backend initialisation, this can be controlled on linux
using an environment variable WINIT_UNIX_BACKEND
. Legal values are x11
and wayland
.
If it is not set, winit will try to connect to a wayland connection, and if it fails will
fallback on x11. If this variable is set with any other value, winit will panic.
ⓘImportant traits for AvailableMonitorsIterpub fn get_available_monitors(&self) -> AvailableMonitorsIter
[src]
Returns the list of all the monitors available on the system.
pub fn get_primary_monitor(&self) -> MonitorHandle
[src]
Returns the primary monitor of the system.
pub fn run<F>(self, event_handler: F) -> ! where
F: 'static + FnMut(Event<T>, &EventLoopWindowTarget<T>, &mut ControlFlow),
[src]
F: 'static + FnMut(Event<T>, &EventLoopWindowTarget<T>, &mut ControlFlow),
Hijacks the calling thread and initializes the winit
event loop with the provided
closure. Since the closure is 'static
, it must be a move
closure if it needs to
access any data from the calling context.
See the ControlFlow
docs for information on how changes to &mut ControlFlow
impact the
event loop's behavior.
Any values not passed to this function will not be dropped.
pub fn create_proxy(&self) -> EventLoopProxy<T>
[src]
Creates an EventLoopProxy
that can be used to wake up the EventLoop
from another
thread.
Trait Implementations
impl<T> EventLoopExtWindows for EventLoop<T>
[src]
fn new_dpi_unaware() -> Self
[src]
impl<T> EventLoopExtDesktop for EventLoop<T>
[src]
type UserEvent = T
A type provided by the user that can be passed through Event::UserEvent
.
fn run_return<F>(&mut self, event_handler: F) where
F: FnMut(Event<T>, &EventLoopWindowTarget<T>, &mut ControlFlow),
[src]
F: FnMut(Event<T>, &EventLoopWindowTarget<T>, &mut ControlFlow),
impl<T> Debug for EventLoop<T>
[src]
impl<T> Deref for EventLoop<T>
[src]
type Target = EventLoopWindowTarget<T>
The resulting type after dereferencing.
fn deref(&self) -> &EventLoopWindowTarget<T>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,