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

Windows bug: window size continues to increase or shrink across monitors of different magnifications #4712

Closed
hsdk123 opened this issue Sep 2, 2021 · 7 comments
Assignees
Labels
waiting Waiting on user response

Comments

@hsdk123
Copy link
Contributor

hsdk123 commented Sep 2, 2021

Hi, I'm running into a bug where, if I have 2 monitors with different magnification scales, moving a window from one monitor to another, has the application window to continue shrinking or increasing each time I move. (this happens when the app window is sitting across both monitors)

@ericwa
Copy link
Contributor

ericwa commented Sep 2, 2021

I think this is the same issue as #3286

@slouken slouken self-assigned this Nov 7, 2021
@slouken slouken added this to the 2.0.18 milestone Nov 7, 2021
@slouken
Copy link
Collaborator

slouken commented Nov 10, 2021

I think this is the correct behavior. If you have one monitor at 100% scale and another monitor at 200% scale, when you move from the 100% monitor to the 200% monitor, Windows will automatically double the size of your application window. If you want to avoid this behavior you have to tell Windows that your application is DPI aware (which is outside the scope of this issue)

Please reopen this bug if what I'm describing isn't what's happening here.

@slouken slouken closed this as completed Nov 10, 2021
@hsdk123
Copy link
Contributor Author

hsdk123 commented Nov 10, 2021

@slouken Hey, you've misinterpreted the issue - the bug is that the scaling 'continues' to occur - it doesn't stop and the window eventually becomes larger than the screen.

@hsdk123
Copy link
Contributor Author

hsdk123 commented Nov 10, 2021

I'm not sure how I reopen this thread.

@slouken slouken reopened this Nov 10, 2021
@slouken
Copy link
Collaborator

slouken commented Nov 10, 2021

So let me see if I understand the steps:
There's a monitor at 100% scaling and one at 150%, the app launches on the monitor with 100% scaling, when it moves halfway onto to the 150% monitor, it increases in size by 50%, and when you move it back it doesn't shrink?

Do you have a video of this in action, or can we do a video call so I can see what's happening?

@slouken slouken added the waiting Waiting on user response label Nov 10, 2021
@slouken slouken removed this from the 2.0.18 milestone Nov 26, 2021
@hsdk123
Copy link
Contributor Author

hsdk123 commented Dec 28, 2021

@slouken
https://photos.app.goo.gl/mztj8VupzvPyZJYH9

The monitor on the left is at 100% scaling, the monitor on the right is at 150%.
As you can see from the video, each time I try pull it towards the left monitor, the window size keeps increasing.

@ericwa
Copy link
Contributor

ericwa commented Jan 23, 2022

@hsdk123 is your application enabling DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2? I can reproduce this in SDL by enabling that DPI awareness level.

Assuming your app is doing that: what's going on is DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 is promising Windows that we've made certain code changes in SDL which we actually haven't made yet, so we get this bad behaviour as a result. The specific call that is causing the infinite growth is the AdjustWindowRectEx call in SDL_windowsevents.c's WM_GETMINMAXINFO handler need to be replaced with AdjustWindowRectExForDpi. So, applications must not enable per-monitor-v2 until we update SDL to support it.


Further details on how to repro this:

Display setup:

  • 3840x2160 pixels, (main display), 150% scaling
  • 2560x1440 pixels, to the right, 100% scaling

Steps:

  • apply enable-v2-awareness.patch.txt to cause SDL to declare DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 awareness at startup
  • launch SDL's testwm2 test program
  • drag from the main display (150% scaled) to the monitor on the right - once it switches monitors, it should start growing for each pixel you drag the window

ericwa added a commit to ericwa/SDL that referenced this issue Mar 10, 2022
The hint allows setting a specific DPI awareness ("unaware", "system", "permonitor", "permonitorv2").

This is the first part of High-DPI support on Windows ( libsdl-org#2119 ).
It doesn't implement a virtualized SDL coordinate system, which will be
addressed in a later commit. (This hint could be useful for SDL apps
that want 1 SDL unit = 1 pixel, though.)

Detecting and behaving correctly under per-monitor V2
(calling AdjustWindowRectExForDpi where needed) should fix the
following issues:

libsdl-org#3286
libsdl-org#4712
slouken pushed a commit that referenced this issue Jun 11, 2022
The hint allows setting a specific DPI awareness ("unaware", "system", "permonitor", "permonitorv2").

This is the first part of High-DPI support on Windows ( #2119 ).
It doesn't implement a virtualized SDL coordinate system, which will be
addressed in a later commit. (This hint could be useful for SDL apps
that want 1 SDL unit = 1 pixel, though.)

Detecting and behaving correctly under per-monitor V2
(calling AdjustWindowRectExForDpi where needed) should fix the
following issues:

#3286
#4712
@slouken slouken closed this as completed May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting on user response
Projects
None yet
Development

No branches or pull requests

3 participants