winit/src/platform
John Nunley 1682703b5c
bugfix(win32): Only return win handle on OK thread
On Windows, it is generally unsafe to use the HWND outside of the thread
that it originates from. In reality, the HWND is an index into a
thread-local table, so using it outside of the GUI thread can result in
another window being used instead, following by code unsoundness. This
is why the WindowHandle type is !Send. However, Window is Send and Sync,
which means we have to account for this.

Thus far the best solution seems to be to check if we are not in the GUI
thread. If we aren't, refuse the return the window handle.

For users who want to ensure the safety themselves, the unsafe API
was added.

Signed-off-by: John Nunley <dev@notgull.net>
2024-04-26 20:28:10 +04:00
..
android.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
ios.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
macos.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
mod.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
modifier_supplement.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
orbital.rs Move some of our documentation to docs.rs (#3478) 2024-02-23 15:35:18 +01:00
pump_events.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
run_on_demand.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
scancode.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
startup_notify.rs Deprecate window creation with stale event loop 2024-02-21 14:44:29 +04:00
wayland.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
web.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00
windows.rs bugfix(win32): Only return win handle on OK thread 2024-04-26 20:28:10 +04:00
x11.rs chore(rustfmt): use nightly (#2325) 2024-04-26 17:11:44 +02:00