hex/scripts/windows-icon.ps1
Luke Parker 8efd9909bd
feat: Windows beta with streaming dictation, Hold/Toggle shortcut mode, and x64 + ARM64 release (#141)
* feat: Windows beta with streaming dictation, Hold/Toggle shortcut mode, and release pipeline

Ports the windows-shell branch onto main, adds a GPU streaming finish for Parakeet Unified English with a whole-clip fallback, a cross-platform Hold/Toggle shortcut mode, x64 and ARM64 Windows CI and release feeds, and the website Windows download.

* copy: Enabled/Disabled status on Linux and in the shared Activity labels

* ci: install SPIRV-Headers for the x64 Vulkan build and gate the Windows-only device query

* refactor: one implementation per concept across macOS, Linux, and Windows

The Windows port carried its own copies of modules main already has. Each
concept now has one implementation:

- UI: Windows uses main's design system (design_tokens, desktop_ui,
  text_input, desktop_transcription_picker types) instead of a Fluent copy.
  Windows-only bits are small cfg additions: Segoe Fluent Icons for Icon,
  Windows text-editing key bindings, fixed-height and read-only text inputs,
  and the shared slider_track component. windows_ui keeps the window chrome
  and the anchored dropdowns, now drawn with menu/menu_item.
- Windows chrome: the sidebar runs the full window height as on macOS. The
  caption row is split: the brand sits over the sidebar, the window buttons
  over the content, and both halves stay OS drag regions.
- Commands: Windows uses main's commands, command_grammar, context, keys,
  and personal_commands. The SDK provisioner accepts the embedded TypeScript
  src layout; Windows execute() opens URLs and paths with ShellExecuteW.
- OpenCode: dictation_processor is the one client and ordered policy
  (corrections, rewrite, transformations) on macOS and Windows. Windows keeps
  its opencode2 api CLI transport in a cfg'd submodule; the ranked catalog,
  prompts, Voice Action generation, and the transformation stage are shared.
- desktop_activity is shared; the Windows Settings contract is
  windows_desktop_host, without #[path] aliases.
- self_update is the signed-feed core for both the Linux and Windows
  updaters.
- Windows copy follows the design system: sentence case and "Hex".

* chore(windows): flat app icon that stays crisp at taskbar sizes

* chore: mark the Windows-only screens to consolidate with app_window after #138

* fix(linux): wait for partial X11 grabs to be released before reporting a conflict
2026-10-19 11:00:46 +10:00

82 lines
4.1 KiB
PowerShell

# Regenerates resources/windows/hex.ico, the executable, taskbar, and shortcut
# icon: the macOS icon's glyph on a flat dark tile with a thin lighter rim, so
# it reads on both dark and light taskbars. Windows icons are flat; the macOS
# gradient collapses into a hard band at taskbar sizes.
param([string]$Out)
$ErrorActionPreference = "Stop"
Add-Type -AssemblyName System.Drawing
$root = Split-Path -Parent $PSScriptRoot
if (-not $Out) { $Out = Join-Path $root "resources\windows\hex.ico" }
$glyph = [Drawing.Image]::FromFile((Join-Path $root "app\AppIcon.icon\Assets\Image.png"))
$sizes = 256, 64, 48, 40, 32, 24, 20, 16
$frames = foreach ($size in $sizes) {
$bitmap = New-Object Drawing.Bitmap $size, $size
$graphics = [Drawing.Graphics]::FromImage($bitmap)
$graphics.SmoothingMode = "AntiAlias"
$graphics.InterpolationMode = "HighQualityBicubic"
$graphics.PixelOffsetMode = "HighQuality"
$inset = if ($size -le 24) { 0.5 } else { [Math]::Max(1, $size / 32) }
$tile = $size - 2 * $inset
$diameter = 2 * $tile * 0.22
$path = New-Object Drawing.Drawing2D.GraphicsPath
$path.AddArc($inset, $inset, $diameter, $diameter, 180, 90)
$path.AddArc($inset + $tile - $diameter, $inset, $diameter, $diameter, 270, 90)
$path.AddArc($inset + $tile - $diameter, $inset + $tile - $diameter, $diameter, $diameter, 0, 90)
$path.AddArc($inset, $inset + $tile - $diameter, $diameter, $diameter, 90, 90)
$path.CloseFigure()
$fill = New-Object Drawing.SolidBrush ([Drawing.Color]::FromArgb(255, 22, 22, 22))
$graphics.FillPath($fill, $path)
$rim = New-Object Drawing.Pen ([Drawing.Color]::FromArgb(255, 70, 70, 70)), ([Math]::Max(1, $size / 48))
$graphics.DrawPath($rim, $path)
# Small frames give the glyph more of the tile so its rings stay legible.
$share = if ($size -le 24) { 0.68 } elseif ($size -le 40) { 0.62 } else { 0.56 }
$height = $tile * $share * 1.12 * $glyph.Height / [Math]::Max($glyph.Width, $glyph.Height)
$width = $height * $glyph.Width / $glyph.Height
$graphics.DrawImage($glyph, ($size - $width) / 2, ($size - $height) / 2, $width, $height)
$graphics.Dispose()
$stream = New-Object IO.MemoryStream
if ($size -ge 256) {
# Vista and later read the large frame as PNG.
$bitmap.Save($stream, [Drawing.Imaging.ImageFormat]::Png)
} else {
# Small frames stay classic 32-bit DIBs: header, bottom-up BGRA rows,
# then an all-zero AND mask padded to 32-bit rows.
$dib = New-Object IO.BinaryWriter $stream
$dib.Write([UInt32]40); $dib.Write([Int32]$size); $dib.Write([Int32]($size * 2))
$dib.Write([UInt16]1); $dib.Write([UInt16]32); $dib.Write([UInt32]0)
$dib.Write([UInt32]($size * $size * 4)); $dib.Write([Int32]0); $dib.Write([Int32]0)
$dib.Write([UInt32]0); $dib.Write([UInt32]0)
for ($y = $size - 1; $y -ge 0; $y--) {
for ($x = 0; $x -lt $size; $x++) {
$pixel = $bitmap.GetPixel($x, $y)
$dib.Write([byte]$pixel.B); $dib.Write([byte]$pixel.G)
$dib.Write([byte]$pixel.R); $dib.Write([byte]$pixel.A)
}
}
$dib.Write((New-Object byte[] ([Math]::Ceiling($size / 32) * 4 * $size)))
$dib.Flush()
}
$bitmap.Dispose()
, $stream.ToArray()
}
$glyph.Dispose()
# ICO container: header, one directory entry per frame, then the payloads.
$icon = New-Object IO.MemoryStream
$writer = New-Object IO.BinaryWriter $icon
$writer.Write([UInt16]0); $writer.Write([UInt16]1); $writer.Write([UInt16]$sizes.Count)
$offset = 6 + 16 * $sizes.Count
for ($i = 0; $i -lt $sizes.Count; $i++) {
$dimension = if ($sizes[$i] -ge 256) { 0 } else { $sizes[$i] }
$writer.Write([byte]$dimension); $writer.Write([byte]$dimension)
$writer.Write([byte]0); $writer.Write([byte]0)
$writer.Write([UInt16]1); $writer.Write([UInt16]32)
$writer.Write([UInt32]$frames[$i].Length); $writer.Write([UInt32]$offset)
$offset += $frames[$i].Length
}
foreach ($frame in $frames) { $writer.Write($frame) }
$writer.Flush()
[IO.File]::WriteAllBytes($Out, $icon.ToArray())
"wrote $Out ($($icon.Length) bytes)"