Skip to content

migrate from winapi to windows-sys#189

Open
lucascompython wants to merge 1 commit into
Narsil:mainfrom
lucascompython:migrate-from-winapi-to-windows-sys
Open

migrate from winapi to windows-sys#189
lucascompython wants to merge 1 commit into
Narsil:mainfrom
lucascompython:migrate-from-winapi-to-windows-sys

Conversation

@lucascompython

Copy link
Copy Markdown

Just thought it was good measure to leave the winapi crate as it unmaintained and the new default are the official windows-* crates.

From my testing, the same tests pass and behavior is the same.

@lucascompython

Copy link
Copy Markdown
Author

I somehow failed to see that #98 exists...
However, that PR is 3 years old and has some differences, I don't know if I should close this PR or not.

Comment thread src/windows/common.rs
Some(EventType::Wheel {
delta_x: 0,
delta_y: (delta / WHEEL_DELTA) as i64,
delta_y: (delta / WHEEL_DELTA as c_short) as i64,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're casting right above, maybe we can drop both c_short casts.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to keep both variables signed, since get_delta results may be interpreted as a signed as stated in the function
If we were to delete the delta cast we would still need to cast WHEEL_DATA to u16, and it would break the logic, since all the values would now be positive.

Comment thread src/windows/listen.rs
unsafe extern "system" fn raw_callback(code: c_int, param: WPARAM, lpdata: LPARAM) -> LRESULT {
unsafe {
if code == HC_ACTION {
if code == HC_ACTION as c_int {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If c_int is not the native type, maybe we should switch.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand what we should switch.
HC_ACTION in winapi was of type c_int but in windows-sys is u32.
The code variable seems to come as a parameter from a callback that is given to SetWindowsHookExA so I think it's probably better to leave it as a c_int.

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