Skip to content

Commit

Permalink
Fix Resolution Bug
Browse files Browse the repository at this point in the history
- Gets the current resolution scale by getting DisplayTransferCharacteristic from WmiMonitorBasicDisplayParams
  - Divides by 96 to get the scale from the given PPI
  - ~2x Slower than the current (but broken) implementation w/o PowerShell bottleneck
    - 34 ms -> 84 ms
  - ~2.7x Faster than lptstr#131 w/o PowerShell bottleneck
    - 230 ms
  • Loading branch information
Carterpersall committed Sep 20, 2022
1 parent 72c3403 commit fa6c639
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions winfetch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,11 @@ function info_uptime {
# ===== RESOLUTION =====
function info_resolution {
Add-Type -AssemblyName System.Windows.Forms
$displays = foreach ($monitor in [System.Windows.Forms.Screen]::AllScreens) {
"$($monitor.Bounds.Size.Width)x$($monitor.Bounds.Size.Height)"
$monitors = [System.Windows.Forms.Screen]::AllScreens
$scale = (Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams -CimSession $cimSession).DisplayTransferCharacteristic / 96

$displays = for($i = 0;$i -lt $monitors.Length;$i++){
"$($monitors[$i].Bounds.Size.Width * $scale[$i])x$($monitors[$i].Bounds.Size.Height * $scale[$i])"
}

return @{
Expand Down

0 comments on commit fa6c639

Please sign in to comment.