mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-15 00:24:19 +00:00
Fix for linux desktop scale on hi-res displays.
This commit is contained in:
parent
058f8102f8
commit
dd249faae4
1 changed files with 28 additions and 0 deletions
|
|
@ -3199,6 +3199,34 @@ void MouseInputSource::setRawMousePosition (Point<float> newPosition)
|
|||
|
||||
double Desktop::getDefaultMasterScale()
|
||||
{
|
||||
// Ubuntu and derived distributions now save a per-display scale factor as a configuration
|
||||
// variable. This can be changed in the Monitor system settings panel.
|
||||
ChildProcess dconf;
|
||||
|
||||
if (dconf.start ("dconf read /com/ubuntu/user-interface/scale-factor", ChildProcess::wantStdOut))
|
||||
{
|
||||
if (dconf.waitForProcessToFinish (200))
|
||||
{
|
||||
String jsonOutput = dconf.readAllProcessOutput().replaceCharacter ('\'', '"');
|
||||
|
||||
if (dconf.getExitCode() == 0 && jsonOutput.isNotEmpty())
|
||||
{
|
||||
var jsonVar = JSON::parse (jsonOutput);
|
||||
|
||||
if (DynamicObject* object = jsonVar.getDynamicObject())
|
||||
{
|
||||
NamedValueSet& scaleFactors = object->getProperties();
|
||||
|
||||
double maxScaleFactor = 1.0;
|
||||
for (int i = 0; i < scaleFactors.size(); ++i)
|
||||
maxScaleFactor = jmax (maxScaleFactor, (double) (scaleFactors.getValueAt (i)) / 8.0);
|
||||
|
||||
return maxScaleFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue