Retina/non Retina detection & several displays


#1

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?


#2

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


#3

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


#4

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.


#5

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


#6

Hi fabian, please consider this in the process:


#7

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.


#8

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


#9

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