hotkey-rs
hotkey-rs copied to clipboard
Allows to quit on `WM_QUIT` message for Windows
Pull requests consist of the following changes:
- constant's type changed from
u32toi32to stay consistant withwinapiconstant's type listenmethod modified to interupt infinite loop whenWM_QUITmessage received- added
post_quit_messagehelper function that simply callsPostQuitMessagethat sendsWM_QUIT - added a bit of docs for
listenandpost_quit_message
From PostQuitMessage docs:
Indicates to the system that a thread has made a request to terminate (quit).
I have verified that posting WM_QUIT by calling PostQuitMessage message from different process have no effect on the listen loop.
Looks good, my only concern is that by making the key codes of type i32, it technically makes the windows and linux versions slightly incompatible I guess. I'm not sure if this is really a concern or not though?
also would this not also need to change to i32? https://github.com/UnwrittenFun/hotkey-rs/blob/1610e8e7726b316fc48a6f132162a42a3af58b15/src/windows.rs#L53
I've got errors about type mismatch by preparing this pull request, that is why I've changed it to i32 and my primary focus was on correct interupting infinite loop, but now I see what happened with that slight change.
I can't see any negative constants, maybe it is "better" to cast i32 to u32.
it technically makes the windows and linux versions slightly incompatible
I'm not a developer of winapi crate and have no idea why do they choose to use i32 for VK_* constants and isize for modifiers. Maybe it is better to ask them whether or not it is safe to cast constants to u32.
I understand that compatibility is an important question, but it is not what I'm concerned with right now. I do not like that "callbacks" are called in the same thread, blocking infinite loop and dispatching events which corresponds to event miss and a ton of additional code for library user.
Recalling your conserns: I do not know right answer.