1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 00:03:45 +00:00

Fixed DPI scaling of privacy bar on windows

This commit is contained in:
Bryan Roe
2022-02-09 22:47:42 -08:00
parent f13f01eef1
commit 7f7edbf0b0
3 changed files with 34 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@@ -88,6 +88,18 @@ function monitorinfo()
this._user32.CreateMethod('EnumDisplayMonitors'); this._user32.CreateMethod('EnumDisplayMonitors');
this._kernel32 = this._gm.CreateNativeProxy('kernel32.dll'); this._kernel32 = this._gm.CreateNativeProxy('kernel32.dll');
this._kernel32.CreateMethod('GetLastError'); this._kernel32.CreateMethod('GetLastError');
this._shcore = this._gm.CreateNativeProxy('SHCore.dll');
if (this._shcore != null)
{
try
{
this._shcore.CreateMethod('GetDpiForMonitor');
}
catch (xx)
{
this._shcore = null;
}
}
this.getInfo = function getInfo() this.getInfo = function getInfo()
{ {
@@ -99,9 +111,21 @@ function monitorinfo()
this._monitorinfo.callback.results = []; this._monitorinfo.callback.results = [];
this._monitorinfo.callback.on('GlobalCallback', function OnMonitorInfo(hmon, hdc, r, user) { this._monitorinfo.callback.on('GlobalCallback', function OnMonitorInfo(hmon, hdc, r, user) {
if (this.ObjectToPtr_Verify(this.info, user)) { if (this.ObjectToPtr_Verify(this.info, user))
{
var dpi = null;
var sh = require('monitor-info')._shcore;
if (sh != null)
{
var xdpi = require('_GenericMarshal').CreateVariable(4);
var ydpi = require('_GenericMarshal').CreateVariable(4);
sh.GetDpiForMonitor(hmon, 0, xdpi, ydpi);
dpi = xdpi.toBuffer().readUInt32LE();
}
var rb = r.Deref(0, 16).toBuffer(); var rb = r.Deref(0, 16).toBuffer();
this.results.push({ left: rb.readInt32LE(0), top: rb.readInt32LE(4), right: rb.readInt32LE(8), bottom: rb.readInt32LE(12) }); this.results.push({ left: rb.readInt32LE(0), top: rb.readInt32LE(4), right: rb.readInt32LE(8), bottom: rb.readInt32LE(12), dpi: dpi });
var r = this.info.self._gm.CreateInteger(); var r = this.info.self._gm.CreateInteger();
r.Val = 1; r.Val = 1;

View File

@@ -221,6 +221,12 @@ function windows_notifybar_local(title)
monHeight = (m[i].bottom - m[i].top); monHeight = (m[i].bottom - m[i].top);
barWidth = Math.floor(monWidth * 0.30); barWidth = Math.floor(monWidth * 0.30);
barHeight = Math.floor(monHeight * 0.035); barHeight = Math.floor(monHeight * 0.035);
if (m[i].dpi != null)
{
barHeight = Math.floor(m[i].dpi / 3);
barWidth = Math.floor(m[i].dpi * 9);
if (barWidth > monWidth) { barWidth = monWidth; }
}
console.info1('Monitor: ' + i + ' = Width[' + (m[i].right - m[i].left) + '] BarHeight[' + barHeight + '] BarWidth[' + barWidth + ']'); console.info1('Monitor: ' + i + ' = Width[' + (m[i].right - m[i].left) + '] BarHeight[' + barHeight + '] BarWidth[' + barWidth + ']');
offset = Math.floor(monWidth * 0.50) - Math.floor(barWidth * 0.50); offset = Math.floor(monWidth * 0.50) - Math.floor(barWidth * 0.50);