Retina/non Retina detection & several displays

I want to know if my app/component is on a retina display or not (say to paint things differently for instance).

But the user can have a main retina display, plus an external non-retina display, and move the app between them.
Is there any smart trick, a callback or something that I can use to be told when the display I’m on is changing?

I could use a timer, and regularly check the current one with something like that :

const double scale = Desktop::getInstance().getDisplays().getDisplayContaining (myComponent.getScreenBounds().getCentre()).scale;
const bool isRetina = scale > 1.;

But there must be a better option?

You can add a ComponentListener to your top-level component and execute your code when the component is moved.

yes sure, actually I had done exactly that in another plugin a few weeks ago, just forgot :slight_smile:
But I was hoping for a kind of display change listener mechanism so that I’m told when the display change and avoid checking. but yes, that will do

Yes. We are working on fixing a lot of scaling issues including having JUCE apps respond to when the user changes the scale at runtime (windows/linux). That will definitely need some kind of callback mechanism. For now use the ComponentListener.

1 Like

ah, actually the thing is that I can’t use ComponentListener is the case of plugins, cause componentMovedOrResized is not called when you move the plugin window within the host

Hi fabian, please consider this in the process:

Did you ever find a solution for this that didn’t involve polling? We allocate openGL textures and images based on the scale factor, so it’d be really nice to have a better mechanism to handle these changes.

no, I’m polling. I agree a better mechanism would be great yes

Thanks for the answer! I guess we can poll in the render callback for now…