Merge branch 'fix-linux-systeminfo' of https://github.com/nothingTVatYT/FlaxEngine into nothingTVatYT-fix-linux-systeminfo
This commit is contained in:
@@ -2700,6 +2700,8 @@ Float2 LinuxPlatform::GetDesktopSize()
|
||||
if (screenIdx >= count)
|
||||
return Float2::Zero;
|
||||
|
||||
// this function is used as a fallback to place a window at the center of
|
||||
// a screen so we report only one screen instead of the real desktop
|
||||
Float2 size((float)xsi[screenIdx].width, (float)xsi[screenIdx].height);
|
||||
X11::XFree(xsi);
|
||||
return size;
|
||||
@@ -2739,8 +2741,40 @@ Rectangle LinuxPlatform::GetMonitorBounds(const Float2& screenPos)
|
||||
|
||||
Rectangle LinuxPlatform::GetVirtualDesktopBounds()
|
||||
{
|
||||
// TODO: do it in a proper way
|
||||
return Rectangle(Float2::Zero, GetDesktopSize());
|
||||
if (!xDisplay)
|
||||
return Rectangle::Empty;
|
||||
|
||||
int event, err;
|
||||
const bool ok = X11::XineramaQueryExtension(xDisplay, &event, &err);
|
||||
if (!ok)
|
||||
return Rectangle::Empty;
|
||||
|
||||
int count;
|
||||
X11::XineramaScreenInfo* xsi = X11::XineramaQueryScreens(xDisplay, &count);
|
||||
if (count <= 0)
|
||||
return Rectangle::Empty;
|
||||
// get all screen dimensions and assume the monitors form a rectangle
|
||||
// as you can arrange monitors to your liking this is not necessarily the case
|
||||
int minX = INT32_MAX, minY = INT32_MAX;
|
||||
int maxX = 0, maxY = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int maxScreenX = xsi[i].x_org + xsi[i].width;
|
||||
int maxScreenY = xsi[i].y_org + xsi[i].height;
|
||||
if (maxScreenX > maxX)
|
||||
maxX = maxScreenX;
|
||||
if (maxScreenY > maxY)
|
||||
maxY = maxScreenY;
|
||||
if (minX > xsi[i].x_org)
|
||||
minX = xsi[i].x_org;
|
||||
if (minY > xsi[i].y_org)
|
||||
minY = xsi[i].y_org;
|
||||
}
|
||||
|
||||
Float2 org(static_cast<float>(minX), static_cast<float>(minY));
|
||||
Float2 size(static_cast<float>(maxX - minX), static_cast<float>(maxY - minY));
|
||||
X11::XFree(xsi);
|
||||
return Rectangle(org, size);
|
||||
}
|
||||
|
||||
String LinuxPlatform::GetMainDirectory()
|
||||
|
||||
Reference in New Issue
Block a user