graphics() improved detection screen resolution (macOS)

This commit is contained in:
Sebastian Hildebrandt
2021-06-15 08:31:47 +02:00
parent fdf55c6c37
commit 8035902cb2
4 changed files with 23 additions and 7 deletions
+14 -4
View File
@@ -172,10 +172,20 @@ function graphics(callback) {
if (4 === level) { // display controller details level
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('resolution') !== -1) {
let resolution = parts[1].split('x');
currentDisplay.resolutionX = (resolution.length > 1 ? parseInt(resolution[0]) : 0);
currentDisplay.resolutionY = (resolution.length > 1 ? parseInt(resolution[1]) : 0);
currentDisplay.currentResX = currentDisplay.resolutionX;
currentDisplay.currentResY = currentDisplay.resolutionY;
if (resolution.length > 1) {
let xpart = resolution[0];
if (xpart.indexOf('(') !== -1) {
xpart = xpart.split('(').slice(-1)[0];
}
let ypart = resolution[1];
if (ypart.indexOf(')') !== -1) {
ypart = ypart.split(')')[0];
}
currentDisplay.resolutionX = parseInt(xpart) || 0;
currentDisplay.resolutionY = parseInt(ypart) || 0;
currentDisplay.currentResX = currentDisplay.resolutionX;
currentDisplay.currentResY = currentDisplay.resolutionY;
}
}
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('pixeldepth') !== -1) { currentDisplay.pixelDepth = parseInt(parts[1]); } // in BIT
if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('framebufferdepth') !== -1) { currentDisplay.pixelDepth = parseInt(parts[1]); } // in BIT