kettle11 / kapp

A pure Rust window and input library for Windows, Mac, and Web. (Work in progress)
Apache License 2.0
56 stars 4 forks source link

Implement cursor functions for web #48

Closed lunabunn closed 3 years ago

lunabunn commented 3 years ago

UNTESTED!

Fixes #5, fixes #6. Might be worth noting that the implementation is not thread-safe.

lunabunn commented 3 years ago

Verified everything working as expected (in Chrome, version 87.0.4280.141). Chrome has a weird bug where if you have the developer console on, the cursor changes only take place when a mouse event is fired, but seems like a minor issue. Implementation still isn't thread-safe. Does wasm support threads now?

lunabunn commented 3 years ago

As a sidenote, Cursor::PointingHand => LoadCursorW(null_mut(), IDC_ARROW), seems like a typo in the Windows implementation for set_cursor. Should be IDC_HAND.

kettle11 commented 3 years ago

Implementation still isn't thread-safe. Does wasm support threads now?

Browser callbacks always call into kapp on the main thread and kapp's Application, EventLoop and Window are !Send.

So even if some other Wasm parts run on other threads (in web workers) the kapp code is thread safe as it's only interacting directly with the main thread.

kettle11 commented 3 years ago

Merged! Thanks for fixing up some of these missing parts. It's really appreciated! 👍