slint/internal/backends/winit
Simon Hausmann 00e5f59d9c
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / files-changed (push) Waiting to run
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, 1.88) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, 1.88) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-14) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.88) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / material-components (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
Skia: Update to latest release of Rust Skia bindings (#9663)
For details, see https://github.com/rust-skia/rust-skia/releases/tag/0.89.0
2025-10-09 09:36:43 +02:00
..
LICENSES Simplify commercial license (#3063) 2024-05-31 14:06:17 +02:00
renderer femtovg: Upgrade to wgpu 27 2025-10-07 14:13:52 +02:00
accesskit.rs Renames after the API review 2025-06-06 12:31:50 +02:00
build.rs Prospective CI fix 2025-09-09 12:50:15 +02:00
Cargo.toml Skia: Update to latest release of Rust Skia bindings (#9663) 2025-10-09 09:36:43 +02:00
clipboard.rs Clean up cfgs for Apple operating systems 2025-05-09 20:54:47 +02:00
drag_resize_window.rs Fix two winit deprecation warnings 2024-06-18 17:48:17 +02:00
event_loop.rs Refactor Apple platform detection for keyboard input handling 2025-09-16 09:02:37 +02:00
frame_throttle.rs winit: Add support for timer based frame throttling (#8828) 2025-07-02 09:37:57 +02:00
lib.rs femtovg: Upgrade to wgpu 27 2025-10-07 14:13:52 +02:00
muda.rs muda: On Windows, force the menu bar to be redrawn after menus are rebuilt (#9435) 2025-09-16 13:51:29 +02:00
README.md Simplify commercial license (#3063) 2024-05-31 14:06:17 +02:00
wasm_input_helper.rs Refactor Apple platform detection for keyboard input handling 2025-09-16 09:02:37 +02:00
winitwindowadapter.rs Fix slide puzzle not resizing with the html canvas 2025-09-09 10:34:17 +02:00
xdg_color_scheme.rs backend-winit: Don't call deprecated xdg settings portal method 2025-01-16 09:57:00 +00:00

NOTE: This library is an internal crate of the Slint project. This crate should not be used directly by applications using Slint. You should use the slint crate instead.

WARNING: This crate does not follow the semver convention for versioning and can only be used with version = "=x.y.z" in Cargo.toml.

The Slint winit Backend

This crate implements the winit backend/platform for Slint. It is enabled by default as a default feature of the slint crate.

Although this crate is primarily internal, it can also be used by applications to leverage the full power of [winit::window::Window] for Slint Window.

To use this functionality, you need to be cautious when importing dependencies since this crate does not adhere to semver and may introduce breaking changes in any patch release. Additionally, the version of this crate must match the version of Slint. To indicate that you specifically want this version, include the = symbol in the version string.

Make sure that the version of winit matches the version used by this crate. Check this crate's dependencies to determine the required version.

[dependencies]
slint = { version = "x.y.z", ... }
i-slint-backend-winit = "=x.y.z"
winit = "0.w"

To ensure that the runtime backend is selected, initialize the backend as the first step in the main function:

fn main() {
    slint::platform::set_platform(Box::new(i_slint_backend_winit::Backend::new().unwrap()));
    // ...
}

Once you have a slint::Window (accessible through the window() function of the generated component), you can utilize the [WinitWindowAccessor::with_winit_window] function to access the [winit::window::Window] object.

# // similar to code generated by the slint! macro
# struct C; impl C { fn window(&self) ->i_slint_core::api::Window {todo!()} }
# let my_ui = C;
use i_slint_backend_winit::WinitWindowAccessor; // import the trait
my_ui.window().with_winit_window(|winit_window: &winit::window::Window| {
    // Here, you can use the winit API
});