apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.64k stars 849 forks source link

On Windows, fix graphics bugs after external monitor connect/disconnect #7475

Open eirikbakke opened 4 months ago

eirikbakke commented 4 months ago

On Windows 10 and 11, I have observed various graphics bugs that appear after changes in the OS graphics configuration, such as connecting or disconnecting external monitors, or changing the HiDPI scaling levels. In some cases, the NetBeans main window ceased to update its graphics at all, making the IDE completely unusable until restarted, or until "Full Screen" was toggled via keyboard shortcut. In other cases, the NetBeans window might appear off-screen or partially off-screen, or the NetBeans window might have paint errors until it is maximized/restored. These are probably OpenJDK bugs or even bugs in Windows graphics drivers, as I saw similar problems in jEdit (another Java Swing app) and Skype (not a Java app).

I ended up developing the patch in this PR, which detects changes in the graphics environment on Windows and refreshes the main window in a way that resets the window state in these cases. This patch was developed and verified to work through many months of experimentation, and I have now been running it on my working NetBeans IDE for 18 months.