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

**URL:** <https://users.rust-lang.org/t/what-are-each-desktop-window-managers-handles-safety-requirements/140361>\
**Category:** help\
**Created:** [May 30, 2026, 7:56pm UTC](https://users.rust-lang.org/t/what-are-each-desktop-window-managers-handles-safety-requirements/140361 "2026-05-30T19:56:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miro](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@miro](https://users.rust-lang.org/u/miro)\
**Post date:** [May 30, 2026, 7:56pm UTC](https://users.rust-lang.org/t/what-are-each-desktop-window-managers-handles-safety-requirements/140361/1 "2026-05-30T19:56:24Z")

</div>

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](https://docs.rs/bevy_window/latest/bevy_window/struct.RawHandleWrapper.html#method.get_handle) 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`](https://docs.rs/bevy_window/latest/bevy_window/struct.RawHandleWrapper.html) 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.

---

<div class="post-metadata">

**Author:** ![kpreid](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/kpreid/32/22420_2.png) [@kpreid](https://users.rust-lang.org/u/kpreid)\
**Post date:** [May 30, 2026, 8:25pm UTC](https://users.rust-lang.org/t/what-are-each-desktop-window-managers-handles-safety-requirements/140361/2 "2026-05-30T20:25:42Z")

</div>

Generally, you don't need to use any unsafe code. You get the handle from `winit` or another windowing library, and pass it to `pixels`, and don't implement or call the trait yourself. The libraries are responsible for maintaining safety.

---

<div class="post-metadata">

**Author:** ![miro](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@miro](https://users.rust-lang.org/u/miro)\
**Post date:** [May 30, 2026, 8:36pm UTC](https://users.rust-lang.org/t/what-are-each-desktop-window-managers-handles-safety-requirements/140361/3 "2026-05-30T20:36:41Z")

</div>

there doesn't seem to be a correct way to get a owned window in bevy\_winit, there's just [WinitWindows](https://docs.rs/bevy_winit/latest/bevy_winit/struct.WinitWindows.html) which has a method for getting a reference to a WindowWrapper (which won't live long enough),  
and a function for removing a window (which returns a owned wrapper of the removed window), which says it should only be called when a window is closed, so using that sounds like it would break something.

---

<div class="post-metadata">

**Author:** ![kpreid](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/kpreid/32/22420_2.png) [@kpreid](https://users.rust-lang.org/u/kpreid)\
**Post date:** [May 31, 2026, 1:12am UTC](https://users.rust-lang.org/t/what-are-each-desktop-window-managers-handles-safety-requirements/140361/4 "2026-05-31T01:12:18Z")

</div>

I would imagine you likely can’t use `pixels` with `bevy`-managed windows anyway, because `bevy` would be expecting to attach its own renderer to them. You should consult people who know Bevy's `winit`-related workings specifically about how to do this (I know some things but not this), or, if there is not a way to do that, create your own window which you don’t tell Bevy about (which might require ditching `bevy`/`winit` integration entirely and managing the event loop yourself from outside).

All that said, it would probably be easier to just stick to using Bevy’s renderer instead of `pixels` — it won’t be quite as convenient but you can do all the same things.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [August 29, 2026, 1:12am UTC](https://users.rust-lang.org/t/what-are-each-desktop-window-managers-handles-safety-requirements/140361/5 "2026-08-29T01:12:24Z")

</div>

Closed on August 29, 2026, 1:12am UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
