graphics() improving display detection (windows)

This commit is contained in:
Sebastian Hildebrandt 2019-10-18 17:02:28 +02:00
parent 7cbb8ac52f
commit 8acd0ece14

View File

@ -561,6 +561,7 @@ function graphics(callback) {
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams | fl'));
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens'));
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
workload.push(util.powerShell('gwmi WmiMonitorID -Namespace root\\wmi | ForEach-Object {(($_.ManufacturerName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.ProductCodeID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + $_.InstanceName}'));
Promise.all(
workload
@ -587,19 +588,34 @@ function graphics(callback) {
let tsections = data[4].split(/\n\s*\n/);
tsections.shift();
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections);
// monitor ID (powershell) - model / vendor
const res = data[5].split(/\r/);
let isections = [];
res.forEach(element => {
const parts = element.split('|');
if (parts.length === 5) {
isections.push({
vendor: parts[0],
code: parts[1],
model: parts[2],
serial: parts[3],
instanceId: parts[4]
});
}
});
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections);
if (result.controllers.length === 1 && result.displays.length === 1) {
if (_resolutionx) {
result.displays[0].currentResX = _resolutionx;
if (!result.displays[0].resolutionx) {
result.displays[0].resolutionx = _resolutionx;
result.displays[0].resolutionx = _resolutionx;
if (!result.displays[0].currentResX) {
result.displays[0].currentResX = _resolutionx;
}
}
if (_resolutiony) {
result.displays[0].currentResY = _resolutiony;
if (result.displays[0].resolutiony === 0) {
result.displays[0].resolutiony = _resolutiony;
result.displays[0].resolutiony = _resolutiony;
if (result.displays[0].currentResY === 0) {
result.displays[0].currentResY = _resolutiony;
}
}
if (_pixeldepth) {
@ -677,7 +693,7 @@ function graphics(callback) {
// return displays;
// }
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections) {
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections) {
let displays = [];
let vendor = '';
let model = '';
@ -706,9 +722,17 @@ function graphics(callback) {
const sizey = util.getValue(linesMonitor, 'MaxVerticalImageSize');
const instanceName = util.getValue(linesMonitor, 'InstanceName').toLowerCase();
const videoOutputTechnology = util.getValue(linesConnection, 'VideoOutputTechnology');
let displayVendor = '';
let displayModel = '';
isections.forEach(element => {
if (element.instanceId.toLowerCase() === instanceName) {
displayVendor = element.vendor;
displayModel = element.model;
}
});
displays.push({
vendor: instanceName.startsWith(deviceID) ? vendor : '',
model: instanceName.startsWith(deviceID) ? model : '',
vendor: instanceName.startsWith(deviceID) && displayVendor === '' ? vendor : displayVendor,
model: instanceName.startsWith(deviceID) && displayModel === '' ? model : displayModel,
main: primary.toLowerCase() === 'true',
builtin: videoOutputTechnology === '2147483648',
connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '',