RustAudio / baseview

low-level window system interface for audio plugin UIs
Apache License 2.0
267 stars 57 forks source link

Add logic for CursorEntered/CursorLeft on Windows #150

Closed Fredemus closed 6 months ago

Fredemus commented 1 year ago

Necessary to fix https://github.com/vizia/vizia/issues/407, which is a bug that locks up the GUI when you press down on a mouse button inside the window and release the button outside the window.

Fredemus commented 12 months ago

I first tried to do it like that, but WM_MOUSEHOVER ends up firing every time the mouse moves inside the window. This way it only happens the first time the mouse enters the window, which lines up with how it works on x11.

edit: also looks like winit does it the same way as I: https://github.com/rust-windowing/winit/blob/ee0db52ac49d64b46c500ef31d7f5f5107ce871a/src/platform_impl/windows/event_loop.rs#L1443

robbert-vdh commented 12 months ago

In that case you'd be able to just only set TME_HOVER when initially creating the window and when handling WM_MOUSELEAVE, and only set TME_LEAVE when handling WM_MOUSEENTER, no? If that works that sounds like a better solution than approximating it by tracking mouse moves.

Fredemus commented 12 months ago

WM_MOUSEENTER

For some reason there is no WM_MOUSEENTER, only WM_MOUSEHOVER

robbert-vdh commented 12 months ago

Sorry yeah I meant WM_MOUSEHOVER.

Fredemus commented 12 months ago

Ah okay. For reasons I don't really understand just sending TrackMouseEvent with TME_HOVER in WM_MOUSELEAVE means the event never fires, no matter if I set either TME_HOVER or TME_LEAVE initially, or both. I also tried to change dwHoverTime in case the system default was weird. It seemingly has to happen in WM_MOUSEMOVE.

I digged up the documentation I based this on.