Trait winit::platform::windows::EventLoopBuilderExtWindows

source ·
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;
}
Available on windows_platform only.
Expand description

Additional methods on EventLoop that are specific to Windows.

Required Methods§

source

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.

source

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 winit::event_loop::EventLoopBuilder;
#[cfg(target_os = "windows")]
use winit::platform::windows::EventLoopBuilderExtWindows;

let mut builder = EventLoopBuilder::new();
#[cfg(target_os = "windows")]
builder.with_dpi_aware(false);
let event_loop = builder.build();
source

fn with_msg_hook<F>(&mut self, callback: F) -> &mut Self
where F: FnMut(*const c_void) -> bool + 'static,

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 winit::event_loop::EventLoopBuilder;
#[cfg(target_os = "windows")]
use winit::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
});

Object Safety§

This trait is not object safe.

Implementors§