-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Touch input offset on secondary monitor #15
Comments
Thank you for reporting this. I am aware of the problem, but for now, I didn't find a way to fix it without breaking the one-screen scenario. For now, you can disable hidpi support:
But the video quality will be bad (pixels will be 2×2). |
This should resolve Genymobile#15
Does SDL 2.0.9 fix the issue on MacOS? There is a commit from Oct 12th: |
@rom1v I have tested latest scrcpy with SDL 2.0.9 on macos 10.14.2, but this problem still exists. |
I can also confirm the issue still exists scrcpy --version dependencies:
|
This issue was bothering me as well, I still think it's a SDL upstream bug but this workaround is simple and safe. If SDL fixes it upstream this workaround won't break, but maybe could be removed eventually. Normally in HiDPI mode, the Renderer resolution is exactly double the window resolution, which is easy to see by comparing the following:
But in the mixed-monitor configuration it gets confused after a window resize and they become the same. This leads to an inconsistency where some part of the SDL code still wants to double the X,Y coordinates of the mouse events. This fix brute-forces things by reinitializing the rendering state after a window resize. I've tested it in a multi-monitor config with every combination of dragging, resizing, fullscreening, and using control-keys to make the app do resizing I can think of, I think it's harmless. Maybe a little inefficient but it only happens in response to resizes. |
PR #848 |
Hi @rom1v I tested the workaround using SDL_RenderSetLogicalSize() on resize events - unfortunately it does not help when I tested it, that call doesn't fix whatever part of the SDL state gets corrupted. I was able to update my existing patch so that the re-creation of the rendering and texture state never occurs when only a single monitor is connected - it does this by testing whether that ratio of window "size" to rendering pixel size has unexpectedly changed and only then resets the state. I believe if the SDL bug only affects the multi-monitor case, then this reset call also would only happen when multiple monitors have been connected. Please let me know your thoughts when you have a chance to look it over. |
Could you please test |
Moving a window between hidpi and non-hidpi monitors is not correctly handled by SDL. Detect when this happens, and recreate the renderer. Fixes <#15>.
Moving a window between hidpi and non-hidpi monitors is not correctly handled by SDL. Detect when this happens, and recreate the renderer. Fixes <#15>. Signed-off-by: Romain Vimont <rom@rom1v.com>
Moving a window between hidpi and non-hidpi monitors is not correctly handled by SDL. Detect when this happens, and recreate the renderer. Fixes <#15> Signed-off-by: Romain Vimont <rom@rom1v.com>
AFAIK to use multiple monitors with different scale is not possible with X11, but possible using Wayland. I will test a few things and comment here later. |
Laptop:
External monitor:
Environment:
|
Hello, I have tried out the mentioned branch and commented everything I knew on #848. It would be awesome if you'd have a look on my comment. Thanks in advance! |
@carstenhag Could you please test the vranch |
OK, (almost) perfect 👍 If you start scrcpy on your primary screen, then moves the window to the secondary screen, does it happen too? (or does it happen only if you start scrcpy directly on the secondary screen?) Are you available on IRC or somewhere to do some tests to fix the problem? (preferably some day in the evening)
Yes, this is different: Ctrl+g resizes the window to the device size, but on some platforms (some window managers) if the window is bigger than the computer screen, the size is clamped (so it does not work as expected).
🎉 |
Yes, let's talk on irc, I have time today or the next days, I don't mind. Just tell me which irc server/channel I should join :). |
But yeah, doesn't matter where my terminal window is or where I last closed scrcpy, it always opens scrcpy on my main screen. |
Cool, thx :)
My nickname is rom1v on freenode. |
Position and scale the content "manually" instead of relying on the renderer "logical size". This avoids possible rounding differences between the computed window size and the content size, causing one row or column of black pixels on the bottom or on the right. This also avoids HiDPI scale issues, by computing the scaling manually. This will also enable to draw items at their expected size on the screen (unscaled). Fixes #15 <#15>
@carstenhag Thank you for your help. So it is fixed now 🎉 Before merging, I would like more tests from users. If you had this problem (or even if you had not), please test #1408. Thank you for your feedback :) |
Position and scale the content "manually" instead of relying on the renderer "logical size". This avoids possible rounding differences between the computed window size and the content size, causing one row or column of black pixels on the bottom or on the right. This also avoids HiDPI scale issues, by computing the scaling manually. This will also enable to draw items at their expected size on the screen (unscaled). Fixes #15 <#15>
Fixed by #1408. |
Touch events were HiDPI-scaled twice: - once because the position (provided as floats between 0 and 1) were converted in pixels using the drawable size (not the window size) - once due to screen_convert_to_frame_coords() One possible fix could be to compute the position in pixels from the window size instead, but this would unnecessarily round the event position to the nearest window coordinates (instead of drawable coordinates). Instead, expose two separate functions to convert to frame coordinates from either window or drawable coordinates. Fixes #1536 <#1536> Refs #15 <#15> Refs e40532a
Touch events were HiDPI-scaled twice: - once because the position (provided as floats between 0 and 1) were converted in pixels using the drawable size (not the window size) - once due to screen_convert_to_frame_coords() One possible fix could be to compute the position in pixels from the window size instead, but this would unnecessarily round the event position to the nearest window coordinates (instead of drawable coordinates). Instead, expose two separate functions to convert to frame coordinates from either window or drawable coordinates. Fixes #1536 <#1536> Refs #15 <#15> Refs e40532a
Hello,
First of all, thank you for this tool.
I know I don't have an usual setup, but here's a bug with it.
This is my setup, I'm on macOS Sierra 10.12.4 and I have two screens:
Now, on the main display, everything works fine with scrcpy, but when the window is on the secondary display, there is an offset for the touch input:
The text was updated successfully, but these errors were encountered: