Reading global scale factor

Hi, I want to position a document window to half way along my plug-in window for neatness.

Point<int> p = getScreenPosition();

gives me the screen top left of my plug-in.
But I need the current windows scale factor to position it half way along, as it depends on my DPI settings.

auto desktopScale =  Desktop::getInstance().getGlobalScaleFactor();

Is always returning 1.0 even though my desktop is at 1.25.
I’m not using OpenGl so I can’t use:

auto desktopScale = (float)editor.openGLContext.getRenderingScale();

Does anyone know how do I access the scaling factor outside of OpenGL?

1 Like

OK, it looks like I can get the scale factor in a paint function:

void paint(Graphics& g) override
{
auto context = &g.getInternalContext();
pixelScale = context->getPhysicalPixelScaleFactor();
.
.

So I can now scale getWidth() to get the correct screen position.

1 Like