NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #1253 most downloaded on crates.io
Cross-platform window creation library.
Latest stable
0.30.13
Last release 29 days ago
24 Oct 2026
Ships fairly regularly
a new release about every 2 months
Most releases are documented
notes for 53 of the last 60 stable releases
5 versions withdrawn
withdrawn after publishing
11 years old
121 releases · first in 2016
Drag across the ruler to compare, or tap a release to open it.
Add ActiveEventLoop::clipboard and ActiveEventLoop::set_clipboard for interacting with the system clipboard through the data transfer API, implemented
ActiveEventLoop::clipboard and ActiveEventLoop::set_clipboard forActiveEventLoop::primary_selection_ext for interacting withWindowEvent::MouseWheel::source: ScrollSource, telling a mouse wheelkeyboard support for OpenHarmony.Window::drag_window, Window::drag_resize_window and Window::show_window_menu when the interaction was started by touch.Ime::Preedit before Ime::Commit.url dependency from winit-core, along with SendData::from_file_paths,TypedData::try_as_file_paths and impl From<Vec<url::Url>> for SendData. Use SendData::UrisTypedData::try_as_uris with file: URIs instead.Your coding agent can read these notes before it upgrades. Set up the MCP server →
Add keyboard support for OpenHarmony.
keyboard support for OpenHarmony.EventLoopExtPumpEvents::pump_app_events.Send and Sync for OwnedDisplayHandle.HoldGesture event for multi-finger hold gesturesWindowType::Popup), withWindowAttributes::with_positioner for configuring their placement via aWindowPositioner (grouping the anchor edge/corner, the anchor rect, theWindowAnchor, WindowGravity and WindowConstraintAdjustmentWindow::positioner/set_positioner methods forWindow, popup or not;Window::window_type to tell whether a given window is a genuineWindowType::Popup. On Windows and macOS, which have no native positionerxdg_positioner behavior, and it also works for a plain WindowType::Windowxdg_popupWindowType::Popup.WindowAttributesMacOS::with_fullscreen_auxiliary andWindowExtMacOS::set_fullscreen_auxiliary / WindowExtMacOS::fullscreen_auxiliary, allowing aNSWindowCollectionBehaviorFullScreenAuxiliary) instead of triggering a Space switch or SplitWindowEvent::PointerButton::is_macos_activation_click. On macOS, both the press andfalse on other platforms.winit::event_loop::EventLoopProvider trait with common event loop methods.Mark the extensible public enums as #[non_exhaustive]: StartCause, WindowEvent,
DeviceEvent, Ime, PointerKind, PointerSource, ButtonSource, NativeKey,
NativeKeyCode, CustomCursorSource, TypeHint, SendData, DndAction, ImeRequest,
BadIcon, BadImage, BadAnimation, ImeSurroundingTextError, MouseScrollDelta,
and Fullscreen.
When matching on one of these types, add a wildcard arm to cover variants added in the future:
match event {
WindowEvent::CloseRequested => (),
// ...
_ => (),
}On macOS, mark ActivationPolicy as #[non_exhaustive].
On X11, mark WindowType and UriListParseError as #[non_exhaustive].
On Web, mark PollStrategy, WaitUntilStrategy, CustomCursorError, MonitorPermissionError,
and OrientationLockError as #[non_exhaustive].
On Windows, mark BackdropType and CornerPreference as #[non_exhaustive].
On iOS, mark ValidOrientations and StatusBarStyle as #[non_exhaustive].
Updated windows-sys to v0.61.
On older macOS versions (tested up to 12.7.6), applications now receive mouse movement events for unfocused windows, matching the behavior on other platforms.
On macOS, using the private API CGSSetWindowBackgroundBlurRadius for Window::set_blur is now disabled by default. It can be re-enabled using the Cargo feature private-apple-apis.
On macOS, Window::set_blur is now implemented with the public NSVisualEffectView when private-apple-apis is disabled, so binaries no longer link _CGSSetWindowBackgroundBlurRadius, which the Mac App Store rejects under Guideline 2.5.1.
On macOS, blurred windows now render a translucent system material rather than an untinted backdrop blur at a fixed radius of 80, and the radius is no longer configurable; enable the private-apple-apis Cargo feature to keep the previous implementation, which --all-features also enables.
On macOS, added BlurMaterial, WindowAttributesMacOS::with_blur_material and WindowExtMacOS::set_blur_material to choose which material is drawn behind a blurred window.
On macOS, the window's contentView is now a plain container NSView holding winit's view, rather than being winit's view itself; the handle returned by raw-window-handle is unchanged.
On macOS 10.12 and older, enabling blur now makes the window's views layer-backed, which may break the association with an attached NSOpenGLContext.
WindowAttributesMacOS::with_accepts_first_mouse. Use the new per-eventWindowEvent::PointerButton::is_macos_activation_click flag instead. To preserve the oldwith_accepts_first_mouse(false) behavior, ignore PointerButton press events (and theiris_macos_activation_click is true.NotSupported instead of panicking when XInput 2.0, XRandRWM_INPUTLANGCHANGE message is now handledDefWindowProc for normal propagation.HDC handles.GetDC when on < Windows 8.1 which improves its performance.Icon isEINTR when reading from event_socket instead of panicking.ahash hashing algorithm to foldhash.wl_surface version below 3.run_app_on_demand exiting immediately after a previous run_app_on_demand called exit.ApplicationHandler drop.Add EventLoopExtRegister::register_app for being explicit about how the event loop runs on Web.
EventLoopExtRegister::register_app for being explicit about how the event loop runs on Web.EventLoopExtNeverReturn::run_app_never_return for being explicit about how the event loop runs on iOS.EventLoop::run_app, instead preferring to return to the caller.'static application to ensure that the application state will live as long as necessary.Window::set_ime_allowed.NamedKey::Super still exists, but it's non-functional and deprecated, NamedKey::Meta should be used instead.
Add ActiveEventLoop::create_proxy().
On Web, add ActiveEventLoopExtWeb::is_cursor_lock_raw() to determine if
DeviceEvent::MouseMotion is returning raw data, not OS accelerated, when using
CursorGrabMode::Locked.
On Web, implement MonitorHandle and VideoModeHandle.
Without prompting the user for permission, only the current monitor is returned. But when
prompting and being granted permission through
ActiveEventLoop::request_detailed_monitor_permission(), access to all monitors and their
details is available. Handles created with "detailed monitor permissions" can be used in
Window::set_fullscreen() as well.
Keep in mind that handles do not auto-upgrade after permissions are granted and have to be
re-created to make full use of this feature.
Implement Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd
and Serialize on many types.
Add MonitorHandle::current_video_mode().
Add ApplicationHandlerExtMacOS trait, and a macos_handler method to ApplicationHandler which returns a dyn ApplicationHandlerExtMacOS which allows for macOS specific extensions to winit.
Add a standard_key_binding method to the ApplicationHandlerExtMacOS trait. This allows handling of standard keybindings such as "go to end of line" on macOS.
On macOS, add WindowExtMacOS::set_unified_titlebar and WindowAttributesMacOS::with_unified_titlebar
to use a larger style of titlebar.
Add WindowId::into_raw() and from_raw().
Add PointerKind, PointerSource, ButtonSource, FingerId, primary and position to all
pointer events as part of the pointer event overhaul.
Add DeviceId::into_raw() and from_raw().
Added Window::surface_position, which is the position of the surface inside the window.
Added Window::safe_area, which describes the area of the surface that is unobstructed.
On X11, Wayland, Windows and macOS, improved scancode conversions for more obscure key codes.
Add ability to make non-activating window on macOS using NSPanel with NSWindowStyleMask::NonactivatingPanel.
Implement MonitorHandleProvider for MonitorHandle to access common monitor API.
On X11, set an "area" attribute on XIM input connection to convey the cursor area.
Implement CustomCursorProvider for CustomCursor to access cursor API.
Add CustomCursorSource::Url, CustomCursorSource::from_animation.
Implement CustomIconProvider for RgbaIcon.
Add icon module that exposes winit's icon API.
VideoMode::new to create a VideoMode.
keyboard::ModifiersKey to track which modifier is exactly pressed.
ActivationToken::as_raw to get a ref to raw token.
Each platform now has corresponding WindowAttributes struct instead of trait extension.
On Wayland, added implementation for Window::set_window_icon
On Wayland, added PanGesture, PinchGesture, and RotationGesture
Add Window::request_ime_update to atomically apply set of IME changes.
Add Ime::DeleteSurrounding to let the input method delete text.
Add more ImePurpose values.
Add ImeHints to request particular IME behaviour.
Add Pen input support on Wayland, Windows, and Web via new Pointer event.
Change ActiveEventLoop and Window to be traits, and added cast_ref/cast_mut/cast
methods to extract the backend type from those.
ActiveEventLoop::create_window now returns Box<dyn Window>.
ApplicationHandler now uses dyn ActiveEventLoop.
On Web, let events wake up event loop immediately when using ControlFlow::Poll.
Bump MSRV from 1.70 to 1.85.
Changed ApplicationHandler::user_event to user_wake_up, removing the
generic user event.
Winit will now only indicate that wake up happened, you will have to pair
this with an external mechanism like std::sync::mpsc::channel if you want
to send specific data to be processed on the main thread.
Changed EventLoopProxy::send_event to EventLoopProxy::wake_up, it now
only wakes up the loop.
On X11, implement smooth resizing through the sync extension API.
ApplicationHandler::can_create|destroy_surfaces() was split off from
ApplicationHandler::resumed/suspended().
ApplicationHandler::can_create_surfaces() should, for portability reasons
to Android, be the only place to create render surfaces.
ApplicationHandler::resumed/suspended() are now only emitted by iOS, Web
and Android, and now signify actually resuming/suspending the application.
Rename platform::web::*ExtWebSys to *ExtWeb.
Change signature of EventLoop::run_app, EventLoopExtPumpEvents::pump_app_events and
EventLoopExtRunOnDemand::run_app_on_demand to accept a impl ApplicationHandler directly,
instead of requiring a &mut reference to it.
On Web, Window::canvas() now returns a reference.
On Web, CursorGrabMode::Locked now lets DeviceEvent::MouseMotion return raw data, not OS
accelerated, if the browser supports it.
(Active)EventLoop::create_custom_cursor() now returns a Result<CustomCursor, ExternalError>.
Changed how ModifiersState is serialized by Serde.
VideoModeHandle::refresh_rate_millihertz() and bit_depth() now return a Option<NonZero*>.
MonitorHandle::position() now returns an Option.
On macOS, remove custom application delegates. You are now allowed to override the
application delegate yourself.
On X11, remove our dependency on libXcursor. (#3749)
Renamed the following APIs to make it clearer that the sizes apply to the underlying surface:
WindowEvent::Resized to SurfaceResized.InnerSizeWriter to SurfaceSizeWriter.WindowAttributes.inner_size to surface_size.WindowAttributes.min_inner_size to min_surface_size.WindowAttributes.max_inner_size to max_surface_size.WindowAttributes.resize_increments to surface_resize_increments.WindowAttributes::with_inner_size to with_surface_size.WindowAttributes::with_min_inner_size to with_min_surface_size.WindowAttributes::with_max_inner_size to with_max_surface_size.WindowAttributes::with_resize_increments to with_surface_resize_increments.Window::inner_size to surface_size.Window::request_inner_size to request_surface_size.Window::set_min_inner_size to set_min_surface_size.Window::set_max_inner_size to set_max_surface_size.To migrate, you can probably just replace all instances of inner_size with surface_size in your codebase.
Every event carrying a DeviceId now uses Option<DeviceId> instead. A None value signifies that the
device can't be uniquely identified.
Pointer WindowEvents were overhauled. The new events can handle any type of pointer, serving as
a single pointer input source. Now your application can handle any pointer type without having to
explicitly handle e.g. Touch:
CursorMoved to PointerMoved.CursorEntered to PointerEntered.CursorLeft to PointerLeft.MouseInput to PointerButton.primary to every PointerEvent as a way to identify discard non-primary pointers in aposition to every PointerEvent.PointerMoved is not sent after PointerEntered anymore.Touch, which is folded into the Pointer* events.PointerKind added to PointerEntered and PointerLeft, signifying which pointer type isPointerSource added to PointerMoved, similar to PointerKind but holding additionalButtonSource added to PointerButton, similar to PointerKind but holding pointer typeButtonSource::mouse_button() to easily normalize any pointer buttonFingerId added to PointerKind::Touch and PointerSource::Touch able to uniquelyTouch::id.DeviceEvent::MouseMotion to PointerMotion.Force::Calibrated::altitude_angle.On X11, use bottom-right corner for IME hotspot in Window::set_ime_cursor_area.
On macOS and iOS, no longer emit ScaleFactorChanged upon window creation.
On macOS, no longer emit Focused upon window creation.
On iOS, emit more events immediately, instead of queuing them.
Update smol_str to version 0.3
Rename VideoModeHandle to VideoMode, now it only stores plain data.
Make Fullscreen::Exclusive contain (MonitorHandle, VideoMode).
Reworked the file drag-and-drop API.
On macOS, the default menu uses the bundle name or falls back to the process name as before.
The WindowEvent::DroppedFile, WindowEvent::HoveredFile and WindowEvent::HoveredFileCancelled
events have been removed, and replaced with WindowEvent::DragEntered, WindowEvent::DragMoved,
WindowEvent::DragDropped and WindowEvent::DragLeft.
The old drag-and-drop events were emitted once per file. This occurred when files were first
hovered over the window, dropped, or left the window. The new drag-and-drop events are emitted
once per set of files dragged, and include a list of all dragged files. They also include the
pointer position.
The rough correspondence is:
WindowEvent::HoveredFile -> WindowEvent::DragEnteredWindowEvent::DroppedFile -> WindowEvent::DragDroppedWindowEvent::HoveredFileCancelled -> WindowEvent::DragLeftThe WindowEvent::DragMoved event is entirely new, and is emitted whenever the pointer moves
whilst files are being dragged over the window. It doesn't contain any file paths, just the
pointer position.
Updated objc2 to v0.6.
Updated windows-sys to v0.59.
windows-sys, the HWND, HMONITOR, and HMENU types*mut c_void instead of isize.Removed KeyEventExtModifierSupplement, and made the fields text_with_all_modifiers and
key_without_modifiers public on KeyEvent instead.
Move window::Fullscreen to monitor::Fullscreen.
Renamed "super" key to "meta", to match the naming in the W3C specification.
NamedKey::Super still exists, but it's non-functional and deprecated, NamedKey::Meta should be used instead.
Move IconExtWindows into WinIcon.
Move EventLoopExtPumpEvents and PumpStatus from platform module to winit::event_loop::pump_events.
Move EventLoopExtRunOnDemand from platform module to winit::event_loop::run_on_demand.
Use NamedKey, Code and Location from the keyboard-types v0.8 crate.
Deprecate Window::set_ime_allowed, Window::set_ime_cursor_area, and Window::set_ime_purpose.
Force::normalized() now takes a Option<ToolAngle> to calculate the perpendicular force.
On Windows, don't confine cursor to center of window when grabbed and hidden.
Remove Event.
Remove already deprecated APIs:
EventLoop::create_window()EventLoop::run.EventLoopBuilder::new()EventLoopExtPumpEvents::pump_events.EventLoopExtRunOnDemand::run_on_demand.VideoModeWindowAttributes::new()Window::set_cursor_icon()On iOS, remove platform::ios::EventLoopExtIOS and related platform::ios::Idiom type.
This feature was incomplete, and the equivalent functionality can be trivially achieved outside
of winit using objc2-ui-kit and calling UIDevice::currentDevice().userInterfaceIdiom().
On Web, remove unused platform::web::CustomCursorError::Animation.
Remove the rwh_04 and rwh_05 cargo feature and the corresponding raw-window-handle v0.4 and
v0.5 support. v0.6 remains in place and is enabled by default.
Remove DeviceEvent::Added and DeviceEvent::Removed.
Remove DeviceEvent::Motion and WindowEvent::AxisMotion.
Remove MonitorHandle::size() and refresh_rate_millihertz() in favor of
MonitorHandle::current_video_mode().
On Android, remove all MonitorHandle support instead of emitting false data.
Remove impl From<u64> for WindowId and impl From<WindowId> for u64. Replaced with
WindowId::into_raw() and from_raw().
Remove dummy() from WindowId and DeviceId.
Remove WindowEvent::Touch and Touch in favor of the new PointerKind, PointerSource and
ButtonSource as part of the new pointer event overhaul.
Remove Force::altitude_angle.
Remove Window::inner_position, use the new Window::surface_position instead.
Remove CustomCursorExtWeb, use the CustomCursorSource.
Remove CustomCursor::from_rgba, use CustomCursorSource instead.
Remove ApplicationHandler::exited, the event loop being shut down can now be listened to in
the Drop impl on the application handler.
Remove NamedKey::Space, match on Key::Character(" ") instead.
Remove PartialEq impl for WindowAttributes.
WindowAttributesExt* platform extensions; use WindowAttributes* instead.
Remove Force::Calibrated::altitude_angle in favor of ToolAngle::altitude.
MonitorHandle::name() now returns None instead of a dummy name.fullscreen.SurfaceResized and Window::surface_size not reporting the size of the actual surface.IntlBackslash.SurfaceResized event at window creation.WindowEvent::MouseWheel.Window::theme will return the correct theme after setting it through Window::set_theme.Window::set_theme will change the title bar color immediately now.SurfaceResized with size zero when an application is minimized. Let Window::surface_size return the pre-minimization window size even while minimized.axis_value120 scroll events now generate MouseScrollDelta::LineDeltaWindowEvent::MouseWheel events.On Wayland, add Window::set_resize_increments .
Window::set_resize_increments.set_hittest not working on some window managers.set_timestamp.set_marked_text when native Pinyin IME sends out-of-bounds selected_range.WM_IME_SETCONTEXT IME UI flag masking on lParam.KeyEvent::text and KeyEvent::text_with_all_modifiers via Key::to_text().On macOS, fix crash on macOS 26 by using objc2's relax-sign-encoding feature.
relax-sign-encoding feature.On Windows, fixed crash in should_apps_use_dark_mode() for Windows versions < 17763.
pump_events driven loop deadlocking when loop was not drained before exit.On Windows, add IconExtWindows::from_resource_name .
IconExtWindows::from_resource_name.CursorGrabMode::Locked.WindowExtWayland::xdg_toplevel.NSApplication class (which means you can now override it yourself).application:didFinishLaunchingWithOptions: and provide the desired behaviour yourself.WindowExtMacOS::set_simple_fullscreen now honors WindowExtMacOS::set_borderless_gameSome(Duration::Zero) blocking with Wait polling modeset_cursor_grab without pointer focus.FD.run_app_on_demand returning without closing open windows.VideoMode::refresh_rate_millihertz for fractional refresh rates.None instead of panicking.Ime::Preedit cursor offset calculation.On Wayland, no longer send an explicit clearing Ime::Preedit just prior to a new Ime::Preedit .
Ime::Preedit just prior to a new Ime::Preedit.ControlFlow::Wait.ActivationToken::from_raw and ActivationToken::into_raw .
ActivationToken::from_raw and ActivationToken::into_raw.On X11, fixed KeyboardInput delivered twice when IME enabled.
On macOS, add WindowExtMacOS::set_borderless_game and WindowAttributesExtMacOS::with_borderless_game to fully disable the menu bar and dock in Borderl
WindowExtMacOS::set_borderless_game and WindowAttributesExtMacOS::with_borderless_game
to fully disable the menu bar and dock in Borderless Fullscreen as commonly done in games.window example now understands the X11_VISUAL_ID and X11_SCREEN_ID env
variables to test the respective modifiers of window creation.Window::set_ime_allowed.Window::set_ime_allowed.WindowEvent::Moved sometimes being triggered unnecessarily on resize.LSUIElement will no longer be overridden with the
default activation policy, unless explicitly provided during initialization.drag_window() without a left click present.ControlFlow::WaitUntil work more precisely using CREATE_WAITABLE_TIMER_HIGH_RESOLUTION.DISPLAY=:0.1) works again.with_x11_screen(non_default_screen) works again.MonitorHandle's PartialEq and Hash implementations.Add ActiveEventLoop::system_theme(), returning the current system theme.
ActiveEventLoop::system_theme(), returning the current system theme.Error for platform::web::CustomCursorError.{Active,}EventLoopExtAndroid::android_app() to access the app used to create the loop.feature = "rwh_04".WindowEvent::Cursor*.Window::theme() if no theme override is set.DeviceId::dummy() and WindowId::dummy() are no longer marked unsafe.
DeviceId::dummy() and WindowId::dummy() are no longer marked unsafe.WindowEvent::Resized not using requestAnimationFrame when sending
WindowEvent::RedrawRequested and also potentially causing WindowEvent::RedrawRequested
to not be de-duplicated.On Web, add EventLoopExtWebSys::(set_)poll_strategy() to allow setting control flow strategies before starting the event loop.
EventLoopExtWebSys::(set_)poll_strategy() to allow setting
control flow strategies before starting the event loop.WaitUntilStrategy, which allows to set different strategies for
ControlFlow::WaitUntil. By default the Prioritized Task Scheduling API is
used, with a fallback to setTimeout() with a trick to circumvent throttling
to 4ms. But an option to use a Web worker to schedule the timer is available
as well, which commonly prevents any throttling when the window is not focused.NSWindow instead of application-wide.WindowBuilder::with_theme not having any effect on the window.On Web, fix EventLoopProxy::send_event() triggering event loop immediately when not called from inside the event loop. Now queues a microtask instead.
EventLoopProxy::send_event() triggering event loop immediately
when not called from inside the event loop. Now queues a microtask instead.CursorIcon::Default.InnerSizeWriter::request_inner_size().Reexport raw-window-handle versions 0.4 and 0.5 as raw_window_handle_04 and raw_window_handle_05.
raw-window-handle versions 0.4 and 0.5 as raw_window_handle_04 and raw_window_handle_05.ApplicationHandler for &mut references and heap allocations to something that implements ApplicationHandler.EventLoopExtWayland and EventLoopExtX11, providing methods is_wayland and is_x11 on EventLoop.Ime::Preedit.On Wayland, bump sctk-adwaita to 0.9.0, which changed system library crates. This change is a cascading breaking change, you must do breaking change a…
OwnedDisplayHandle type for allowing safe display handle usage outside of
trivial cases.ApplicationHandler<T> trait which mimics Event<T>.WindowBuilder::with_cursor and Window::set_cursor which takes a
CursorIcon or CustomCursor.Sync implementation for EventLoopProxy<T: Send>.Window::default_attributes to get default WindowAttributes.EventLoop::builder to get EventLoopBuilder without export.CustomCursor::from_rgba to allow creating cursor images from RGBA data.CustomCursorExtWebSys::from_url to allow loading cursor images from URLs.CustomCursorExtWebSys::from_animation to allow creating animated
cursors from other CustomCursors.{Active,}EventLoop::create_custom_cursor to load custom cursor image sources.ActiveEventLoop::create_window and EventLoop::create_window.CustomCursor which could be set via Window::set_cursor, implemented on
Windows, macOS, X11, Wayland, and Web.Event.preventDefault() on Window.PinchGesture, DoubleTapGesture, PanGesture and RotationGesture.UIGestureRecognizerDelegate for fine grained control of gesture recognizers.with_title_text_color, and with_corner_preference on
WindowAttributesExtWindows.AnyThread API to access window handle off the main thread.1.65 to 1.70.sctk-adwaita to 0.9.0, which changed system library
crates. This change is a cascading breaking change, you must do breaking
change as well, even if you don't expose winit.TouchpadMagnify to PinchGesture.SmartMagnify to DoubleTapGesture.TouchpadRotate to RotationGesture.EventLoopWindowTarget to ActiveEventLoop.platform::x11::XWindowType to platform::x11::WindowType.VideoMode to VideoModeHandle to represent that it doesn't hold
static data.Debug formatting of WindowId more concise.dpi types to its own crate, and re-export it from the root crate.log with tracing, use log feature on tracing to restore old
behavior.EventLoop::with_user_event now returns EventLoopBuilder.HandleError::Unavailable when a window handle is not available.RawWindowHandle::WebCanvas instead of RawWindowHandle::Web.HandleError::Unavailable when a window handle is not available.HandleError::Unavailable when a window handle is not available.WS_CAPTION, WS_BORDER, and WS_EX_WINDOWEDGE styles
for child windows without decorations.ndk to 0.9.0 and android-activity to 0.6.0,
and remove unused direct dependency on ndk-sys.Deprecate EventLoop::run, use EventLoop::run_app.
Deprecate EventLoopExtRunOnDemand::run_on_demand, use EventLoop::run_app_on_demand.
Deprecate EventLoopExtPumpEvents::pump_events, use EventLoopExtPumpEvents::pump_app_events.
The new app APIs accept a newly added ApplicationHandler<T> instead of
Fn. The semantics are mostly the same, given that the capture list of the
closure is your new State. Consider the following code:
use winit::event::Event;
use winit::event_loop::EventLoop;
use winit::window::Window;
struct MyUserEvent;
let event_loop = EventLoop::<MyUserEvent>::with_user_event().build().unwrap();
let window = event_loop.create_window(Window::default_attributes()).unwrap();
let mut counter = 0;
let _ = event_loop.run(move |event, event_loop| {
match event {
Event::AboutToWait => {
window.request_redraw();
counter += 1;
}
Event::WindowEvent { window_id, event } => {
// Handle window event.
}
Event::UserEvent(event) => {
// Handle user event.
}
Event::DeviceEvent { device_id, event } => {
// Handle device event.
}
_ => (),
}
});
To migrate this code, you should move all the captured values into some
newtype State and implement ApplicationHandler for this type. Finally,
we move particular match event arms into methods on ApplicationHandler,
for example:
use winit::application::ApplicationHandler;
use winit::event::{Event, WindowEvent, DeviceEvent, DeviceId};
use winit::event_loop::{EventLoop, ActiveEventLoop};
use winit::window::{Window, WindowId};
struct MyUserEvent;
struct State {
window: Window,
counter: i32,
}
impl ApplicationHandler<MyUserEvent> for State {
fn user_event(&mut self, event_loop: &ActiveEventLoop, user_event: MyUserEvent) {
// Handle user event.
}
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
// Your application got resumed.
}
fn window_event(&mut self, event_loop: &ActiveEventLoop, window_id: WindowId, event: WindowEvent) {
// Handle window event.
}
fn device_event(&mut self, event_loop: &ActiveEventLoop, device_id: DeviceId, event: DeviceEvent) {
// Handle device event.
}
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop) {
self.window.request_redraw();
self.counter += 1;
}
}
let event_loop = EventLoop::<MyUserEvent>::with_user_event().build().unwrap();
#[allow(deprecated)]
let window = event_loop.create_window(Window::default_attributes()).unwrap();
let mut state = State { window, counter: 0 };
let _ = event_loop.run_app(&mut state);
Please submit your feedback after migrating in this issue.
Deprecate Window::set_cursor_icon, use Window::set_cursor.
Remove Window::new, use ActiveEventLoop::create_window instead.
You now have to create your windows inside the actively running event loop
(usually the new_events(cause: StartCause::Init) or resumed() events),
and can no longer do it before the application has properly launched.
This change is done to fix many long-standing issues on iOS and macOS, and
will improve things on Wayland once fully implemented.
To ease migration, we provide the deprecated EventLoop::create_window that
will allow you to bypass this restriction in this release.
Using the migration example from above, you can change your code as follows:
use winit::application::ApplicationHandler;
use winit::event::{Event, WindowEvent, DeviceEvent, DeviceId};
use winit::event_loop::{EventLoop, ActiveEventLoop};
use winit::window::{Window, WindowId};
#[derive(Default)]
struct State {
// Use an `Option` to allow the window to not be available until the
// application is properly running.
window: Option<Window>,
counter: i32,
}
impl ApplicationHandler for State {
// This is a common indicator that you can create a window.
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
self.window = Some(event_loop.create_window(Window::default_attributes()).unwrap());
}
fn window_event(&mut self, event_loop: &ActiveEventLoop, window_id: WindowId, event: WindowEvent) {
// `unwrap` is fine, the window will always be available when
// receiving a window event.
let window = self.window.as_ref().unwrap();
// Handle window event.
}
fn device_event(&mut self, event_loop: &ActiveEventLoop, device_id: DeviceId, event: DeviceEvent) {
// Handle window event.
}
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop) {
if let Some(window) = self.window.as_ref() {
window.request_redraw();
self.counter += 1;
}
}
}
let event_loop = EventLoop::new().unwrap();
let mut state = State::default();
let _ = event_loop.run_app(&mut state);
Remove Deref implementation for EventLoop that gave EventLoopWindowTarget.
Remove WindowBuilder in favor of WindowAttributes.
Remove Generic parameter T from ActiveEventLoop.
Remove EventLoopBuilder::with_user_event, use EventLoop::with_user_event.
Remove Redundant EventLoopError::AlreadyRunning.
Remove WindowAttributes::fullscreen and expose as field directly.
On X11, remove platform::x11::XNotSupported export.
On X11, fix crash due to xsettings query on systems with incomplete xsettings.
On X11/Wayland, fix text and text_with_all_modifiers not being None during compose.
text and text_with_all_modifiers not being None during compose.On Web, fix possible crash with ControlFlow::Wait and ControlFlow::WaitUntil.
ControlFlow::Wait and ControlFlow::WaitUntil.On X11, fix use after free during xinput2 handling.
On Wayland, fix DeviceEvent::Motion not being sent
Occluded event handling._XSETTINGS_SETTINGS update.Focused(false) being send when other seats still have window focused.Window::set_{min,max}_inner_size not always applied.WAYLAND_SOCKET not used when detecting platform.logical_key and text not reported in KeyEvent.KeyEventExtModifierSupplement.NamedKey when possible.set_cursor_grab.set_cursor_visible.drag_window.drag_resize_window.set_transparent.set_visible.is_visible.set_resizable.is_resizable.set_maximized.is_maximized.set_decorations.is_decorated.set_window_level.DeviceEvent::MouseMotion.AboutToWait.On Web, account for canvas being focused already before event loop starts.
On X11, fix NotSupported error not propagated when creating event loop.
NotSupported error not propagated when creating event loop.ArrowLeft.On X11, fix IME input lagging behind.
ModifiersChanged not sent from xdotool-like inputWindow::request_inner_size being overwritten by resize.Window::inner_size not using the correct rounding.On X11, fix Xft.dpi reload during runtime.
Xft.dpi reload during runtime.On Web, fix context menu not being disabled by with_prevent_default(true).
with_prevent_default(true).WindowEvent::Destroyed not being delivered after destroying window.EventLoopExtRunOnDemand::run_on_demand not working for consequent invocationOn macOS, remove spurious error logging when handling Fn.
Fn.refresh_rate_millihertz.wl_subcompositor is not supported.Xft.dpi detection from Xresources.window.set_fullscreen(Some(Fullscreen::Borderless(None))) resulting in losing previous window state when eventually exiting fullscreen using window.set_fullscreen(None).set_ime_cursor_area.Fix crash when running iOS app on macOS.
drag_window and drag_resize_window can be called from another thread.set_control_flow in AboutToWait not being taken in account.Resized event after each ScaleFactorChanged event.wl_surface being destroyed before associated objects.Fn key.On Wayland, apply correct scale to PhysicalSize passed in WindowBuilder::with_inner_size when possible.
PhysicalSize passed in WindowBuilder::with_inner_size when possible.RedrawRequsted being always sent without decorations and sctk-adwaita feature.configure_bounds to constrain with_inner_size when compositor wants users to pick size.Cursor{Enter,Leave}.Window::set_transparent.Window::set_blur.Breaking: Remove all deprecated modifiers fields.
1.60 to 1.65.Event::MemoryWarning; implemented on iOS/Android.ndk version to 0.8.0, ndk-sys to 0.5.0, android-activity to 0.5.0.ControlFlow from Poll to Wait.Event::RedrawRequested to WindowEvent::RedrawRequested.ControlFlow::Exit to EventLoopWindowTarget::exit() and EventLoopWindowTarget::exiting() and removed ControlFlow::ExitWithCode(_) entirely.ControlFlow to EventLoopWindowTarget::set_control_flow() and EventLoopWindowTarget::control_flow().EventLoop::new and EventLoopBuilder::build now return Result<Self, EventLoopError>WINIT_UNIX_BACKEND was removed in favor of standard WAYLAND_DISPLAY and DISPLAY variables.DeviceEvent::Text.Event and WindowEvent.Window::set_inner_size to Window::request_inner_size and indicate if the size was applied immediately.ActivationTokenDone event which could be requested with the new startup_notify module, see its docs for more.ScaleFactorChanged now contains a writer instead of a reference to update inner size.run() -> ! has been replaced by run() -> Result<(), EventLoopError> for returning errors without calling std::process::exit() (#2767)EventLoopExtRunReturn / run_return in favor of EventLoopExtPumpEvents / pump_events and EventLoopExtRunOnDemand / run_on_demand (#2767)RedrawRequested is no longer guaranteed to be emitted after MainEventsCleared, it is now platform-specific when the event is emitted after being requested via redraw_request().
RedrawRequested is now driven by WM_PAINT messages which are requested via redraw_request()LoopDestroyed renamed to LoopExiting (#2900)RedrawEventsCleared removed (#2900)MainEventsCleared removed (#2900)modifiers fields.DeviceEventFilter to DeviceEvents reversing the behavior of variants.AboutToWait event which is emitted when the event loop is about to block and wait for new events (#2900)EventLoopWindowTarget::set_device_event_filter to listen_device_events.Window::set_ime_position to Window::set_ime_cursor_area adding a way to set exclusive zone.with_x11_visual now takes the visual ID instead of the bare pointer.MouseButton now supports Back and Forward variants, emitted from mouse events on Wayland, X11, Windows, macOS and Web.instant is now replaced by web_time.WindowEvent::Resized.bitflags crate version to 2, which changes the API on exposed types.CursorIcon::Arrow was removed.CursorIcon::Hand is now named CursorIcon::Pointer.CursorIcon is now used from the cursor-icon crate.WindowExtWebSys::canvas() now returns an Option.KeyboardInput with KeyEvent and RawKeyEvent.
WindowEvent::KeyboardInput to contain a KeyEvent.Event::Key to contain a RawKeyEvent.Event::ReceivedCharacter. In its place, you should use
KeyEvent.text in combination with WindowEvent::Ime.VirtualKeyCode with the Key enum.ScanCode with the KeyCode enum.ModifiersState::LOGO to SUPER and ModifiersState::CTRL to CONTROL.PhysicalKey wrapping KeyCode and NativeKeyCode.KeyCode to refer to keys (roughly) by their physical location.NativeKeyCode to represent raw KeyCodes which Winit doesn't
understand.Key to represent the keys after they've been interpreted by the
active (software) keyboard layout.NamedKey to represent the categorized keys.NativeKey to represent raw Keys which Winit doesn't understand.KeyLocation to tell apart Keys which usually "mean" the same thing,
but can appear simultaneously in different spots on the same keyboard
layout.Window::reset_dead_keys to enable application-controlled cancellation
of dead key sequences.KeyEventExtModifierSupplement to expose additional (and less
portable) interpretations of a given key-press.PhysicalKeyExtScancode, which lets you convert between scancodes and
PhysicalKey.ModifiersChanged now uses dedicated Modifiers struct.raw-window-handle trait implementations instead:
platform::windows::HINSTANCE.WindowExtWindows::hinstance.WindowExtWindows::hwnd.WindowExtIOS::ui_window.WindowExtIOS::ui_view_controller.WindowExtIOS::ui_view.WindowExtMacOS::ns_window.WindowExtMacOS::ns_view.EventLoopWindowTargetExtWayland::wayland_display.WindowExtWayland::wayland_surface.WindowExtWayland::wayland_display.WindowExtX11::xlib_window.WindowExtX11::xlib_display.WindowExtX11::xlib_screen_id.WindowExtX11::xcb_connection.raw-window-handle in window module.ElementState::is_pressed.Window::pre_present_notify to notify winit before presenting to the windowing system.Window::set_blur to request a blur behind the window; implemented on Wayland for now.Window::show_window_menu to request a titlebar/system menu; implemented on Wayland/Windows for now.AsFd/AsRawFd for EventLoop<T> on X11 and Wayland.PartialOrd and Ord for MouseButton.PartialOrd and Ord on types in the dpi module.WindowBuilder Send + Sync.MonitorHandle and VideoMode usable from other threads.EventLoopBuilderExtAndroid::handle_volume_keys to indicate that the application will handle the volume keys manually.DeviceId to contain device id's.ModifiersChanged not being sent.Window::outer_size now accounts for client side decorations.Window::drag_resize_window method.WINIT_WAYLAND_CSD_THEME variable.TouchPhase::Canceled being sent for moved events.Occluded event with xdg-shell v6RedrawRequested events so redraws will align with compositor.ControlFlow::WaitUntil now uses the Prioritized Task Scheduling API. setTimeout(), with a trick to circumvent throttling to 4ms, is used as a fallback.EventLoopProxy now implements Send.Window now implements Send and Sync.padding, border, and margin when getting or setting the canvas position.DeviceEvent::Motion, DeviceEvent::MouseWheel, DeviceEvent::Button and DeviceEvent::Key support.EventLoopWindowTargetExtWebSys and PollStrategy, which allows to set different strategies for ControlFlow::Poll. By default the Prioritized Task Scheduling API is used, but an option to use Window.requestIdleCallback is available as well. Both use setTimeout(), with a trick to circumvent throttling to 4ms, as a fallback.WindowBuilderExtWebSys::with_append() to append the canvas element to the web page on creation.spawn.ControlFlow::WaitUntil to never wake up before the given time.DeviceEvent::MouseMotion only being emitted for each canvas instead of the whole window.Window:::set_fullscreen doing nothing when called outside the event loop but during transient activation.WindowBuilder methods doing nothing.Window methods using incorrect HTML attributes instead of CSS properties.beforeunload event and map bfcache loading/unloading to Suspended/Resumed events.Window::focus_window().Window::set_(min|max)_inner_size().WindowEvent::Occluded.MonitorHandle.Window::is_dark_mode(), which was replaced with Window::theme().EventLoopWindowTarget::listen_device_events() settings.Window.requestAnimationFrame() to throttle RedrawRequested events.Window::request_redraw not waking the event loop when called from outside the loop.drag_resize_window method support.DeviceEvent.WindowBuilderExtWindows::with_class_name to customize the internal class name.CursorEnter/Left not being sent when grabbing the mouse.RedrawRequested not being delivered when calling Window::request_redraw from RedrawRequested.windows-sys version 0.48.0.with_embedded_parent_window function to the window builder to allow embedding a window into another window.ControlFlow::Poll and ControlFlow::WaitUntil.visual_id in returned raw-window-handle.ControlFlow::Poll to ControlFlow::Poll.WindowEvent::Occluded(false), WindowEvent::Occluded(true) when application enters/leaves foreground.WindowExtMacOS and EventLoopWindowTargetExtMacOS.Globe key.window.set_minimized(false).Window.Breaking: Bump ndk version to 0.8.0-beta.0, ndk-sys to v0.5.0-beta.0, android-activity to 0.5.0-beta.1.
ndk version to 0.8.0-beta.0, ndk-sys to v0.5.0-beta.0, android-activity to 0.5.0-beta.1.1.64 to 1.65.raw-window-handle in window module.WINIT_UNIX_BACKEND was removed in favor of standard WAYLAND_DISPLAY and DISPLAY variables.EventLoop::new and EventLoopBuilder::build now return Result<Self, EventLoopError>visual_id in returned raw-window-handle.raw-window-handle trait implementations instead:
platform::windows::HINSTANCE.WindowExtWindows::hinstance.WindowExtWindows::hwnd.WindowExtIOS::ui_window.WindowExtIOS::ui_view_controller.WindowExtIOS::ui_view.WindowExtMacOS::ns_window.WindowExtMacOS::ns_view.EventLoopWindowTargetExtWayland::wayland_display.WindowExtWayland::wayland_surface.WindowExtWayland::wayland_display.WindowExtX11::xlib_window.WindowExtX11::xlib_display.WindowExtX11::xlib_screen_id.WindowExtX11::xcb_connection.Window.requestAnimationFrame() to throttle RedrawRequested events.RedrawRequested events so redraws will align with compositor.Window::pre_present_notify to notify winit before presenting to the windowing system.WindowBuilderExtWindows::with_class_name to customize the internal class name.Event and WindowEvent.ScaleFactorChanged now contains a writer instead of a reference to update inner size.ControlFlow::Poll to ControlFlow::Poll.ActivationTokenDone event which could be requested with the new startup_notify module, see its docs for more.WindowExtMacOS and EventLoopWindowTargetExtMacOS.Window::set_inner_size to Window::request_inner_size and indicate if the size was applied immediately.PartialOrd and Ord for Key, KeyCode, NativeKey, and NativeKeyCode.ElementState::is_pressed.WindowEvent::Occluded.padding, border, and margin when getting or setting the canvas position.Window::set_(min|max)_inner_size().Window methods using incorrect HTML attributes instead of CSS properties.WindowBuilder methods doing nothing.Window::focus_window().Window::is_dark_mode(), which was replaced with Window::theme().WindowBuilderExtWebSys::with_append() to append the canvas element to the web page on creation.drag_resize_window method support.run() ->! has been replaced by run() -> Result<(), EventLoopError> for returning errors without calling std::process::exit() (#2767)EventLoopExtRunReturn / run_return in favor of EventLoopExtPumpEvents / pump_events and EventLoopExtRunOnDemand / run_ondemand (#2767)RedrawRequested is no longer guaranteed to be emitted after MainEventsCleared, it is now platform-specific when the event is emitted after being requested via redraw_request().
RedrawRequested is now driven by WM_PAINT messages which are requested via redraw_request()LoopDestroyed renamed to LoopExiting (#2900)RedrawEventsCleared removed (#2900)MainEventsCleared removed (#2900)AboutToWait event which is emitted when the event loop is about to block and wait for new events (#2900)with_x11_visual now takes the visual ID instead of the bare pointer.with_embedded_parent_window function to the window builder to allow embedding a window into another window.Nothing published for this version
Breaking: Remove all deprecated modifiers fields.
spawn.Window::set_ime_position to Window::set_ime_cursor_area adding a way to set exclusive zone.EventLoopBuilderExtAndroid::handle_volume_keys to indicate that the application will handle the volume keys manually.DeviceEventFilter to DeviceEvents reversing the behavior of variants.EventLoopWindowTarget::set_device_event_filter to listen_device_events.EventLoopWindowTarget::listen_device_events effect being reversed.modifiers fields.KeyboardInput with KeyEvent and RawKeyEvent.
WindowEvent::KeyboardInput to contain a KeyEvent.Event::Key to contain a RawKeyEvent.Event::ReceivedCharacter. In its place, you should use
KeyEvent.text in combination with WindowEvent::Ime.VirtualKeyCode with the Key enum.ScanCode with the KeyCode enum.ModifiersState::LOGO to SUPER and ModifiersState::CTRL to CONTROL.KeyCode to refer to keys (roughly) by their physical location.NativeKeyCode to represent raw KeyCodes which Winit doesn't
understand.Key to represent the keys after they've been interpreted by the
active (software) keyboard layout.NativeKey to represent raw Keys which Winit doesn't understand.KeyLocation to tell apart Keys which usually "mean" the same thing,
but can appear simultaneously in different spots on the same keyboard
layout.Window::reset_dead_keys to enable application-controlled cancellation
of dead key sequences.KeyEventExtModifierSupplement to expose additional (and less
portable) interpretations of a given key-press.KeyCodeExtScancode, which lets you convert between raw keycodes and
KeyCode.ModifiersChanged now uses dedicated Modifiers struct.ModifiersChanged not being sent.CursorIcon is now used from the cursor-icon crate.CursorIcon::Hand is now named CursorIcon::Pointer.CursorIcon::Arrow was removed.Window::outer_size now accounts for client side decorations.Window::drag_resize_window method.WINIT_WAYLAND_CSD_THEME variable.PartialOrd and Ord on types in the dpi module.1.60 to 1.64.Window::request_redraw not waking the event loop when called from outside the loop.Window:::set_fullscreen doing nothing when called outside the event loop but during
a transient activation.bitflags crate version to 2, which changes the API on exposed types.instant is now replaced by web_time.windows-sys version 0.48.0.EventLoopProxy now implements Send.Window now implements Send and Sync.WindowExtWebSys::canvas() now returns an Option.beforeunload event and map bfcache loading/unloading to Suspended/Resumed events.Window.Window.requestIdleCallback() for ControlFlow::Poll when available.WindowEvent::Resized.EventLoopWindowTarget::listen_device_events() settings.DeviceEvent::MouseMotion only being emitted for each canvas instead of the whole window.DeviceEvent::Motion, DeviceEvent::MouseWheel, DeviceEvent::Button and
DeviceEvent::Key support.MouseButton now supports Back and Forward variants, emitted from mouse events
on Wayland, X11, Windows, macOS and Web.Fix window size sometimes being invalid when resizing on macOS 14 Sonoma.
On macOS, fixed memory leak when getting monitor handle.
Backspace being emitted when clearing preedit with it.On macOS, fix key_up being ignored when Ime is disabled.
key_up being ignored when Ime is disabled.On macOS, fix empty marked text blocking regular input.
Window::set_ime_position from another thread.Nothing published for this version
Implement HasRawDisplayHandle for EventLoop.
HasRawDisplayHandle for EventLoop.Window::theme.On Wayland, fix crash when dropping a window in multi-window setup.
Breaking:: Removed deprecated method platform::WindowExtUnix::is_ready.
Ime::Commit persisting for all input after interacting with Ime.WindowExtMacOS::option_as_alt and WindowExtMacOS::set_option_as_alt.WindowBuilder::with_active.Window::is_minimized.register_xlib_error_hook invocation bleeding into winit.Window::has_focus.Window::set_minimized(false) not working for windows minimized by Win + D hotkey.WindowEvent::Cursor*, WindowEvent::MouseInput, or DeviceEvent::MouseMotion like other platforms, but instead it fires WindowEvent::Touch.WindowBuilder::with_parent API in favor of WindowBuilder::with_parent_window.WS_MAXIMIZE window style when un-minimizing a maximized window.Window::drag_window.Window::set_theme.WindowExtWayland::wayland_set_csd_theme and WindowBuilderExtX11::with_gtk_theme_variant.Window::set_always_on_top and related APIs in favor of Window::set_window_level.MouseButton::Other.WindowExtMacOS::is_document_edited and WindowExtMacOS::set_document_edited APIs.WindowBuilderExtIOS::with_root_view_class; instead, you should use [[view layer] addSublayer: ...] to add an instance of the desired layer class (e.g. CAEAGLLayer or CAMetalLayer). See vulkano-win or wgpu for examples of this.Window::set_content_protected.EventLoopBuilderExtMacOS::with_activate_ignoring_other_apps.WindowBuilder not taking effect for windows created after the first one.Window::title to query the current window title.Alt.accepts_first_mouse configurable.WindowBuilderExtUnix::with_resize_increments to WindowBuilder.Window::resize_increments/Window::set_resize_increments to update resize increments at runtime for X11/macOS.objc2 instead of objc internally.1.57 to 1.60.platform::unix module into platform::x11 and platform::wayland. The extension types are similarly renamed.platform::unix::WindowExtUnix::is_ready.parking_lot dependency.WindowEvent::TouchpadMagnify and WindowEvent::TouchpadRotate. Also add support for touchpad smart-magnification gesture with a new event WindowEvent::SmartMagnify.WindowBuilderExtWebSys::with_prevent_default setting (enabled by default), now additionally prevents scrolling of the webpage in mobile browsers, previously it only disabled scrolling on desktop.wayland-csd-adwaita now uses ab_glyph instead of crossfont to render the title for decorations.wayland-csd-adwaita-crossfont feature was added to use crossfont instead of ab_glyph for decorations.WindowExtX11::with_parent to create child windows.WindowBuilder::with_theme and Window::theme to support per-window dark/light/system theme configuration on macos, windows and wayland.WindowEvent::ThemeChanged.WindowBuilderExtWindows::with_theme and WindowBuilderExtWayland::with_wayland_csd_theme in favour of WindowBuilder::with_theme.WindowExtWindows::theme in favour of Window::theme.doc_auto_cfg when generating docs on docs.rs for feature labels.android-activity crate as a glue layer instead of ndk-glue. See README.md#Android for more details. (#2444)raw-window-handle version 0.4RedrawRequested not emitted during resize.set_wait_timeout function to ControlFlow to allow waiting for a Duration.xlib_xconnection() function from the private interface.drag_resize_window method.Window::set_transparent to provide a hint about transparency of the window on Wayland and macOS.Window::set_ime_purpose for setting the IME purpose, currently implemented on Wayland only.On Wayland, fix byte offset in Ime::Preedit pointing to invalid bytes.
Ime::Preedit pointing to invalid bytes.On Windows, emit ReceivedCharacter events on system keybindings.
ReceivedCharacter events on system keybindings.On Windows, added WindowExtWindows::set_undecorated_shadow and WindowBuilderExtWindows::with_undecorated_shadow to draw the drop shadow behind a borde
WindowExtWindows::set_undecorated_shadow and WindowBuilderExtWindows::with_undecorated_shadow to draw the drop shadow behind a borderless window.Ime::Preedit not being sent on IME reset.raw-window-handle leading to compilation failures.Ime::Preedit event will be sent before Ime::Commit to help clearing preedit.On macOS, fixed touch phase reporting when scrolling.
Window now (additionally) implements the old version (0.4) of the HasRawWindowHandle traitEventLoopWindowTarget::set_device_event_filter.WindowEvent::RedrawRequested being delayed by a frame.The minimum supported Rust version was lowered to 1.57.0 and now explicitly tested.
1.57.0 and now explicitly tested.Deprecated EventLoop::with_user_event; use EventLoopBuilder::with_user_event instead.
ndk-glue's NativeWindow lock is now held between Event::Resumed and Event::Suspended.EventLoopExtWebSys with a spawn method to start the event loop without throwing an exception.WindowEvent::Occluded(bool), currently implemented on macOS and X11.docs.rs for iOS and Android as well.WindowAttributes struct, since all its functionality is accessible from WindowBuilder.WindowBuilder::transparent getter to check if the user set transparent attribute.Event::LoopDestroyed on CMD+Q.set_cursor_hittest to let the window ignore mouse events.WindowExtWindows::set_skip_taskbar and WindowBuilderExtWindows::with_skip_taskbar.EventLoopBuilderExtWindows::with_msg_hook.set_ime_position after moving the window.Window::is_visible.Window::is_resizable.Window::is_decorated.ControlFlow was WaitDeviceEvent::MouseMotion.ndk version to 0.6, ndk-sys to v0.3, ndk-glue to 0.6.WINIT_LINK_COLORSYNC environment variable.Exit variant of ControlFlow to ExitWithCode, which holds a value to control the exit code after running. Add an Exit constant which aliases to ExitWithCode(0) instead to avoid major breakage. This shouldn't affect most existing programs.EventLoopBuilder, which allows you to create and tweak the settings of an event loop before creating it.EventLoop::with_user_event; use EventLoopBuilder::with_user_event instead.EventLoopExtMacOS with EventLoopBuilderExtMacOS (which also has renamed methods).EventLoopExtWindows with EventLoopBuilderExtWindows (which also has renamed methods).EventLoopExtUnix with EventLoopBuilderExtUnix (which also has renamed methods).winit::platform::windows have changed. All HANDLE-like types e.g. HWND and HMENU were converted from winapi types or *mut c_void to isize. This was done to be consistent with the type definitions in windows-sys and to not expose internal dependencies.EventLoop::run_return invocations.WindowBuilder::with_fullscreenvirtual_keycode for KeyboardInput events is now filled in where a suitable match is found.ControlFlow to set its value.TouchPhase::Ended always reporting the location of the first touch down, unless the compositor
sent a cancel or frame event.RedrawEventsCleared even if there are no redraw events, consistent with other platforms.Window::with_app_id and Window::with_class with Window::with_name on WindowBuilderExtUnix.WindowBuilderExtUnix::with_wayland_csd_theme to set color theme in builder.WindowExtUnix::wayland_set_csd_theme to set color theme when creating a window.WINIT_WAYLAND_CSD_THEME env variable was added, it can be used to set "dark"/"light" theme in apps that don't expose theme setting.wayland-csd-adwaita feature that enables proper CSD with title rendering using FreeType system library.wayland-csd-adwaita-notitle feature that enables CSD but without title rendering.Window::set_inner_size after calling Window:set_resizable(false).WindowEvent::Ime supported on desktop platforms.Window::set_ime_allowed supported on desktop platforms.Window::set_ime_allowed and new WindowEvent::Ime events are handled.WindowEvent::Resized is now emitted in frameDidChange instead of windowDidResize.EventLoopWindowTarget::set_device_event_filter to set the filter level.Default on EventLoop<()>.Eq for Fullscreen, Theme, and UserAttentionType.Window::set_cursor_grab now accepts CursorGrabMode to control grabbing behavior.Window::set_cursor_position.WindowBuilder::with_disallow_hidpi, setting true or false by the user no matter the SO default value.EventLoopBuilder::build will now panic when the EventLoop is being created more than once.From<u64> for WindowId and From<WindowId> for u64.MonitorHandle::refresh_rate_millihertz to get monitor's refresh rate.VideoMode::refresh_rate with VideoMode::refresh_rate_millihertz providing better precision.with_prevent_default and with_focusable to WindowBuilderExtWebSys to control whether events should be propagated.raw-window-handle to v0.5 and implement HasRawDisplayHandle for Window and EventLoopWindowTarget.register_xlib_error_hook into winit::platform::unix to subscribe for errors comming from Xlib.ndk and ndk-glue dependencies to the recently released 0.7.0.Resumed event. Applications are recommended to lazily initialize graphics state and windows on first resume for portability.MouseScrollDelta to match the direction of vertical scrolling. A positive X value now means moving the content to the right. The meaning of vertical scrolling stays the same: a positive Y value means moving the content down.Fix linking to the ColorSync framework on macOS 10.7, and in newer Rust versions.
ColorSync framework on macOS 10.7, and in newer Rust versions.Update raw-window-handle to v0.4. This is _not_ a breaking change, we still implement HasRawWindowHandle from v0.3, see rust-windowing/raw-window-hand…
raw-window-handle to v0.4. This is not a breaking change, we still implement HasRawWindowHandle from v0.3, see rust-windowing/raw-window-handle#74. Note that you might have to run cargo update -p raw-window-handle after upgrading.mio to 0.8.WindowExtAndroid::config initially returning an empty Configuration.Window::scale_factor and MonitorHandle::scale_factor initially always returning 1.0.Window::request_redrawstdweb backend.Window::focus_windowto bring the window to the front and set input focus.is_maximized method on Window.explorer.exe.ReceivedCharacter was not being emitted during some key repeat events.hand2 and hand1 for CursorIcon::Hand.smithay-client-toolkit to 0.15.1.request_user_attention with xdg_activation_v1.WindowEvent::ScaleFactorChanged when the only monitor gets reconnected.wayland-dlopen so users can opt out of using dlopen to load system libraries.ndk and ndk-glue to 0.5.WaitUntil.xdg_decoration in kwin_waylandBreaking: On macOS, replace WindowBuilderExtMacOS::with_activation_policy with EventLoopExtMacOS::set_activation_policy
WindowBuilderExtMacOS::with_activation_policy with EventLoopExtMacOS::set_activation_policyInputEvent::KeyEvent is partially implemented providing the key scancode.is_maximized method to Window.WindowBuilderExtWindows::with_menu to set a custom menu at window creation time.ndk and ndk-glue to 0.3: use predefined constants for event ident.WindowEvent::ThemeChanged not properly firing and fixed Window::theme returning the wrong theme.DeviceEvent::MouseMotion to listen for relative mouse movements.WindowBuilder::with_position to allow setting the position of a Window on creation. Supported on Windows, macOS and X11.Window::drag_window. Implemented on Windows, macOS, X11 and Wayland.mio to 0.7.WindowBuilderExtWindows::with_owner_window to allow creating popup windows.WindowExtWindows::set_enable to allow creating modal popup windows.RedrawRequested events immediately while the window is being resized.Default, Hash, and Eq for LogicalPosition, PhysicalPosition, LogicalSize, and PhysicalSize.enable_default_menu_creation)MouseInput event on a "first mouse click".mint).On Windows, fix applications not exiting gracefully due to thread_event_target_callback accessing corrupted memory.
Window::set_ime_position.WindowBuilderExtWindows's is_dark_mode to theme.WindowBuilderExtWindows::with_theme to set a preferred theme.WindowEvent::Focused now works properly instead of always returning false.with_min_inner_size in WindowBuilder.WindowEvent::ReceivedCharacter never being sent on key input.Window::request_redraw not waking the event loop.desktop::EventLoopExtDesktop to run_return::EventLoopExtRunReturn.request_user_attention method to Window.WindowExt::request_user_attention, use Window::request_user_attention.WindowExt::set_urgent, use Window::request_user_attention.MouseButton::Other now uses u16.Deprecate the stdweb backend, to be removed in a future release
available_monitors and primary_monitor are now on EventLoopWindowTarget rather than EventLoop to list monitors event in the event loop.set_fullscreen_inner.window.set_cursor_icon no longer breaks HiDPI scalingWindowBuilderExtWindows::with_drag_and_drop(true).set_inner_size from a callback.hide__other_applications to EventLoopWindowTarget via existing EventLoopWindowTargetExtMacOS trait. hide_other_applications will hide other applications by calling -[NSApplication hideOtherApplications: nil].run_return.run_return.MainEventsCleared events during nested win32 event loops.set_ime_position is now a no-op instead of a runtime crash.set_fullscreen is now a no-op instead of a runtime crash.set_inner_size is now a no-op instead of a runtime crash.ControlFlow::Poll not polling the Android event queue.NSWindow.hasShadow support.ControlFlow::Exit not properly handled.WindowEvent::ScaleFactorChanged event when window.devicePixelRatio is changed.set_cursor_position and set_cursor_grab will now always return an error.PixelDelta scroll events now return a PhysicalPosition.- key is mapped to the Minus virtual key code, instead of Subtract.current_monitor now returns Option<MonitorHandle>.primary_monitor now returns Option<MonitorHandle>.parking_lot to 0.11ndk, ndk-sys and ndk-glue to 0.2. Checkout the new ndk-glue main proc attribute.Add, Multiply, Divide, Decimal, and Subtract with Numpad.Asterisk and Plus virtual key codes.Event::LoopDestroyed event is correctly emitted when leaving the page.WindowEvent::Destroyed event now gets emitted when a Window is dropped.Window is dropped or when the event loop is destroyed.EventLoop::run now gets dropped after the event loop is destroyed.Window is no longer removed from the DOM when the Window is dropped.WindowEvent::Resized is now emitted when Window::set_inner_size is called.Fullscreen enum now uses Borderless(Option<MonitorHandle>) instead of Borderless(MonitorHandle) to allow picking the current monitor.WindowEvent::Moved ignoring the scale factor.set_cursor_grab.resizable attribute not being applied properly on startup.XCURSOR_SIZE is 0.Theme trait was reworked.set_ime_position.Added Clone implementation for 'static events.
ControlFlow was set to Poll.WindowBuilder::with_maximized being ignored.On X11, fix ResumeTimeReached being fired too early.
ResumeTimeReached being fired too early.ControlFlow::Poll with requestAnimationFrameEventLoopProxy leaking memory for every instance.On Windows, fix minor timing issue in wait_until_time_or_msg
set_simple_screen to remember frame excluding title bar.close_button_icon_color not applying.ThemeChanged on change.Event::to_static returning None for user events.ModifiersChanged variant from DeviceEvent to WindowEvent.IconExtWindows trait which exposes creating an Icon from an external file or embedded resourceBadIcon::OsError variant for when OS icon functionality failsi32 instead of u32 for position type in WindowEvent::Moved.On Windows, fixed "error: linking with link.exe failed: exit code: 1120" error on older versions of windows.
link.exe failed: exit code: 1120" error on older versions of windows.hide_application to EventLoopWindowTarget via a new EventLoopWindowTargetExtMacOS trait. hide_application will hide the entire application by calling -[NSApplication hide: nil].CursorMoved event reporting the cursor position using logical coordinates.run_return does not return unless it receives a message.RedrawRequested would only get emitted every other iteration of the event loop.WindowBuilder now implements Default.WindowEvent::CursorMoved changed to f64 units, preserving high-precision data supplied by most backendsWaylandTheme struct has been replaced with a Theme trait, allowing for extra configurationOn X11, deprecate WINIT_HIDPI_FACTOR environment variable in favor of WINIT_X11_SCALE_FACTOR.
PhysicalSize instead of LogicalSize.Size or Position types can now take either Logical or Physical types.hidpi_factor has been renamed to scale_factor.HiDpiFactorChanged has been renamed to ScaleFactorChanged, and lets you control how the OS
resizes the window in response to the change.WINIT_HIDPI_FACTOR environment variable in favor of WINIT_X11_SCALE_FACTOR.Size and Position types are now generic over their exact pixel type.Deprecate modifiers fields in other events in favor of ModifiersChanged.
set_cursor_visible hides cursor outside of window.CursorEntered and CursorLeft events fired at old window size.set_fullscreen is called during fullscreen transition.Window::set_minimized.CursorEntered event being generated for non-winit windows.run_return.WindowEvent::ThemeChanged variant to handle changes to the system theme. Currently only implemented on Windows.RedrawRequested event (#1041):
RedrawRequested has been moved from WindowEvent to Event.EventsCleared has been renamed to MainEventsCleared.RedrawRequested is now issued only after MainEventsCleared.RedrawEventsCleared is issued after each set of RedrawRequested events.ModifiersState to a bitflags struct.VirtualKeyCode translation for LWin and RWin.DeviceEvents to stop getting emitted.Window::set_visible not setting internal flags correctly. This resulted in some weird behavior.DeviceEvent::ModifiersChanged.
modifiers fields in other events in favor of ModifiersChanged.WINIT_HIDPI_FACTOR now dominates Xft.dpi when picking DPI factor for output.randr for WINIT_HIDPI_FACTOR to make winit use self computed DPI factor instead of the one from Xft.dpi.One column per quarter.