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

SDL_SetWindowMouseRect — the set area is one pixel too small #5946

Closed
furious-programming opened this issue Jul 22, 2022 · 4 comments
Closed

Comments

@furious-programming
Copy link

furious-programming commented Jul 22, 2022

On the Windows platform, the cursor boundary area is one pixel too small — pixel is missing on the right and bottom of the selected area. To avoid this error, currently I have to increase Rect.W and Rect.H by one pixel first, and then pass it to SDL_SetWindowMouseRect.

This problem does not occur when null is passed as a pointer to a rect. Apparently, the SDL_SetWindowMouseRect function miscalculates the coordinates of the right and bottom sides of the rectangle by subtracting one pixel unnecessarily.

@flibitijibibo
Copy link
Collaborator

@furious-programming
Copy link
Author

Thank you @flibitijibibo.

Note that the functions from the Win32 API take care of the correctness of right and bottom coordinates, not including these values in the handling of rects. So, wherever rect must be passed, right and bottom should be computed as X + W and Y + H respectively, without subtracting anything.

@flibitijibibo
Copy link
Collaborator

Makes sense to me! But, it looks like @slouken wrote this, so will defer to him since I don't know the Windows side very well:

7d21322

@slouken
Copy link
Collaborator

slouken commented Jul 24, 2022

Fixed, thanks!

PJB3005 pushed a commit to PJB3005/SDL that referenced this issue Oct 5, 2022
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

No branches or pull requests

3 participants