mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
Fix bug when the first display is not the main display on linux
This commit is contained in:
parent
9fa964881f
commit
2fcabaec10
1 changed files with 35 additions and 2 deletions
|
|
@ -1189,7 +1189,7 @@ private:
|
|||
ScopedPointer<XRRScreenResources> screens;
|
||||
|
||||
const int numMonitors = ScreenCount (dpy);
|
||||
RROutput mainDisplay = xrandr.getOutputPrimary (dpy, RootWindow (dpy, 0));
|
||||
RROutput mainDisplay = xrandr.getOutputPrimary (dpy, RootWindow (dpy, 0)) + 1;
|
||||
|
||||
for (int i = 0; i < numMonitors; ++i)
|
||||
{
|
||||
|
|
@ -3722,12 +3722,45 @@ void Desktop::Displays::findDisplays (float masterScale)
|
|||
{
|
||||
DisplayGeometry& geometry = DisplayGeometry::getOrCreateInstance (display, masterScale);
|
||||
|
||||
// add the main display first
|
||||
int mainDisplayIdx;
|
||||
for (mainDisplayIdx = 0; mainDisplayIdx < geometry.infos.size(); ++mainDisplayIdx)
|
||||
{
|
||||
const DisplayGeometry::ExtendedInfo& info = geometry.infos.getReference (mainDisplayIdx);
|
||||
if (info.isMain)
|
||||
break;
|
||||
}
|
||||
|
||||
// no main display found then use the first
|
||||
if (mainDisplayIdx >= geometry.infos.size())
|
||||
mainDisplayIdx = 0;
|
||||
|
||||
// add the main display
|
||||
{
|
||||
const DisplayGeometry::ExtendedInfo& info =
|
||||
geometry.infos.getReference (mainDisplayIdx);
|
||||
Desktop::Displays::Display d;
|
||||
|
||||
d.isMain = true;
|
||||
d.scale = masterScale * info.scale;
|
||||
d.dpi = info.dpi;
|
||||
|
||||
d.totalArea = DisplayGeometry::physicalToScaled (info.totalBounds);
|
||||
d.userArea = (info.usableBounds / d.scale) + info.topLeftScaled;
|
||||
|
||||
displays.add (d);
|
||||
}
|
||||
|
||||
for (int i = 0; i < geometry.infos.size(); ++i)
|
||||
{
|
||||
// don't add the main display a second time
|
||||
if (i == mainDisplayIdx)
|
||||
continue;
|
||||
|
||||
const DisplayGeometry::ExtendedInfo& info = geometry.infos.getReference (i);
|
||||
Desktop::Displays::Display d;
|
||||
|
||||
d.isMain = info.isMain;
|
||||
d.isMain = false;
|
||||
d.scale = masterScale * info.scale;
|
||||
d.dpi = info.dpi;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue