pub trait EventLoopBuilderExtWindows {
// Required methods
fn with_any_thread(&mut self, any_thread: bool) -> &mut Self;
fn with_dpi_aware(&mut self, dpi_aware: bool) -> &mut Self;
fn with_msg_hook<F>(&mut self, callback: F) -> &mut Self
where F: FnMut(*const c_void) -> bool + 'static;
}
Expand description
Additional methods on EventLoop
that are specific to Windows.
Required Methods§
Sourcefn with_any_thread(&mut self, any_thread: bool) -> &mut Self
fn with_any_thread(&mut self, any_thread: bool) -> &mut Self
Whether to allow the event loop to be created off of the main thread.
By default, the window is only allowed to be created on the main thread, to make platform compatibility easier.
§Window
caveats
Note that any Window
created on the new thread will be destroyed when the thread
terminates. Attempting to use a Window
after its parent thread terminates has
unspecified, although explicitly not undefined, behavior.
Sourcefn with_dpi_aware(&mut self, dpi_aware: bool) -> &mut Self
fn with_dpi_aware(&mut self, dpi_aware: bool) -> &mut Self
Whether to enable process-wide DPI awareness.
By default, winit
will attempt to enable process-wide DPI awareness. If
that’s undesirable, you can disable it with this function.
§Example
Disable process-wide DPI awareness.
use rio_window::event_loop::EventLoopBuilder;
#[cfg(target_os = "windows")]
use rio_window::platform::windows::EventLoopBuilderExtWindows;
let mut builder = EventLoopBuilder::new();
#[cfg(target_os = "windows")]
builder.with_dpi_aware(false);
let event_loop = builder.build();
Sourcefn with_msg_hook<F>(&mut self, callback: F) -> &mut Self
fn with_msg_hook<F>(&mut self, callback: F) -> &mut Self
A callback to be executed before dispatching a win32 message to the window procedure. Return true to disable winit’s internal message dispatching.
§Example
use rio_window::event_loop::EventLoopBuilder;
#[cfg(target_os = "windows")]
use rio_window::platform::windows::EventLoopBuilderExtWindows;
let mut builder = EventLoopBuilder::new();
#[cfg(target_os = "windows")]
builder.with_msg_hook(|msg|{
let msg = msg as *const MSG;
let translated = unsafe {
TranslateAcceleratorW(
(*msg).hwnd,
CreateAcceleratorTableW(accels.as_ptr() as _, 1),
msg,
) == 1
};
translated
});
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.