{"id":15102840,"url":"https://github.com/tauri-apps/winit","last_synced_at":"2025-09-27T00:31:52.854Z","repository":{"id":52269407,"uuid":"351398357","full_name":"tauri-apps/winit","owner":"tauri-apps","description":"Window handling library in pure Rust","archived":true,"fork":true,"pushed_at":"2021-05-02T13:33:35.000Z","size":5371,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T06:45:14.727Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"rust-windowing/winit","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tauri-apps.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-25T10:40:33.000Z","updated_at":"2023-07-25T14:44:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tauri-apps/winit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Fwinit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Fwinit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Fwinit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tauri-apps%2Fwinit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tauri-apps","download_url":"https://codeload.github.com/tauri-apps/winit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219871598,"owners_count":16554432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-25T19:08:07.366Z","updated_at":"2025-09-27T00:31:47.474Z","avatar_url":"https://github.com/tauri-apps.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# winit - Cross-platform window creation and management in Rust\n\n[![Crates.io](https://img.shields.io/crates/v/winit.svg)](https://crates.io/crates/winit)\n[![Docs.rs](https://docs.rs/winit/badge.svg)](https://docs.rs/winit)\n[![CI Status](https://github.com/rust-windowing/winit/workflows/CI/badge.svg)](https://github.com/rust-windowing/winit/actions)\n\n```toml\n[dependencies]\nwinit = \"0.24.0\"\n```\n\n## [Documentation](https://docs.rs/winit)\n\nFor features _within_ the scope of winit, see [FEATURES.md](FEATURES.md).\n\nFor features _outside_ the scope of winit, see [Missing features provided by other crates](https://github.com/rust-windowing/winit/wiki/Missing-features-provided-by-other-crates) in the wiki.\n\n## Contact Us\n\nJoin us in any of these:\n\n[![Freenode](https://img.shields.io/badge/freenode.net-%23glutin-red.svg)](http://webchat.freenode.net?channels=%23glutin\u0026uio=MTY9dHJ1ZSYyPXRydWUmND10cnVlJjExPTE4NSYxMj10cnVlJjE1PXRydWU7a)\n[![Matrix](https://img.shields.io/badge/Matrix-%23Glutin%3Amatrix.org-blueviolet.svg)](https://matrix.to/#/#Glutin:matrix.org)\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tomaka/glutin?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n## Usage\n\nWinit is a window creation and management library. It can create windows and lets you handle\nevents (for example: the window being resized, a key being pressed, a mouse movement, etc.)\nproduced by window.\n\nWinit is designed to be a low-level brick in a hierarchy of libraries. Consequently, in order to\nshow something on the window you need to use the platform-specific getters provided by winit, or\nanother library.\n\n```rust\nuse winit::{\n    event::{Event, WindowEvent},\n    event_loop::{ControlFlow, EventLoop},\n    window::WindowBuilder,\n};\n\nfn main() {\n    let event_loop = EventLoop::new();\n    let window = WindowBuilder::new().build(\u0026event_loop).unwrap();\n\n    event_loop.run(move |event, _, control_flow| {\n        *control_flow = ControlFlow::Wait;\n\n        match event {\n            Event::WindowEvent {\n                event: WindowEvent::CloseRequested,\n                window_id,\n            } if window_id == window.id() =\u003e *control_flow = ControlFlow::Exit,\n            _ =\u003e (),\n        }\n    });\n}\n```\n\nWinit is only officially supported on the latest stable version of the Rust compiler.\n\n### Cargo Features\n\nWinit provides the following features, which can be enabled in your `Cargo.toml` file:\n* `serde`: Enables serialization/deserialization of certain types with [Serde](https://crates.io/crates/serde).\n* `x11` (enabled by default): On Unix platform, compiles with the X11 backend\n* `wayland` (enabled by default): On Unix platform, compiles with the Wayland backend\n\n### Platform-specific usage\n\n#### WebAssembly\n\nWinit supports compiling to the `wasm32-unknown-unknown` target with either a\n`stdweb` or a `web-sys` backend for use on web browsers. However, please note\nthat **the `stdweb` backend is being deprecated and may be removed in a future\nrelease of Winit**. The `web-sys` backend is also more feature complete.\n\nOn the web platform, a Winit window is backed by a `\u003ccanvas\u003e` element. You can\neither [provide Winit with a `\u003ccanvas\u003e` element][web with_canvas], or [let Winit\ncreate a `\u003ccanvas\u003e` element which you can then retrieve][web canvas getter] and\ninsert it into the DOM yourself.\n\nFor example code using Winit with WebAssembly, check out the [web example]. For\ninformation on using Rust on WebAssembly, check out the [Rust and WebAssembly\nbook].\n\n[web with_canvas]: https://docs.rs/winit/latest/wasm32-unknown-unknown/winit/platform/web/trait.WindowBuilderExtWebSys.html#tymethod.with_canvas\n[web canvas getter]: https://docs.rs/winit/latest/wasm32-unknown-unknown/winit/platform/web/trait.WindowExtWebSys.html#tymethod.canvas\n[web example]: ./examples/web.rs\n[Rust and WebAssembly book]: https://rustwasm.github.io/book/\n\n#### Android\n\nThis library makes use of the [ndk-rs](https://github.com/rust-windowing/android-ndk-rs) crates, refer to that repo for more documentation.\n\nRunning on an Android device needs a dynamic system library, add this to Cargo.toml:\n```toml\n[[example]]\nname = \"request_redraw_threaded\"\ncrate-type = [\"cdylib\"]\n```\n\nAnd add this to the example file to add the native activity glue:\n```rust\n#[cfg_attr(target_os = \"android\", ndk_glue::main(backtrace = \"on\"))]\nfn main() {\n    ...\n}\n```\n\nAnd run the application with `cargo apk run --example request_redraw_threaded`\n\n#### MacOS\n\nTo ensure compatibility with older MacOS systems, winit links to\nCGDisplayCreateUUIDFromDisplayID through the CoreGraphics framework.\nHowever, under certain setups this function is only available to be linked\nthrough the newer ColorSync framework. So, winit provides the\n`WINIT_LINK_COLORSYNC` environment variable which can be set to `1` or `true` \nwhile compiling to enable linking via ColorSync.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftauri-apps%2Fwinit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftauri-apps%2Fwinit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftauri-apps%2Fwinit/lists"}