Repository: spyder-ide/spyder

Issue:
`A monitor scale changed was detected` message blocks the window
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

### Issue Report Checklist

* [ ] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [ ] Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* [ ] Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* [ ] Could not reproduce inside ``jupyter qtconsole`` (if console-related)
* [ ] Tried basic troubleshooting (if a bug/error)
    * [ ] Restarted Spyder
    * [ ] Reset preferences with ``spyder --reset``
    * [ ] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [ ] Tried the other applicable steps from the Troubleshooting Guide
* [ ] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below


## Problem Description
Using spyder on a Windows 10 laptop connected to a bigger monitor with an HDMI connection.
When I disconnect it, there is message window that appears with the message:
"A monitor scale changed was detected.
We recommend restarting spyder..."
The issue is that this window appears behind the main spyder window and so cannot be dismissed as it is a blocking window.
To dismiss it, you need to reconnect the monitor.
Second, the window suggests to "Enable auto high DPI Scaling" which I did but the behavior remains the same.


### What steps reproduce the problem?

1.  Open spyder with a laptop connect with HDMI to a monitor
2.  Disconnect the laptop from the monitor
3.  The spyder window is moved to the latpop's screen but it is blocked as there's an erro message window behind the main window that cannot be dismissed

### What is the expected output? What do you see instead?
1- The error message should be in front of the main window
2- if we tick the preferences / General / Interface / Auto high DPI scaling, the error window should not even open


### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

PASTE TRACEBACK HERE

```

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 4.2.2, installed with the Windows installer
* Python version: 3.9.2
* Qt version: 
* PyQt version: 
* Operating System name/version: Windows 10

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
PASTE DEPENDENCIES HERE
```



Discussion:
Hey @Iqigai, thanks for reporting. We'll try to fix this problem in a future release.

@dalthviz, I think this message annoys people a lot and we should give them the possibility to hide it forever. What do you think?
Sure :+1:
Hi,
I upgraded to spyder 5.0.1 and the issue is still there. Was it corrected in an earlier version and then regressed?
Nop, that's why it's still open.
@ccordoba12 @dalthviz adding some method of permanently disabling this message would be very welcome (or better yet, turn it off by default if auto high DPI scaling is enabled), as this message can lock the user out of Spyder if an auxiliary monitor is disconnected.  This just happened to me and I was unable to use Spyder to present an example I'd set up until I reconnected my monitor.  The steps that caused this are (although I can't seem to make the problem occur again, not sure why):
1. Connect a monitor that has a different auto scale than the primary monitor and open Spyder on that monitor.  If you have to move the Spyder window onto the second monitor, do not check the "hide during current session" box.
2. Disconnect the second monitor.  Spyder detects the change in scale and pops up the "A monitor scale change was detected" message.  For me, Spyder tried to place the popup window on the second monitor that was just disconnected where I could not get to it to close it.  With this popup window up, the main Spyder window is inaccessible.  


Hi @jeremymatt thanks for the feedback, indeed I think this popup window restricts more than it helps at the end so having a way to disable it from the start (either by checking the high DPI setting enabled or a specific setting) could be worthy. What do you think @ccordoba12 ? 
hey, just wanted to add something in here... I just stumbled upon this popup and on my side it looks like this:

![image](https://user-images.githubusercontent.com/22773387/167614990-96149e9b-ac9b-4318-9deb-7b3e67f795c6.png)

The desired button is behind the "don't show again" checkmark, the window is not resizeable and you cannot simply close it (e.g. the "X" button is grayed out)...

So for me this popup was basically something like "let's try to click on that hidden button and hope it does what I'd expect it to do"




Thank you for the feedback @raphaelquast ! That makes things even worse 😨 (although not totally sure why the dialog layout would mess up in that way) What Spyder version are you using? Also could you share the resolutions you were using when this happened? Thanks!
@dalthviz I'm using spyder 5.3.0.  Concerning the resolution, unfortunately I can't say at the moment (it was not my screen and it might take some time till I get back there)

Resolving patch:
diff --git a/spyder/plugins/application/container.py b/spyder/plugins/application/container.py
--- a/spyder/plugins/application/container.py
+++ b/spyder/plugins/application/container.py
@@ -549,7 +549,12 @@ def show_dpi_change_message(self, dpi):
                     sys.platform == 'darwin'):
                 return
 
+            if self.get_conf('high_dpi_scaling'):
+                return
+
             if self.dpi_messagebox is not None:
+                self.dpi_messagebox.activateWindow()
+                self.dpi_messagebox.raise_()
                 return
 
             self.dpi_messagebox = MessageCheckBox(icon=QMessageBox.Warning,
@@ -590,3 +595,4 @@ def show_dpi_change_message(self, dpi):
             # Convert coordinates to int to avoid a TypeError in Python 3.10
             # Fixes spyder-ide/spyder#17677
             self.dpi_messagebox.move(int(x), int(y))
+            self.dpi_messagebox.adjustSize()


Test patch: