We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4287 - SDL_MouseMotionEvent with SDL_WINDOW_ALLOW_HIGHDPI flag
Summary: SDL_MouseMotionEvent with SDL_WINDOW_ALLOW_HIGHDPI flag
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.8
Hardware: x86 All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-01 14:18 UTC by SKOMAND
Modified: 2019-02-12 11:43 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description SKOMAND 2018-10-01 14:18:37 UTC
Hi!

Similar problem with mouse coordinates on high DPI was described in detail already:
https://forums.libsdl.org/viewtopic.php?p=43373

SDL_MouseMotionEvent is generated when logical coordinates are changed only, i.e. it's impossible to process an event of moving the mouse less than one logical pixel aside, which may correspond to several physical pixel on device screen. 

E.g. on 4k display with screen scaling to 1920x1080 no event is generated if you move the mouse less than 2 physical pixels aside. 

The solution may be in adding float rawX, rawY coordinates to SDL_MouseMotionEvent (or changing the type of X, Y coordinates from Sint32 to float) and generating this event when physical coordinates are changed.

Thus, moving the mouse one physical pixel aside will generate SDL_MouseMotionEvent with corresponding coordinate value = 0.5f for example mentioned above.

Thanks!
Comment 1 ®om 2019-02-12 11:43:31 UTC
I have a possibly related issue.

On MacOS, on secondary screen with hidpi enabled, click events location are not consistent with the logical size of the renderer, leading to incorrect click location: https://github.com/Genymobile/scrcpy/issues/15

Someone proposed a workaround in my app: https://github.com/Genymobile/scrcpy/pull/245 but I think the root cause is in SDL.

Still happens in SDL 2.0.9.

Is it the same problem?