Blurry tray icon after DPI scaling ratio change

Here's a fun one that I noticed.

  • Open Directory Opus and observe the system tray icon.
  • Change the DPI scaling ratio about 20 times. I'm referring to the setting in Windows Settings → System → Display "Change the size of text, apps, and other items". (Going from 100% to 125% and back several times is fine.)
  • With each ratio change, the Directory Opus tray icon is getting blurrier and blurrier, until it's just a smudge...

I'm observing this when switching between a local session (1080p/100%) and a remote session (4k/200%) multiple times per day.

It's clearly an issue with Windows scaling up and down the tray icon bitmap as the ratio changes.
There are a handful of other apps that have the same problem with their tray icons ... but most apps do not. Not sure what the differentiating factor is yet, but it seems like there is some easy way to prevent this from happening to your icon.

Happens to pretty much every icon in the tray, not just the Opus one, in my experience.

I have 31 icons in my tray and only 5 of them have this scaling issue.

You'll probably want to restart Opus after a system DPI change in any case. (File > Exit Directory Opus, then re-launch it.) That should also re-add the tray icon at the current DPI.

(But part of the problem seems to be that Windows doesn't ask programs to refresh their tray icons on a DPI change. It scales the version of the icon it already has, sometimes through multiple changes, which looks ridiculous, but is what Windows itself is doing rather than telling the programs to refresh their icons. Maybe some software does this automatically on a DPI change without being asked; I'm not sure. Most third party (not part of Windows) tray icons become blurry in my experience, until a reboot or restart of the apps involved.)

So I guess the distinction that I want to make is changing the DPI scaling value and then returning back to the original one. If I go from 100% to 200%, then yes, most of the icons look yucky because they have been scaled. But if I go from 100% to 200% and then back to 100%, most of the icons look clean (DOpus is an exception here). The problem only gets worse after many switches.

A niggling issue, I know, just wanted to bring it up. I'm looking into a solution on my own to make a script or something to automatically restart affected apps on-demand. So I guess as a side note — Is there a good way to tell DOpus to shut down (cleanly) externally?

Methods to exit Opus via a script can be found here: How to Exit Directory Opus - #2 by Leo