Window stops showing anything after being dragged to a different monitor.

So basically if I drag the window to a different monitor with a different scaling set in windows, the window stops being there except for the top bar. If the scaling is the same it doesn’t happen, if Window.AllowUserResizing is set to true it also doesn’t happen. Setting the resolution to anything after it happened in code fixes it.
I suspect that windows is trying to readjust the window size and that attempt is seen as the same as a user resize attempt by monogame and breaks something.

Is there a way to fix this or a way to get around it by setting Window.AllowUserResizing to true without actually allowing the user to resize the window???

Have had this problem for a while and just ignored it. Any help is appreciated.
Before:
image
After:
after

2 Likes

Are they using the same GPU?

EDIT

DX or OGL?

Yes both monitors are connected via Displayport to a GTX 1060 6gb.
I’m using OGL, should I see if the problem occurs in DX? I could make different versions for linux and windows if it doesn’t happen in DX.

Alright I kinda got a solution to this. It doesn’t solve the problem but instead just fixes it after happening.
Using Window.ScreenDeviceNameChanged I made it so if the resolution is changed by the user, which shouldn’t even be possible since AllowUserResizing is turned off, the event resets it to the current resolution. It also triggers when trying to switch between fullscreen and window mode however, so I made it so it just does nothing in that case.

If anyone wants to recreate this for some reason:

Create a new project (use openGl, idk if it happens in DirectX)
set Window.AllowUserResizing to false
have two monitors with different scaling in Windows
drag the window from one monitor to the other

This scale in Windows:
Untitled

I tested on my UWPDX project, and have no such issue on a single GPU…

I imagine it may be an issue across GPU’s…

OGL, are you creating cross platform?

The scenario of multiple scaling is not a good test case… [I do use multiple scaling across 6+ displays {tested on 3 for now} but that does not mean all users are using two screens with differing scales…]

There are methods which check for graphics flushing, but unsure if this is what you are experiencing… can’t tell from the above data…

Hopefully this helps…

Confirmed it in a new project, problem only occurs in OGL projects. And I finally found a solution!
This line in the automatically created app.manifest file was causing the problem, deleting it fixes the issue:

  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
      This line right here => <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness>
    </windowsSettings>
  </application>
3 Likes

Umm… ok…

See you again soon 🪄

I have been having issues with monogame windows resizing automatically for OGL projects for a while, but only under certain conditions. Specifically when my laptop is plugged into an external monitor and a window is dragged to the external monitor. This solution has fixed the issue for me as well. Thanks!