What are each desktop window manager's handle's safety requirements?

โš“ Rust    ๐Ÿ“… 2026-05-30    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 3      

surdeus

i'm trying to use software rendering (currently pixels, i may switch to softbuffer) with bevy,
but both require a HasWindowHandle type to create the buffer, which requires unsafe code, but i can't determine what safety requirements i actually have to follow.
for example this function just says

Safety
Some platforms have constraints on where/how this handle can be used. For example, some platforms donโ€™t support doing window operations off of the main thread. The caller must ensure the RawHandleWrapper is only used in valid contexts.

which tells me just about anything and everything involving the handle could be unsafe, which isn't very helpful.

i only care about linux (X11 + Wayland) and windows (no idea what that uses),
i don't care about supporting MacO, iOS, Android, Plan 9, etc (i can just panic if their window manager is used)

so i just need to know what the safety requirements are for these ~3 (i hope modern windows only has 1) window managers actually are,
if i can send their ThreadLockedRawWindowHandleWrapper across threads,
and if i can create the ThreadLockedRawWindowHandleWrapper and buffer on any thread.

3 posts - 2 participants

Read full topic

๐Ÿท๏ธ Rust_feed