dsh-native-uia 0.4.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -630
- package/cordis.patch.yml +2 -2
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -6
- package/scripts/check-lease.mjs +2 -2
- package/scripts/install.mjs +1 -2
- package/scripts/lib/sources.mjs +0 -4
- package/scripts/load-tools.mjs +1 -1
- package/scripts/measure-parse.mjs +2 -2
- package/scripts/regression-halt-latch.mjs +100 -100
- package/scripts/regression-tools.mjs +69 -24
- package/scripts/verify.mjs +142 -13
- package/src/guard.js +26 -7
- package/src/index.js +11 -49
- package/src/state.js +0 -3
- package/src/themes.js +16 -24
- package/src/tools/defs/act.js +149 -11
- package/src/tools/defs/lifecycle.js +2 -2
- package/src/tools/defs/observe.js +22 -6
- package/src/tools/defs/pointer.js +65 -35
- package/src/tools/format.js +45 -8
- package/src/tools/index.js +3 -6
- package/src/tools/ocr.js +1 -1
- package/src/tools/recipes.js +9 -4
- package/src/worker-client.js +5 -5
- package/worker/indicator-server.ps1 +150 -196
- package/worker/lib/02-uia.ps1 +9 -6
- package/worker/lib/05-value.ps1 +111 -6
- package/worker/lib/06-snapshot.ps1 +79 -12
- package/worker/lib/07-action.ps1 +44 -6
- package/worker/lib/08-command.ps1 +11 -1
- package/worker/lib/10-dispatch.ps1 +0 -2
- package/src/native-uia-remote.js +0 -80
|
@@ -40,8 +40,7 @@
|
|
|
40
40
|
# * never activated (ShowActivated=false, WS_EX_NOACTIVATE), never in the taskbar or alt-tab
|
|
41
41
|
# (ShowInTaskbar=false, WS_EX_TOOLWINDOW), mouse-transparent (WS_EX_TRANSPARENT), and the
|
|
42
42
|
# visuals are IsHitTestVisible=false as a second line of defence. A watchdog asserts the overlay
|
|
43
|
-
# never becomes GetForegroundWindow(); if it ever did that is logged
|
|
44
|
-
# (state().fgThefts) instead of being silently accepted.
|
|
43
|
+
# never becomes GetForegroundWindow(); if it ever did, that is logged instead of silently accepted.
|
|
45
44
|
#
|
|
46
45
|
# Run: powershell.exe -NoProfile -ExecutionPolicy Bypass -File indicator-server.ps1
|
|
47
46
|
$ErrorActionPreference = 'Stop'
|
|
@@ -242,6 +241,68 @@ public static class IndNative {
|
|
|
242
241
|
public static int PhysWidth { get { try { return GetSystemMetrics(0); } catch { return 0; } } }
|
|
243
242
|
public static int PhysHeight { get { try { return GetSystemMetrics(1); } catch { return 0; } } }
|
|
244
243
|
}
|
|
244
|
+
|
|
245
|
+
// Edge light: ONE continuous ring, baked as a distance field.
|
|
246
|
+
//
|
|
247
|
+
// Alpha depends on the distance to the NEAREST screen edge, so it is constant along each edge and the
|
|
248
|
+
// four corners join with neither a seam nor a doubled patch. Four per-edge linear gradients cannot do
|
|
249
|
+
// that: where two of them overlap the alphas add, which is what reads as four strips with bright
|
|
250
|
+
// corners instead of one breathing frame. A radial gradient is the other obvious answer and is also
|
|
251
|
+
// wrong -- it brightens the middle of each edge and dims the corners, i.e. the opposite artefact.
|
|
252
|
+
//
|
|
253
|
+
// Two profiles, chosen from the palette, exactly like the old masks: 0 = light bleeding in from the
|
|
254
|
+
// frame (dense at the edge, dissolving inward); 1 = vignette for a darkening ambient (ramps up just
|
|
255
|
+
// inside the edge, holds, then releases, so the frame reads as intentional rather than as a dim border).
|
|
256
|
+
public static class IndRing {
|
|
257
|
+
public static byte[] Pixels(int w, int h, double e, int r0, int g0, int b0, int r1, int g1, int b1, double amp, int profile) {
|
|
258
|
+
byte[] px = new byte[w * h * 4];
|
|
259
|
+
if (w <= 0 || h <= 0 || e <= 0) return px;
|
|
260
|
+
// Distance to the NEAREST edge: constant along every edge, and at a corner the two nearest edges
|
|
261
|
+
// meet on the diagonal, so the iso-lines turn a mitre there instead of two bands adding up. A
|
|
262
|
+
// rounded-rectangle field was tried and read as a bevelled picture frame -- the physical corner
|
|
263
|
+
// triangle ends up outside the arc and takes full alpha.
|
|
264
|
+
for (int y = 0; y < h; y++) {
|
|
265
|
+
double dy = Math.Min(y, h - 1 - y);
|
|
266
|
+
for (int x = 0; x < w; x++) {
|
|
267
|
+
double dx = Math.Min(x, w - 1 - x);
|
|
268
|
+
// Plain minimum of the two nearest-edge distances. Measured alternatives, so nobody retries
|
|
269
|
+
// them: a rounded-rectangle field put the physical corner outside the arc and painted that
|
|
270
|
+
// triangle at full alpha (a bevelled picture frame); a smooth minimum rounded the iso-lines
|
|
271
|
+
// but carved a visibly dimmer notch out of each corner. The min() leaves one gradient crease
|
|
272
|
+
// on the 45-degree diagonal and is otherwise uniform -- the least artefact of the three.
|
|
273
|
+
double t = (dx < dy ? dx : dy) / e;
|
|
274
|
+
if (t >= 1.0) continue;
|
|
275
|
+
double a;
|
|
276
|
+
if (profile == 1) {
|
|
277
|
+
if (t < 0.18) {
|
|
278
|
+
double u = t / 0.18;
|
|
279
|
+
a = 0.55 + 0.45 * (u * u * (3.0 - 2.0 * u));
|
|
280
|
+
} else if (t < 0.46) {
|
|
281
|
+
a = 1.0;
|
|
282
|
+
} else {
|
|
283
|
+
double u = (t - 0.46) / 0.54;
|
|
284
|
+
a = 1.0 - (u * u * (3.0 - 2.0 * u));
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
double s = 1.0 - t;
|
|
288
|
+
a = s * s * s * (s * (s * 6.0 - 15.0) + 10.0);
|
|
289
|
+
}
|
|
290
|
+
a *= amp;
|
|
291
|
+
if (a <= 0.0) continue;
|
|
292
|
+
if (a > 1.0) a = 1.0;
|
|
293
|
+
double rr = r0 + (r1 - r0) * t;
|
|
294
|
+
double gg = g0 + (g1 - g0) * t;
|
|
295
|
+
double bb = b0 + (b1 - b0) * t;
|
|
296
|
+
int i = (y * w + x) * 4;
|
|
297
|
+
px[i + 0] = (byte)(bb * a);
|
|
298
|
+
px[i + 1] = (byte)(gg * a);
|
|
299
|
+
px[i + 2] = (byte)(rr * a);
|
|
300
|
+
px[i + 3] = (byte)(a * 255.0);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return px;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
245
306
|
'@
|
|
246
307
|
$script:nativeLoaded = $false
|
|
247
308
|
$script:dpiMode = 0
|
|
@@ -470,16 +531,12 @@ function Apply-Palette($A) {
|
|
|
470
531
|
$script:S = [ordered]@{
|
|
471
532
|
startTick = [Diagnostics.Stopwatch]::GetTimestamp()
|
|
472
533
|
app = $null
|
|
473
|
-
dispatcher = $null
|
|
474
534
|
win = $null
|
|
475
535
|
canvas = $null
|
|
476
536
|
ring = @()
|
|
477
537
|
bloom = @()
|
|
478
538
|
outline = $null
|
|
479
539
|
halo = $null
|
|
480
|
-
haloBlooms = @()
|
|
481
|
-
haloX = 0
|
|
482
|
-
haloY = 0
|
|
483
540
|
haloOn = $false
|
|
484
541
|
haloCurs = $null
|
|
485
542
|
haloShape = [IntPtr]::Zero
|
|
@@ -487,6 +544,7 @@ $script:S = [ordered]@{
|
|
|
487
544
|
pill = $null
|
|
488
545
|
pillText = $null
|
|
489
546
|
pillSub = $null
|
|
547
|
+
ringImg = $null
|
|
490
548
|
pillOrb = $null
|
|
491
549
|
pillOrbScale = $null
|
|
492
550
|
pillOrbHalo = $null
|
|
@@ -518,36 +576,23 @@ $script:S = [ordered]@{
|
|
|
518
576
|
textOverride = ''
|
|
519
577
|
subtext = ''
|
|
520
578
|
framesRendered = [Int64]0
|
|
521
|
-
renderCallbacks = [Int64]0
|
|
522
|
-
visualUpdates = [Int64]0
|
|
523
579
|
appliedAlpha = $null
|
|
524
580
|
renderOn = $false
|
|
525
|
-
renderHookOn = $false
|
|
526
|
-
renderDriver = ''
|
|
527
581
|
lastPulseStamp = [Int64]0
|
|
528
582
|
lastPulseMsWall = [Int64]0
|
|
529
583
|
phaseStartTick = [Diagnostics.Stopwatch]::GetTimestamp()
|
|
530
|
-
pulseOffset = 0.0
|
|
531
|
-
pulseAlpha = 0.0
|
|
532
584
|
exStyles = 0
|
|
533
|
-
straddle = $false
|
|
534
585
|
idleHideMs = [int]$CFG.idleMs
|
|
535
586
|
lastCmdTick = [Diagnostics.Stopwatch]::GetTimestamp()
|
|
536
|
-
autoHides = [Int64]0
|
|
537
|
-
showCount = [Int64]0
|
|
538
|
-
hideCount = [Int64]0
|
|
539
587
|
hwndCreateCount = [Int64]0
|
|
540
588
|
hwndChanges = [Int64]0
|
|
541
589
|
hwndSeen = @()
|
|
542
590
|
fitPasses = 0
|
|
543
591
|
fitConverged = $false
|
|
544
592
|
fitDelta = $null
|
|
545
|
-
fitRect = $null
|
|
546
|
-
fgThefts = [Int64]0
|
|
547
593
|
fontProbe = $null
|
|
548
594
|
chosenFont = ''
|
|
549
595
|
dipW = 0.0
|
|
550
|
-
dipH = 0.0
|
|
551
596
|
ringDip = 0.0
|
|
552
597
|
pillX = 0
|
|
553
598
|
pillY = 0
|
|
@@ -803,26 +848,6 @@ function New-Solid($rgb, [double]$a) {
|
|
|
803
848
|
return $b
|
|
804
849
|
}
|
|
805
850
|
|
|
806
|
-
function New-GradH($rgb0, $rgb1, [double]$a, [bool]$flip) {
|
|
807
|
-
# colour ramp across the ring direction, constant alpha
|
|
808
|
-
$b = New-Object System.Windows.Media.LinearGradientBrush
|
|
809
|
-
if ($flip) {
|
|
810
|
-
$b.StartPoint = New-Object System.Windows.Point -ArgumentList 1.0, 0.5
|
|
811
|
-
$b.EndPoint = New-Object System.Windows.Point -ArgumentList 0.0, 0.5
|
|
812
|
-
} else {
|
|
813
|
-
$b.StartPoint = New-Object System.Windows.Point -ArgumentList 0.0, 0.5
|
|
814
|
-
$b.EndPoint = New-Object System.Windows.Point -ArgumentList 1.0, 0.5
|
|
815
|
-
}
|
|
816
|
-
$s0 = New-Object System.Windows.Media.GradientStop
|
|
817
|
-
$s0.Color = (ColA $a $rgb0); $s0.Offset = 0.0
|
|
818
|
-
$s1 = New-Object System.Windows.Media.GradientStop
|
|
819
|
-
$s1.Color = (ColA $a $rgb1); $s1.Offset = 1.0
|
|
820
|
-
[void]$b.GradientStops.Add($s0)
|
|
821
|
-
[void]$b.GradientStops.Add($s1)
|
|
822
|
-
[void]$b.Freeze()
|
|
823
|
-
return $b
|
|
824
|
-
}
|
|
825
|
-
|
|
826
851
|
function Test-DarkAmbient($rgb) {
|
|
827
852
|
# A ramp whose average luminance is below mid-grey is an ambient that DARKENS the screen instead
|
|
828
853
|
# of lighting it. The two need opposite geometry (see New-Vignette), so the distinction has to be
|
|
@@ -832,101 +857,62 @@ function Test-DarkAmbient($rgb) {
|
|
|
832
857
|
return ($l -lt 96.0)
|
|
833
858
|
}
|
|
834
859
|
|
|
835
|
-
function New-
|
|
836
|
-
#
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
#
|
|
842
|
-
#
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
return $
|
|
860
|
+
function New-RingTexture([double]$W, [double]$H, [double]$T, $ph) {
|
|
861
|
+
# One continuous ring, baked as a distance field: alpha depends on the distance to the NEAREST
|
|
862
|
+
# screen edge, so brightness is constant along each edge and the four corners join without a seam
|
|
863
|
+
# or a doubled-up patch. Four per-edge gradients cannot do that -- where two of them overlap the
|
|
864
|
+
# alphas add, which is what the eye reads as four strips with bright corners instead of one frame.
|
|
865
|
+
#
|
|
866
|
+
# Baked at <= 1280 px wide: the field is a smooth gradient, so a 2-3x upscale is invisible, while
|
|
867
|
+
# a device-resolution bake on a 4K panel would cost 8 MB and ~30 ms on every phase change.
|
|
868
|
+
if (-not $script:nativeLoaded) { return $null }
|
|
869
|
+
$sc = [double]$script:S.scale; if ($sc -le 0) { $sc = 1.0 }
|
|
870
|
+
$wd = [double]$W * $sc; $hd = [double]$H * $sc
|
|
871
|
+
if ($wd -le 0 -or $hd -le 0) { return $null }
|
|
872
|
+
$k = 1.0
|
|
873
|
+
if ($wd -gt 1280.0) { $k = 1280.0 / $wd }
|
|
874
|
+
$bw = [int][Math]::Max(2, [Math]::Round($wd * $k))
|
|
875
|
+
$bh = [int][Math]::Max(2, [Math]::Round($hd * $k))
|
|
876
|
+
$e = [Math]::Max(2.0, [double]$T * 4.0 * $sc * $k)
|
|
877
|
+
$profile = 0
|
|
878
|
+
if (Test-DarkAmbient $ph.g0) { $profile = 1 }
|
|
879
|
+
$px = [IndRing]::Pixels($bw, $bh, $e, [int]$ph.g0[0], [int]$ph.g0[1], [int]$ph.g0[2], [int]$ph.g1[0], [int]$ph.g1[1], [int]$ph.g1[2], 0.85, $profile)
|
|
880
|
+
$bmp = [System.Windows.Media.Imaging.BitmapSource]::Create($bw, $bh, 96.0, 96.0, [System.Windows.Media.PixelFormats]::Pbgra32, $null, $px, $bw * 4)
|
|
881
|
+
$bmp.Freeze()
|
|
882
|
+
return $bmp
|
|
858
883
|
}
|
|
859
884
|
|
|
860
|
-
function New-
|
|
861
|
-
#
|
|
862
|
-
#
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
$
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
$
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
@{ o = 0.18; a = $a255 },
|
|
875
|
-
@{ o = 0.46; a = $a255 },
|
|
876
|
-
@{ o = 0.70; a = [int]($a255 * 0.72) },
|
|
877
|
-
@{ o = 0.88; a = [int]($a255 * 0.28) },
|
|
878
|
-
@{ o = 1.00; a = 0 }
|
|
879
|
-
)) {
|
|
880
|
-
$gs = New-Object System.Windows.Media.GradientStop
|
|
881
|
-
$gs.Color = [System.Windows.Media.Color]::FromArgb([byte]$p.a, 255, 255, 255)
|
|
882
|
-
$gs.Offset = [double]$p.o
|
|
883
|
-
[void]$b.GradientStops.Add($gs)
|
|
884
|
-
}
|
|
885
|
-
[void]$b.Freeze()
|
|
886
|
-
return $b
|
|
885
|
+
function New-RingLayer([double]$W, [double]$H, [double]$T, $ph) {
|
|
886
|
+
# Stretch=Fill maps the baked bitmap onto the window surface in DIPs; its own pixels are only
|
|
887
|
+
# ~1280 wide, and HighQuality scaling keeps the upscaled gradient free of visible steps.
|
|
888
|
+
$img = New-Object System.Windows.Controls.Image
|
|
889
|
+
$img.Width = $W
|
|
890
|
+
$img.Height = $H
|
|
891
|
+
$img.Stretch = [System.Windows.Media.Stretch]::Fill
|
|
892
|
+
$img.Source = (New-RingTexture $W $H $T $ph)
|
|
893
|
+
if ($null -eq $img.Source) { return $null }
|
|
894
|
+
[System.Windows.Controls.Canvas]::SetLeft($img, 0.0)
|
|
895
|
+
[System.Windows.Controls.Canvas]::SetTop($img, 0.0)
|
|
896
|
+
$img.IsHitTestVisible = $false
|
|
897
|
+
[System.Windows.Media.RenderOptions]::SetBitmapScalingMode($img, [System.Windows.Media.BitmapScalingMode]::HighQuality)
|
|
898
|
+
return $img
|
|
887
899
|
}
|
|
888
900
|
|
|
889
|
-
function New-Bar([double]$x, [double]$y, [double]$w, [double]$h, $fill, $mask) {
|
|
890
|
-
$r = New-Object System.Windows.Shapes.Rectangle
|
|
891
|
-
$r.Width = [Math]::Max(0.5, $w)
|
|
892
|
-
$r.Height = [Math]::Max(0.5, $h)
|
|
893
|
-
$r.Fill = $fill
|
|
894
|
-
if ($null -ne $mask) { $r.OpacityMask = $mask }
|
|
895
|
-
[System.Windows.Controls.Canvas]::SetLeft($r, $x)
|
|
896
|
-
[System.Windows.Controls.Canvas]::SetTop($r, $y)
|
|
897
|
-
$r.SnapsToDevicePixels = $true
|
|
898
|
-
$r.IsHitTestVisible = $false
|
|
899
|
-
return $r
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
# Ring geometry for a window surface of W x H DIPs, thickness T DIPs.
|
|
903
|
-
# BOTH pairs of bars span their full edge (horizontals full width, verticals full height) and therefore
|
|
904
|
-
# overlap in the four T x T corner squares. That overlap is what makes the frame continuous -- if either
|
|
905
|
-
# pair is inset, the corner is left to the perpendicular bar's fading tail and reads as a dark break.
|
|
906
|
-
# The corner overlap only lifts alpha a little (pale lavender, perpendicular fades), so it glows rather
|
|
907
|
-
# than burns.
|
|
908
901
|
function Build-Ring([double]$W, [double]$H, [double]$T, $ph) {
|
|
902
|
+
# ONE element, one opacity write per pulse tick. The old build composed four E-wide bands that each
|
|
903
|
+
# spanned their full edge, so every corner square carried two gradients (alpha added up there) and
|
|
904
|
+
# the frame read as four strips meeting at bright patches -- the "stacked / layered" report.
|
|
909
905
|
$bars = New-Object System.Collections.Generic.List[object]
|
|
910
906
|
$bloom = New-Object System.Collections.Generic.List[object]
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
# like a slightly dimmer border that merges into the wallpaper (measured: luminance 4..21 against a
|
|
921
|
-
# desktop edge of 75 -- present, and invisible as an effect). A dark ambient gets the vignette
|
|
922
|
-
# profile instead, which puts its darkest band just inside the edge so the eye reads a frame.
|
|
923
|
-
$dark = Test-DarkAmbient $ph.g0
|
|
924
|
-
$E = $T * 4.0
|
|
925
|
-
$mask = if ($dark) { 'New-Vignette' } else { 'New-Fade' }
|
|
926
|
-
[void]$bloom.Add((New-Bar 0 0 $W $E (New-GradH $ph.g0 $ph.g1 0.85 $false) (& $mask 0.5 0.0 0.5 1.0 1.0)))
|
|
927
|
-
[void]$bloom.Add((New-Bar 0 ($H - $E) $W $E (New-GradH $ph.g1 $ph.g0 0.85 $false) (& $mask 0.5 1.0 0.5 0.0 1.0)))
|
|
928
|
-
[void]$bloom.Add((New-Bar 0 0 $E $H (New-GradH $ph.g0 $ph.g1 0.85 $true) (& $mask 0.0 0.5 1.0 0.5 1.0)))
|
|
929
|
-
[void]$bloom.Add((New-Bar ($W - $E) 0 $E $H (New-GradH $ph.g0 $ph.g1 0.85 $false) (& $mask 1.0 0.5 0.0 0.5 1.0)))
|
|
907
|
+
$layer = New-RingLayer $W $H $T $ph
|
|
908
|
+
if ($null -eq $layer) {
|
|
909
|
+
# Without the native helper there is no distance field. An overlay with no edge light is still a
|
|
910
|
+
# working overlay; falling back to four gradients would put the artefact back on screen.
|
|
911
|
+
Log 'ring texture unavailable: edge light skipped'
|
|
912
|
+
} else {
|
|
913
|
+
$script:S.ringImg = $layer
|
|
914
|
+
[void]$bloom.Add($layer)
|
|
915
|
+
}
|
|
930
916
|
return @{ bars = $bars; bloom = $bloom }
|
|
931
917
|
}
|
|
932
918
|
|
|
@@ -1033,7 +1019,6 @@ function Position-Halo {
|
|
|
1033
1019
|
$lt = New-Object System.Windows.Media.TranslateTransform -ArgumentList $lx, $ly
|
|
1034
1020
|
foreach ($it in $script:S.halo.items) { $it.RenderTransform = $lt; $it.Opacity = 1.0 }
|
|
1035
1021
|
$script:S.haloOn = $true
|
|
1036
|
-
$script:S.haloX = $c[0]; $script:S.haloY = $c[1]
|
|
1037
1022
|
} elseif ($script:S.haloOn) {
|
|
1038
1023
|
$script:S.haloOn = $false
|
|
1039
1024
|
foreach ($it in $script:S.halo.items) { $it.Opacity = 0.0 }
|
|
@@ -1241,10 +1226,9 @@ function New-PillOrb($ph, [bool]$inverse) {
|
|
|
1241
1226
|
# host uses in its welcome wordmark; it is scaled into an 18 DIP slot so the silhouette stays
|
|
1242
1227
|
# crisp at any DPI.
|
|
1243
1228
|
#
|
|
1244
|
-
# The
|
|
1245
|
-
#
|
|
1246
|
-
#
|
|
1247
|
-
# as the same object. The whale is drawn straight onto the shell instead, in ink for paper.
|
|
1229
|
+
# The whale is drawn straight onto the shell, in ink on the paper style: no chip behind it. A chip
|
|
1230
|
+
# that only the paper style carried made its mark read as a second surface the black capsule never
|
|
1231
|
+
# had, and the two styles stopped looking like the same object.
|
|
1248
1232
|
$wrap = New-Object System.Windows.Controls.Grid
|
|
1249
1233
|
$wrap.Width = 18; $wrap.Height = 18
|
|
1250
1234
|
$wrap.VerticalAlignment = [System.Windows.VerticalAlignment]::Center
|
|
@@ -1303,9 +1287,9 @@ function New-PillMark {
|
|
|
1303
1287
|
# A 20 DIP rounded square holding the identity mark, for the `mark` style only -- here the chip IS
|
|
1304
1288
|
# the shape, so it has a surface of its own on purpose.
|
|
1305
1289
|
#
|
|
1306
|
-
#
|
|
1307
|
-
#
|
|
1308
|
-
#
|
|
1290
|
+
# This chip is the shape itself, so it is the one style allowed a second surface. `inverse` draws
|
|
1291
|
+
# the bare whale in ink like `orb`; putting it through this function gives the paper capsule a
|
|
1292
|
+
# background its whale should not have.
|
|
1309
1293
|
$chip = New-Object System.Windows.Controls.Border
|
|
1310
1294
|
$chip.Width = 20; $chip.Height = 20
|
|
1311
1295
|
$chip.CornerRadius = New-Object System.Windows.CornerRadius -ArgumentList 6
|
|
@@ -1576,10 +1560,10 @@ function New-PillFloor([bool]$inverse) {
|
|
|
1576
1560
|
function Build-Pill($ph) {
|
|
1577
1561
|
# Four shapes, two things to decide: the shell (black or paper) and the mark.
|
|
1578
1562
|
#
|
|
1579
|
-
# ALL FOUR are the same size: 44 DIP, 22 DIP radius.
|
|
1580
|
-
#
|
|
1581
|
-
#
|
|
1582
|
-
#
|
|
1563
|
+
# ALL FOUR are the same size: 44 DIP, 22 DIP radius. Size is not part of what "paper" means, so
|
|
1564
|
+
# the shell colour and the height are decided separately: grouping `inverse` with `wave` as a
|
|
1565
|
+
# "dense" two-line shape makes the paper capsule 56 DIP tall with a 25 DIP radius, and switching
|
|
1566
|
+
# styles then jumps the pill under the pointer.
|
|
1583
1567
|
#
|
|
1584
1568
|
# The mark is the whale on every style. `orb` and `inverse` draw it bare on the shell; `mark`
|
|
1585
1569
|
# keeps the chip, because that chip IS the shape; `wave` shows bars instead.
|
|
@@ -1589,13 +1573,13 @@ function Build-Pill($ph) {
|
|
|
1589
1573
|
$border = New-Object System.Windows.Controls.Border
|
|
1590
1574
|
$border.CornerRadius = New-Object System.Windows.CornerRadius -ArgumentList 22
|
|
1591
1575
|
$border.MinHeight = 44
|
|
1592
|
-
# FIXED width.
|
|
1593
|
-
#
|
|
1594
|
-
#
|
|
1595
|
-
#
|
|
1596
|
-
#
|
|
1576
|
+
# FIXED width. Sizing to content makes the length a function of the text: the thin-smoke host
|
|
1577
|
+
# (186 DIP) is the widest child and stretches every capsule to 218 DIP with ~80 empty DIP of shell
|
|
1578
|
+
# past the type. A fixed length keeps the silhouette stable -- constant shape, constant position of
|
|
1579
|
+
# everything inside it, no layout shift when the state word changes -- and the smoke sheet fills
|
|
1580
|
+
# whatever this width is instead of dictating it.
|
|
1597
1581
|
# 172 DIP: mark(18) + gap(9) + heading(~34) + gap(10) + longest state word(~78) + padding(26).
|
|
1598
|
-
# 160
|
|
1582
|
+
# 160 squeezes the heading against the state word; do not go below 172.
|
|
1599
1583
|
$border.Width = 172.0
|
|
1600
1584
|
$bgT = $script:S.pillBg; if ($null -eq $bgT) { $bgT = @(11, 13, 16) }
|
|
1601
1585
|
$bgBrush = New-Object System.Windows.Media.LinearGradientBrush
|
|
@@ -1857,11 +1841,11 @@ function Clear-Canvas {
|
|
|
1857
1841
|
# twenty actions must show layoutBuilds = 1, not 20.
|
|
1858
1842
|
$script:S.layoutBuilds += 1
|
|
1859
1843
|
if ($null -ne $script:S.canvas) { $script:S.canvas.Children.Clear() }
|
|
1860
|
-
$script:S.ring = @(); $script:S.bloom = @()
|
|
1844
|
+
$script:S.ring = @(); $script:S.bloom = @(); $script:S.ringImg = $null
|
|
1861
1845
|
$script:S.pill = $null; $script:S.pillText = $null; $script:S.pillSub = $null
|
|
1862
1846
|
$script:S.pillOrb = $null; $script:S.pillOrbScale = $null; $script:S.pillOrbHalo = $null; $script:S.pillOrbHaloScale = $null; $script:S.pillBars = @()
|
|
1863
1847
|
$script:S.pillScale = $null; $script:S.pillBrandRun = $null; $script:S.pillRestRun = $null
|
|
1864
|
-
$script:S.halo = $null; $script:S.
|
|
1848
|
+
$script:S.halo = $null; $script:S.haloOn = $false
|
|
1865
1849
|
$script:S.haloCurs = $null; $script:S.haloShape = [IntPtr]::Zero
|
|
1866
1850
|
}
|
|
1867
1851
|
|
|
@@ -1870,10 +1854,9 @@ function Clear-Canvas {
|
|
|
1870
1854
|
function Update-PhaseLook {
|
|
1871
1855
|
# Recolour the live tree for the current phase, WITHOUT rebuilding it.
|
|
1872
1856
|
#
|
|
1873
|
-
#
|
|
1874
|
-
#
|
|
1875
|
-
#
|
|
1876
|
-
# colours, so this rewrites the brushes that depend on the phase and leaves geometry, layout and
|
|
1857
|
+
# A phase change must not rebuild the tree: clearing the canvas replays the intro animation, so
|
|
1858
|
+
# the capsule turns red and then pops in again -- "the stopped state flashes twice". Phase only
|
|
1859
|
+
# needs new colours, so this rewrites the brushes that depend on it and leaves geometry, layout and
|
|
1877
1860
|
# the running animations alone.
|
|
1878
1861
|
#
|
|
1879
1862
|
# Only the ring/bloom and the pill's own accent depend on the phase; the shell colour, the text
|
|
@@ -1887,25 +1870,12 @@ function Update-PhaseLook {
|
|
|
1887
1870
|
$W = [double]$m.w / $sc
|
|
1888
1871
|
$H = [double]$m.h / $sc
|
|
1889
1872
|
$T = [double]$CFG.ringPx / $sc
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
#
|
|
1893
|
-
$
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
$edges = @(
|
|
1897
|
-
@{ x = 0; y = 0; w = $W; h = $E; g0 = $ph.g0; g1 = $ph.g1; flip = $false; m = @(0.5, 0.0, 0.5, 1.0) },
|
|
1898
|
-
@{ x = 0; y = ($H - $E); w = $W; h = $E; g0 = $ph.g1; g1 = $ph.g0; flip = $false; m = @(0.5, 1.0, 0.5, 0.0) },
|
|
1899
|
-
@{ x = 0; y = 0; w = $E; h = $H; g0 = $ph.g0; g1 = $ph.g1; flip = $true; m = @(0.0, 0.5, 1.0, 0.5) },
|
|
1900
|
-
@{ x = ($W - $E); y = 0; w = $E; h = $H; g0 = $ph.g0; g1 = $ph.g1; flip = $false; m = @(1.0, 0.5, 0.0, 0.5) }
|
|
1901
|
-
)
|
|
1902
|
-
$i = 0
|
|
1903
|
-
foreach ($b in @($script:S.bloom)) {
|
|
1904
|
-
if ($null -eq $b -or $i -ge $edges.Count) { break }
|
|
1905
|
-
$s = $edges[$i]
|
|
1906
|
-
$b.Fill = (New-GradH $s.g0 $s.g1 0.85 ([bool]$s.flip))
|
|
1907
|
-
$b.OpacityMask = (& $mask $s.m[0] $s.m[1] $s.m[2] $s.m[3] 1.0)
|
|
1908
|
-
$i++
|
|
1873
|
+
# The ring is ONE baked texture, so a phase change re-bakes it (~10 ms at <= 1280 px wide) instead of
|
|
1874
|
+
# repainting four brushes. Geometry, position and the running breath are untouched: the pulse keeps
|
|
1875
|
+
# driving this element's Opacity exactly as before.
|
|
1876
|
+
if ($null -ne $script:S.ringImg) {
|
|
1877
|
+
$fresh = New-RingTexture $W $H $T $ph
|
|
1878
|
+
if ($null -ne $fresh) { $script:S.ringImg.Source = $fresh }
|
|
1909
1879
|
}
|
|
1910
1880
|
# The pill's bloom is the phase accent, so it has to follow too -- otherwise a red stopped phase
|
|
1911
1881
|
# sits in a silver halo.
|
|
@@ -1942,10 +1912,10 @@ function Render-Layout {
|
|
|
1942
1912
|
# restart every animation, which read as one hard flash per tool action. Reuse the live tree and
|
|
1943
1913
|
# only refresh text/position; the tail and the edge breath keep their phase.
|
|
1944
1914
|
#
|
|
1945
|
-
# The phase is deliberately NOT part of the key.
|
|
1946
|
-
#
|
|
1947
|
-
#
|
|
1948
|
-
#
|
|
1915
|
+
# The phase is deliberately NOT part of the key. Putting it there rebuilds the whole tree and
|
|
1916
|
+
# replays Start-PillIntro's 340 ms scale-and-fade on the way out: the colour turns red AND the
|
|
1917
|
+
# capsule pops in again, which is the "stopped flashes twice" report. A phase change is a RECOLOUR,
|
|
1918
|
+
# and Update-PhaseLook already does that in place.
|
|
1949
1919
|
# The smoke flag IS part of the key: turning it on or off changes which children the tree has, so
|
|
1950
1920
|
# it is a structural change and has to rebuild. It is a rare, deliberate act (a click on the plugin
|
|
1951
1921
|
# page), not something that happens per action, so it does not reintroduce the per-action flash.
|
|
@@ -1957,7 +1927,6 @@ function Render-Layout {
|
|
|
1957
1927
|
}
|
|
1958
1928
|
$script:S.layoutKey = $layoutKey
|
|
1959
1929
|
$script:S.dipW = $W
|
|
1960
|
-
$script:S.dipH = $H
|
|
1961
1930
|
$script:S.ringDip = $T
|
|
1962
1931
|
$ph = $script:PH[$script:S.phase]
|
|
1963
1932
|
if ($null -eq $ph) { $ph = $script:PH['acting'] }
|
|
@@ -2183,7 +2152,6 @@ function Fit-To-Monitor($m, [int]$maxPasses) {
|
|
|
2183
2152
|
$r = Get-WindowRect
|
|
2184
2153
|
if ($null -eq $r) { return }
|
|
2185
2154
|
$script:S.fitPasses = $pass
|
|
2186
|
-
$script:S.fitRect = $r
|
|
2187
2155
|
$dw = [int]$target.w - [int]$r.w
|
|
2188
2156
|
$dh = [int]$target.h - [int]$r.h
|
|
2189
2157
|
$dx = [int]$target.x - [int]$r.x
|
|
@@ -2241,7 +2209,6 @@ function Hide-Overlay([string]$why) {
|
|
|
2241
2209
|
}
|
|
2242
2210
|
try { $script:S.win.Hide() } catch { Log ('hide threw: ' + $_.Exception.Message) }
|
|
2243
2211
|
$script:S.visible = $false
|
|
2244
|
-
$script:S.hideCount += 1
|
|
2245
2212
|
$script:S.phase = 'hidden'
|
|
2246
2213
|
Stop-RenderLoop
|
|
2247
2214
|
Stop-HaloLoop
|
|
@@ -2249,10 +2216,9 @@ function Hide-Overlay([string]$why) {
|
|
|
2249
2216
|
}
|
|
2250
2217
|
|
|
2251
2218
|
# ---------------------------------------------------------------- render loop / pulse
|
|
2252
|
-
# Only ever called when DSH_INDICATOR_RENDER_HOOK=1
|
|
2253
|
-
#
|
|
2219
|
+
# Only ever called when DSH_INDICATOR_RENDER_HOOK=1: framesRendered counts pulse updates
|
|
2220
|
+
# actually pushed, from the timer or the render event, whichever is driving.
|
|
2254
2221
|
function On-Frame {
|
|
2255
|
-
$script:S.renderCallbacks += 1
|
|
2256
2222
|
Pump-Inbox
|
|
2257
2223
|
Tick-Pulse
|
|
2258
2224
|
}
|
|
@@ -2272,17 +2238,13 @@ function Start-RenderLoop {
|
|
|
2272
2238
|
# Subscribing to WPF's render event is only an OBSERVER, and an expensive one: measured on this
|
|
2273
2239
|
# box it kept a 2560x1600 layered surface compositing at ~55 Hz even while only 4 updates a
|
|
2274
2240
|
# second were pushed (14 pushes -> 189 callbacks in 3.4 s). Off by default, on for diagnostics.
|
|
2275
|
-
$hooked = $false
|
|
2276
2241
|
if ($script:renderLoaded -and [int]$CFG.renderHook -eq 1) {
|
|
2277
2242
|
try {
|
|
2278
2243
|
[IndWpf]::StartRendering([System.Action]{ On-Frame })
|
|
2279
|
-
$hooked = [bool][IndWpf]::RenderingOn
|
|
2280
2244
|
} catch {
|
|
2281
2245
|
Log ('render subscription failed: ' + $_.Exception.Message)
|
|
2282
2246
|
}
|
|
2283
2247
|
}
|
|
2284
|
-
$script:S.renderHookOn = $hooked
|
|
2285
|
-
$script:S.renderDriver = if ($hooked) { 'dispatcher-timer+composition-render-event' } else { 'dispatcher-timer' }
|
|
2286
2248
|
$script:S.renderOn = $true
|
|
2287
2249
|
}
|
|
2288
2250
|
|
|
@@ -2290,13 +2252,12 @@ function Stop-RenderLoop {
|
|
|
2290
2252
|
if ($script:renderLoaded) { try { [IndWpf]::StopRendering() } catch { } }
|
|
2291
2253
|
if ($null -ne $script:pulseTimer) { try { $script:pulseTimer.Stop() } catch { } }
|
|
2292
2254
|
$script:S.renderOn = $false
|
|
2293
|
-
$script:S.renderHookOn = $false
|
|
2294
2255
|
}
|
|
2295
2256
|
|
|
2296
2257
|
$script:pulseTimer = $null
|
|
2297
2258
|
$script:haloTimer = $null
|
|
2298
2259
|
|
|
2299
|
-
# The halo is decoupled from the
|
|
2260
|
+
# The halo is decoupled from the pulse tick: a dedicated ~16 ms loop repositions it with
|
|
2300
2261
|
# GetCursorPos, so it tracks the pointer without the one-beat lag a shared pulse tick would cause.
|
|
2301
2262
|
function Start-HaloLoop {
|
|
2302
2263
|
if ($null -ne $script:haloTimer) { return }
|
|
@@ -2339,8 +2300,6 @@ function Update-Pulse([Int64]$now) {
|
|
|
2339
2300
|
elseif ($alpha -lt $prev - $step) { $alpha = $prev - $step }
|
|
2340
2301
|
}
|
|
2341
2302
|
$script:S.appliedAlpha = $alpha
|
|
2342
|
-
$script:S.pulseOffset = $frac
|
|
2343
|
-
$script:S.pulseAlpha = [Math]::Round($alpha, 4)
|
|
2344
2303
|
foreach ($b in $script:S.ring) { if ($null -ne $b) { $b.Opacity = $alpha } }
|
|
2345
2304
|
$bloomAlpha = $alpha * 0.72
|
|
2346
2305
|
foreach ($b in $script:S.bloom) { if ($null -ne $b) { $b.Opacity = $bloomAlpha } }
|
|
@@ -2351,7 +2310,7 @@ function Update-Pulse([Int64]$now) {
|
|
|
2351
2310
|
}
|
|
2352
2311
|
|
|
2353
2312
|
# One pulse tick, from whatever source raised it. framesRendered counts ticks where a visual update
|
|
2354
|
-
# was actually pushed;
|
|
2313
|
+
# was actually pushed; composition frames are not counted here.
|
|
2355
2314
|
function Tick-Pulse {
|
|
2356
2315
|
if ($script:S.closing -or -not $script:S.visible) { return }
|
|
2357
2316
|
$now = [Diagnostics.Stopwatch]::GetTimestamp()
|
|
@@ -2360,7 +2319,7 @@ function Tick-Pulse {
|
|
|
2360
2319
|
if ($sinceMs -lt [double]$CFG.renderMs) { return }
|
|
2361
2320
|
$script:S.lastPulseStamp = $now
|
|
2362
2321
|
$script:S.framesRendered += 1
|
|
2363
|
-
|
|
2322
|
+
[void](Update-Pulse $now)
|
|
2364
2323
|
Position-Halo
|
|
2365
2324
|
}
|
|
2366
2325
|
|
|
@@ -2494,8 +2453,6 @@ function Cmd-Show($A) {
|
|
|
2494
2453
|
if ($phase -eq 'hidden') { Hide-Overlay 'show asked for phase hidden' }
|
|
2495
2454
|
Start-RenderLoop
|
|
2496
2455
|
Sync-Hwnd | Out-Null
|
|
2497
|
-
$script:S.showCount += 1
|
|
2498
|
-
$script:S.straddle = [bool]$pick.straddle
|
|
2499
2456
|
$fgAfter = (Get-Fg)
|
|
2500
2457
|
return [ordered]@{
|
|
2501
2458
|
visible = [bool]$script:S.visible
|
|
@@ -2861,7 +2818,7 @@ function Close-Server([string]$why) {
|
|
|
2861
2818
|
$aliveAfter = (Test-HwndAlive)
|
|
2862
2819
|
Log ('hwnd ' + [Int64]$script:S.hwnd + ' IsWindow before close = ' + $aliveBefore + ', after close = ' + $aliveAfter)
|
|
2863
2820
|
}
|
|
2864
|
-
try { $script:S.canvas = $null; $script:S.win = $null; $script:S.ring = @(); $script:S.bloom = @() } catch { }
|
|
2821
|
+
try { $script:S.canvas = $null; $script:S.win = $null; $script:S.ring = @(); $script:S.bloom = @(); $script:S.ringImg = $null } catch { }
|
|
2865
2822
|
try { if ($null -ne $script:S.app) { $script:S.app.Shutdown() } } catch { }
|
|
2866
2823
|
try { if ($null -ne $script:dispatcher) { $script:dispatcher.InvokeShutdown() } } catch { }
|
|
2867
2824
|
# A stuck overlay is the worst failure mode on this list, so unwinding the dispatcher is not
|
|
@@ -2878,7 +2835,6 @@ function Close-Server([string]$why) {
|
|
|
2878
2835
|
|
|
2879
2836
|
# ---------------------------------------------------------------- bootstrap
|
|
2880
2837
|
$script:dispatcher = [System.Windows.Threading.Dispatcher]::CurrentDispatcher
|
|
2881
|
-
$script:S.dispatcher = $script:dispatcher
|
|
2882
2838
|
$script:pumpAction = [System.Action]{ Pump-Inbox; [IndWake]::Clear() }
|
|
2883
2839
|
$app = New-Object System.Windows.Application
|
|
2884
2840
|
$app.ShutdownMode = [System.Windows.ShutdownMode]::OnExplicitShutdown
|
|
@@ -2897,7 +2853,6 @@ New-ServerTimer 250 {
|
|
|
2897
2853
|
if ($script:S.visible) {
|
|
2898
2854
|
$idle = (SinceMs $script:S.lastCmdTick)
|
|
2899
2855
|
if ([int]$script:S.idleHideMs -gt 0 -and $idle -gt [double]$script:S.idleHideMs) {
|
|
2900
|
-
$script:S.autoHides += 1
|
|
2901
2856
|
$script:S.stats.autoHides += 1
|
|
2902
2857
|
Log ('idle ' + [Math]::Round($idle, 0) + ' ms > idleHideMs ' + $script:S.idleHideMs + ' -- auto-hiding')
|
|
2903
2858
|
Hide-Overlay 'idle auto-hide'
|
|
@@ -2905,7 +2860,6 @@ New-ServerTimer 250 {
|
|
|
2905
2860
|
if ($script:nativeLoaded -and [Int64]$script:S.hwnd -ne 0) {
|
|
2906
2861
|
try {
|
|
2907
2862
|
if ((Get-Fg) -eq [Int64]$script:S.hwnd) {
|
|
2908
|
-
$script:S.fgThefts += 1
|
|
2909
2863
|
Log 'tripwire: the overlay became GetForegroundWindow() despite NOACTIVATE'
|
|
2910
2864
|
}
|
|
2911
2865
|
} catch { }
|
package/worker/lib/02-uia.ps1
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# 02-uia.ps1 -- UIA plumbing: patterns, rects, process names
|
|
2
|
-
#
|
|
3
|
-
# Part of worker/uia-worker.ps1, dot-sourced by it in the order scripts/lib/sources.mjs declares.
|
|
4
|
-
# It lives in its own file only so a section can be read without scrolling the whole RPC server.
|
|
5
|
-
# Dot-sourcing shares the entry's script scope, so a helper here may use $script:W and may call
|
|
1
|
+
# 02-uia.ps1 -- UIA plumbing: patterns, rects, process names
|
|
2
|
+
#
|
|
3
|
+
# Part of worker/uia-worker.ps1, dot-sourced by it in the order scripts/lib/sources.mjs declares.
|
|
4
|
+
# It lives in its own file only so a section can be read without scrolling the whole RPC server.
|
|
5
|
+
# Dot-sourcing shares the entry's script scope, so a helper here may use $script:W and may call
|
|
6
6
|
# any function from any other part: neighbour order is not a dependency.
|
|
7
7
|
# ---------------------------------------------------------------- uiA plumbing
|
|
8
8
|
$script:ctCache = @{}
|
|
@@ -100,7 +100,7 @@ function PatternsOf($el) {
|
|
|
100
100
|
# (probe-verified: all exist; IsLegacyIAccessiblePatternAvailableProperty does not — there is no
|
|
101
101
|
# managed wrapper type for that pattern, so it can neither be requested nor reported here, and
|
|
102
102
|
# LegacyIAccessible is deliberately absent from a cached pattern list: the capability table
|
|
103
|
-
# computer_act checks
|
|
103
|
+
# computer_act checks never names it and the rendered tree filters patterns
|
|
104
104
|
# through ACTIONABLE, which never showed it either).
|
|
105
105
|
$script:cachedPatProps = @(
|
|
106
106
|
'IsDockPatternAvailableProperty', 'IsExpandCollapsePatternAvailableProperty', 'IsGridItemPatternAvailableProperty',
|
|
@@ -140,6 +140,9 @@ $patternTypes = @{
|
|
|
140
140
|
Transform = [System.Windows.Automation.TransformPattern]
|
|
141
141
|
Text = [System.Windows.Automation.TextPattern]
|
|
142
142
|
GridItem = [System.Windows.Automation.GridItemPattern]
|
|
143
|
+
# ScrollItem only became useful with the scroll_to verb; before that its absence was invisible
|
|
144
|
+
# (nothing asked for it) and adding it would have been a dead table entry.
|
|
145
|
+
ScrollItem = [System.Windows.Automation.ScrollItemPattern]
|
|
143
146
|
}
|
|
144
147
|
|
|
145
148
|
function GetPattern($el, $name) {
|