Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows to quit on WM_QUIT message for Windows #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

koutoftimer
Copy link

Pull requests consist of the following changes:

  • constant's type changed from u32 to i32 to stay consistant with winapi constant's type
  • listen method modified to interupt infinite loop when WM_QUIT message received
  • added post_quit_message helper function that simply calls PostQuitMessage that sends WM_QUIT
  • added a bit of docs for listen and post_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.

@jamesbirtles
Copy link
Owner

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

@koutoftimer
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants