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

prevent incorrect shifting of window when dragging onto monitor with different DPI #4119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

acarl005
Copy link

@acarl005 acarl005 commented Feb 7, 2025

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

This PR fixes this issue: #4041

The code I deleted has a validation to check if the new window bounds which Windows is suggesting to move the monitor to is actually on the monitor which triggered the WM_DPI_CHANGED event. If that validation fails, it tried to move the window such that it will be on the monitor which triggered the WM_DPI_CHANGED event. However, this validation was buggy and was actually causing this bug. It was moving the window off of the intended monitor. It seems this is no longer necessary. For example, Chromium's DPI changed handler does not contain an analogous check.

Before

https://www.loom.com/share/aefc5dc1027a42fc8f462c23621ce9a5

After

https://www.loom.com/share/81351dcb5938463c8bb60a66b2a0641b

@dgerhardt
Copy link

dgerhardt commented Feb 14, 2025

I ran into the same issue during development of a Tauri/TAO app and also came to the conclusion that the custom positioning is not only unnecessary, but breaks on Windows 11. There is a difference in behavior between Windows 10 and 11. On Windows 11 (without the custom positioning), the Window remains at the same relative position to the cursor when moving between monitors. This is not the case on Windows 10 and this is what I think the custom positioning logic attempts to fix.

I've created a similar fix for TAO but kept the logic conditionally for Windows 10 (build < 22000) just to be safe. But I'm not sure if it is worth to keep that much logic just for minimal positioning optimizations, especially now that Windows 10 will soon reach EOL.

Related PR and issues (TAO seems still uses the same logic since it was forked from winit, so I think they are relevant):

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

Successfully merging this pull request may close these issues.

4 participants