Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99e189bef2 | ||
|
|
0ad5652ecd | ||
|
|
4cf1e8ea37 | ||
|
|
31a72892de | ||
|
|
12fa25d089 | ||
|
|
181ad64618 | ||
|
|
1017301682 |
No files matched your search
+102
@@ -0,0 +1,102 @@
|
||||
# 更新日志
|
||||
|
||||
本文件只记录 Reims-Go 桌面应用的变化。便携运行时(`runtime-*`)的版本另见 [Releases](https://github.com/Nwflower/Reims-Go/releases)。
|
||||
|
||||
## v0.2.4 — 2026-11-29
|
||||
|
||||
### 新功能
|
||||
|
||||
- 分辨率选项新增「全屏」,原来单独的全屏开关并入其中。
|
||||
- HiDPI 分辨率标出实际显示大小,例如「看起来像 1280 × 800」。
|
||||
- 宿主页显示 Windows 处理器计划(程序优先或后台服务),并可一键以管理员身份打开设置。
|
||||
|
||||
### 优化
|
||||
|
||||
- 分辨率推荐按 macOS 实际进入 HiDPI 的条件判断,只列出放得进屏幕的尺寸;进不了 HiDPI 时会说明怎么办。
|
||||
- 虚拟机自己关机或退出后,界面立即显示已停止,不再最多等 5 秒。
|
||||
- 设置页能正确读出已保存的分辨率、显示器数量、VMware SVGA 显卡后端和不限时的关机等待。
|
||||
- 显示器数量改成多块后可以再改回 1。
|
||||
|
||||
## v0.2.3 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- 命令行并入 `reims-go.exe`:双击打开界面,带子命令即在终端运行,不再单独提供命令行版。
|
||||
- 从命令行启动的虚拟机交给 Reims-Go 界面托管,界面没开时自动在托盘后台运行,同样有剪贴板、共享目录和 Win10 自动冷重启。
|
||||
- 同时只运行一个 Reims-Go,再次双击会唤出已打开的窗口。
|
||||
- 可把 Windows 本地磁盘只读共享给 macOS,每台虚拟机单独开启,默认关闭。
|
||||
|
||||
### 优化
|
||||
|
||||
- 虚拟机页面在后台查询虚拟机状态的次数减少约八成。
|
||||
- 屏幕缩略图生成更快、改为每 15 秒刷新,虚拟机窗口在前台时暂停截图,减少对虚拟机的打扰。
|
||||
- 命令行启动失败时直接显示原因。
|
||||
|
||||
## v0.2.2 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- Guest Tools 2.0:支持图片剪贴板,共享目录可直接挂载到 macOS。
|
||||
- 可向虚拟机发送中文和 emoji,宿主机输入法也能直接输入到虚拟机。
|
||||
- 系统托盘驻留,关闭窗口后最小化到托盘,可从托盘启停虚拟机。
|
||||
- 一键开关 macOS 防休眠。
|
||||
- 详情页实时显示虚拟机的 CPU、内存、磁盘占用和运行时长。
|
||||
- 详情页显示虚拟机屏幕缩略图。
|
||||
- 按显示器分辨率和缩放推荐 HiDPI 分辨率。
|
||||
- 可预设 macOS 系统语言,恢复模式和设置助理不再总是英文。
|
||||
- 虚拟磁盘支持停机扩容和回收未用空间。
|
||||
- 可切换音频后端,并检查宿主机的播放和录音设备。
|
||||
- 设置面板改版为 macOS 系统设置风格,改动可逐项撤销。
|
||||
- 运行时候选通道改名为 alpha,每天自动从上游构建。
|
||||
|
||||
### 优化
|
||||
|
||||
- 截取缩略图改用更快的格式,截图时虚拟机的卡顿大幅减少。
|
||||
- 运行中虚拟机的状态识别更准确,相关提示和保护恢复正常。
|
||||
|
||||
## v0.2.1 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- 离线装机辅助盘自动完成抹盘和安装命令,装机不用手敲长命令。
|
||||
- 一键进入或退出恢复模式,可挂载离线镜像或下载在线恢复镜像。
|
||||
- Guest Tools:宿主机与 macOS 之间双向剪贴板和共享文件夹。
|
||||
- 已关机的虚拟机可秒级派生出独立副本。
|
||||
- 新建虚拟机时可导入 VMDK 或 RAW 磁盘。
|
||||
- 一键导出已脱敏的排障日志包。
|
||||
- 宿主页显示当前版本并检查更新。
|
||||
|
||||
### 优化
|
||||
|
||||
- 新建虚拟机默认使用 NVMe 磁盘,旧虚拟机可一键升级。
|
||||
- 绑核支持三层大小核,虚拟 CPU 多于性能核时自动避开低功耗核。
|
||||
- Win10 冷重启使用的控制通道只在本机可见,虚拟机内无法访问。
|
||||
- 数据目录在外置盘、网络盘或内存负载过高时给出提示。
|
||||
- 临时文件全部放在数据目录里,不再写入 C 盘。
|
||||
|
||||
## v0.2.0 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- 默认用离线安装包装机,装机引导精简为三步。
|
||||
- 新增「安装包」页面,可下载、暂停、续传和删除离线安装包。
|
||||
- 按 Windows 实际可用内存推荐内存大小,新建、修改和启动前都会检查。
|
||||
- 首次启动时先检查 WHPX、显卡和内存,再安装运行时。
|
||||
- 新建助手增加确认页,创建改在后台进行。
|
||||
|
||||
### 优化
|
||||
|
||||
- 宿主页去掉重复信息,运行时合并为一个列表。
|
||||
- 新建时虚拟机重名会提前提示。
|
||||
- 运行时版本列表缓存 10 分钟,避免触发 GitHub 访问次数限制。
|
||||
|
||||
## v0.1.0 — 2026-11-28
|
||||
|
||||
### 新功能
|
||||
|
||||
- 首个版本:单文件桌面应用,在 Windows x64 上运行带 GPU 加速的 macOS 虚拟机,无需自己编译。
|
||||
- 虚拟机列表、启动和关机、分类设置面板与分步新建助手。
|
||||
- 离线安装包下载,支持暂停和续传。
|
||||
- 运行时在线安装,分稳定版和候选版两个通道。
|
||||
- 宿主机体检,虚拟机启动后自动绑定到性能核。
|
||||
- Win10 上虚拟机内部重启时自动冷重启。
|
||||
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -178,6 +179,7 @@ func (a *App) pollVMs(ctx context.Context) {
|
||||
cachedHost := host.Inspect(initRoot)
|
||||
var lastSig string
|
||||
pinnedPIDs := make(map[int]bool)
|
||||
exitWatched := make(map[int]bool)
|
||||
|
||||
for {
|
||||
select {
|
||||
@@ -197,6 +199,7 @@ func (a *App) pollVMs(ctx context.Context) {
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
watchExits(ctx, vms, exitWatched, a.wakePoll)
|
||||
type pinCandidate struct {
|
||||
name string
|
||||
pid int
|
||||
@@ -290,6 +293,39 @@ func (a *App) listVMsInternal(ctx context.Context) ([]reims.VMListItem, error) {
|
||||
return c.List(ctx)
|
||||
}
|
||||
|
||||
// qemuImage is the executable reims-ctl reports as a running VM's PID.
|
||||
const qemuImage = "qemu-system-x86_64.exe"
|
||||
|
||||
// watchExits waits on every running VM's QEMU process not yet watched and
|
||||
// calls onExit the moment one exits, so a VM that stops by itself (macOS shut
|
||||
// down, QEMU quit or crashed) shows as stopped at once instead of at the next
|
||||
// steady poll. watched holds the PIDs being waited on; PIDs no longer running
|
||||
// are dropped so a reused PID is watched again.
|
||||
func watchExits(ctx context.Context, vms []reims.VMListItem, watched map[int]bool, onExit func()) {
|
||||
running := make(map[int]bool, len(vms))
|
||||
for _, vm := range vms {
|
||||
if vm.State != "running" || vm.PID == nil || *vm.PID <= 0 {
|
||||
continue
|
||||
}
|
||||
pid := *vm.PID
|
||||
running[pid] = true
|
||||
if watched[pid] {
|
||||
continue
|
||||
}
|
||||
watched[pid] = true
|
||||
go func() {
|
||||
if err := host.WaitProcessExit(ctx, uint32(pid), qemuImage); err == nil {
|
||||
onExit()
|
||||
}
|
||||
}()
|
||||
}
|
||||
for pid := range watched {
|
||||
if !running[pid] {
|
||||
delete(watched, pid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// polledVMs returns the list pollVMs saw last if it is at most polledMaxAge
|
||||
// old, so per-VM samplers (stats, thumbnails, heartbeats) don't each spawn
|
||||
// their own `reims-ctl list`. A stale or missing poll falls back to one.
|
||||
@@ -583,6 +619,19 @@ func (a *App) EnableWHPX() error {
|
||||
return host.EnableWHPXElevated()
|
||||
}
|
||||
|
||||
// OpenProcessorScheduling opens Windows' Performance Options as administrator
|
||||
// (one UAC prompt) for the processor scheduling choice. Declining the prompt
|
||||
// is not an error.
|
||||
func (a *App) OpenProcessorScheduling() error {
|
||||
a.emitLog("host", "Requesting Windows UAC to open Performance Options (processor scheduling)...")
|
||||
err := host.OpenPerformanceOptionsElevated()
|
||||
if errors.Is(err, host.ErrElevationDeclined) {
|
||||
a.emitLog("host", "UAC prompt declined; Performance Options not opened")
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *App) InstallRuntimeArchive(archivePath string) (*rt.Installed, error) {
|
||||
a.mu.Lock()
|
||||
cfg := a.cfg
|
||||
|
||||
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -29,6 +30,40 @@ func TestPolledVMsReusesFreshPoll(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWatchExitsTracksRunningPIDs(t *testing.T) {
|
||||
gone := 999999 // no such process: WaitProcessExit reports it exited at once
|
||||
stopped := reims.VMListItem{Name: "m1", State: "stopped"}
|
||||
running := reims.VMListItem{Name: "m0", State: "running", PID: &gone}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
exits := make(chan struct{}, 4)
|
||||
watched := map[int]bool{}
|
||||
watchExits(ctx, []reims.VMListItem{running, stopped}, watched, func() { exits <- struct{}{} })
|
||||
watchExits(ctx, []reims.VMListItem{running, stopped}, watched, func() { exits <- struct{}{} })
|
||||
if len(watched) != 1 || !watched[gone] {
|
||||
t.Fatalf("watched = %v, want only %d", watched, gone)
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
select {
|
||||
case <-exits:
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Fatal("onExit not called for an exited process")
|
||||
}
|
||||
select {
|
||||
case <-exits:
|
||||
t.Fatal("a PID already watched must not get a second waiter")
|
||||
case <-time.After(300 * time.Millisecond):
|
||||
}
|
||||
}
|
||||
|
||||
running.State = "stopped"
|
||||
watchExits(ctx, []reims.VMListItem{running, stopped}, watched, func() {})
|
||||
if len(watched) != 0 {
|
||||
t.Fatalf("watched = %v, want empty once the VM stopped", watched)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWakePollMarksStaleAndWakesOnce(t *testing.T) {
|
||||
a := &App{pollWake: make(chan struct{}, 1)}
|
||||
a.lastVMsAt = time.Now()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "reims-go-frontend",
|
||||
"private": true,
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1 +1 @@
|
||||
f71dbd21d10dd124677343ad731d7f59
|
||||
3e62bdadbba688cfaff4397370fad1e2
|
||||
@@ -12,6 +12,9 @@ import {
|
||||
memorySafeLimitGB,
|
||||
parseMemoryGB,
|
||||
recommendedCPUs,
|
||||
hidpiLooksLike,
|
||||
hostDisplayAdvice,
|
||||
hostDisplayDesc,
|
||||
recommendedDisplayPresets,
|
||||
recommendedMemoryGB,
|
||||
recommendedResolution,
|
||||
@@ -444,14 +447,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
title={tr('resolution')}
|
||||
disabled={opts.graphics !== 'reims-vgpu'}
|
||||
reason={tr('gpuSvgaReason')}
|
||||
desc={host.primary_display
|
||||
? tr('hostDisplayHint', {
|
||||
w: host.primary_display.width,
|
||||
h: host.primary_display.height,
|
||||
scale: host.primary_display.scale_pct || 100,
|
||||
rec: host.recommended_resolution || '1920x1080',
|
||||
})
|
||||
: undefined}
|
||||
desc={[hostDisplayDesc(host, tr), hostDisplayAdvice(host, tr)].filter(Boolean).join(' · ') || undefined}
|
||||
control={
|
||||
<PopupSelect
|
||||
id="vm-res"
|
||||
@@ -461,7 +457,7 @@ export const CreateWizard: React.FC<Props> = ({ locale, host, draft, onClose, on
|
||||
options={recommendedDisplayPresets(host).map((p) => ({
|
||||
value: p.resolution,
|
||||
label: p.label,
|
||||
detail: [p.hidpi ? tr('hidpiPresetBadge') : '', p.recommended ? tr('recommendedBadge') : ''].filter(Boolean).join(' · ') || undefined,
|
||||
detail: [p.hidpi ? `${tr('hidpiPresetBadge')} · ${hidpiLooksLike(p.resolution, tr) ?? ''}` : '', p.recommended ? tr('recommendedBadge') : ''].filter(Boolean).join(' · ') || undefined,
|
||||
}))}
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ interface Props {
|
||||
export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, onSetLocale, runtimeTask, onChannel, onInstallRuntime, onCancelTask }) => {
|
||||
const [importing, setImporting] = useState(false)
|
||||
const [enabling, setEnabling] = useState(false)
|
||||
const [openingSched, setOpeningSched] = useState(false)
|
||||
const [appUpdate, setAppUpdate] = useState<AppUpdateInfo | null>(null)
|
||||
const [checkingUpdate, setCheckingUpdate] = useState(false)
|
||||
const [updateErr, setUpdateErr] = useState('')
|
||||
@@ -71,6 +72,14 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, o
|
||||
setEnabling(false)
|
||||
}
|
||||
|
||||
// One UAC prompt, then Windows' own Performance Options; the choice shows
|
||||
// here on the next refresh.
|
||||
const openScheduling = async () => {
|
||||
setOpeningSched(true)
|
||||
await guard(() => api.OpenProcessorScheduling())()
|
||||
setOpeningSched(false)
|
||||
}
|
||||
|
||||
const pickDataRoot = guard(async () => {
|
||||
const dir = await api.PickDirectory(tr('hostDataRoot'))
|
||||
if (dir) await api.SetDataRoot(dir)
|
||||
@@ -289,6 +298,20 @@ export const HostView: React.FC<Props> = ({ state, locale, onRefresh, onError, o
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="row-main">
|
||||
<div className="row-title">
|
||||
{tr('optSchedTitle')}
|
||||
{host.processor_scheduling && (
|
||||
<span className="badge">{tr(host.processor_scheduling === 'background' ? 'optSchedBackground' : 'optSchedPrograms')}</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="row-sub">{tr('optSchedSub')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Button busy={openingSched} onClick={openScheduling}>{tr('optSchedOpen')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ import {
|
||||
memorySafeLimitGB,
|
||||
parseMemoryGB,
|
||||
recommendedCPUs,
|
||||
hidpiLooksLike,
|
||||
hostDisplayAdvice,
|
||||
hostDisplayDesc,
|
||||
recommendedDisplayPresets,
|
||||
recommendedMemoryGB,
|
||||
shortGPUName,
|
||||
@@ -70,6 +73,7 @@ const FIELDS = Object.keys(FIELD_CAT) as Field[]
|
||||
|
||||
const LOG_LEVELS = ['error', 'warn', 'info', 'debug', 'trace'] as const
|
||||
const CUSTOM = '__custom'
|
||||
const FULLSCREEN = '__fullscreen'
|
||||
const RES_RE = /^\s*\d{3,5}\s*[x×]\s*\d{3,5}\s*$/i
|
||||
|
||||
const normPath = (s: string | undefined) => (s ?? '').replace(/\//g, '\\').toLowerCase()
|
||||
@@ -155,7 +159,19 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, stats, host, op
|
||||
const [customRes, setCustomRes] = useState(!presetHit)
|
||||
const [customLog, setCustomLog] = useState(!!form.log_level && !(LOG_LEVELS as readonly string[]).includes(form.log_level))
|
||||
|
||||
// The detail the panel opened with can be a stale one (reopened right after
|
||||
// a save, before the refreshed detail arrives): follow newer details until
|
||||
// the person changes something.
|
||||
const edited = useRef(false)
|
||||
useEffect(() => {
|
||||
if (edited.current) return
|
||||
setForm(base)
|
||||
setCustomRes(!presets.some((p) => same('resolution', p.resolution, base.resolution)))
|
||||
setCustomLog(!!base.log_level && !(LOG_LEVELS as readonly string[]).includes(base.log_level))
|
||||
}, [base]) // presets come from host, which base already follows
|
||||
|
||||
const set = (patch: Partial<SetOpts>) => {
|
||||
edited.current = true
|
||||
setForm((f) => ({ ...f, ...patch }))
|
||||
const touched = Object.keys(patch)
|
||||
setIssues((list) => list.filter((i) => !touched.includes(i.field)))
|
||||
@@ -246,6 +262,7 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, stats, host, op
|
||||
}
|
||||
|
||||
const resetAll = () => {
|
||||
edited.current = false
|
||||
setForm(base)
|
||||
setIssues([])
|
||||
setCustomRes(!presets.some((p) => same('resolution', p.resolution, base.resolution)))
|
||||
@@ -368,7 +385,9 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, stats, host, op
|
||||
gpuOptions.push({ value: form.gpu, title: form.gpu.split(/[\\/]/).pop() || form.gpu, sub: tr('gpuCustomIcd') })
|
||||
}
|
||||
const vgpu = form.graphics !== 'vmware-svga'
|
||||
const resValue = customRes ? CUSTOM : presets.find((p) => same('resolution', p.resolution, form.resolution))?.resolution
|
||||
const pd = host.primary_display
|
||||
const hidpiAdvice = hostDisplayAdvice(host, tr)
|
||||
const resValue = form.borderless ? FULLSCREEN : customRes ? CUSTOM : presets.find((p) => same('resolution', p.resolution, form.resolution))?.resolution
|
||||
const resArt = (r: string) => {
|
||||
const m = /^(\d+)\s*[x×]\s*(\d+)$/i.exec(r)
|
||||
return m ? <ScreenArt w={Number(m[1])} h={Number(m[2])} /> : <ScreenArt w={16} h={10} />
|
||||
@@ -406,37 +425,42 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, stats, host, op
|
||||
<SetGroup title={tr('displayGroup')}>
|
||||
<SetRow
|
||||
{...rowProps('resolution')}
|
||||
// Full screen is one of the sizes here, so the row also owns borderless.
|
||||
dirty={dirty('resolution') || dirty('borderless')}
|
||||
onReset={() => { reset('resolution')(); reset('borderless')() }}
|
||||
error={issueOf('resolution') ?? (resBad ? tr('resInvalid') : undefined)}
|
||||
title={tr('resolution')}
|
||||
desc={host.primary_display
|
||||
? tr('hostDisplayHint', {
|
||||
w: host.primary_display.width,
|
||||
h: host.primary_display.height,
|
||||
scale: host.primary_display.scale_pct || 100,
|
||||
rec: host.recommended_resolution || '1920x1080',
|
||||
})
|
||||
: undefined}
|
||||
desc={hostDisplayDesc(host, tr)}
|
||||
block={
|
||||
<>
|
||||
<OptionCards
|
||||
label={tr('resolution')}
|
||||
value={resValue}
|
||||
onChange={(v) => {
|
||||
if (v === CUSTOM) { setCustomRes(true); return }
|
||||
if (v === FULLSCREEN) { setCustomRes(false); set({ borderless: true }); return }
|
||||
if (v === CUSTOM) { setCustomRes(true); set({ borderless: false }); return }
|
||||
setCustomRes(false)
|
||||
set({ resolution: v })
|
||||
set({ resolution: v, borderless: false })
|
||||
}}
|
||||
options={[
|
||||
...presets.map((p) => ({
|
||||
value: p.resolution,
|
||||
title: p.label,
|
||||
sub: p.hidpi ? hidpiLooksLike(p.resolution, tr) : undefined,
|
||||
art: resArt(p.resolution),
|
||||
badges: [p.hidpi ? tr('hidpiPresetBadge') : '', p.recommended ? tr('recommendedBadge') : ''].filter(Boolean),
|
||||
})),
|
||||
{
|
||||
value: FULLSCREEN,
|
||||
title: tr('resFullscreen'),
|
||||
sub: pd ? `${pd.width} × ${pd.height}` : undefined,
|
||||
art: pd ? resArt(`${pd.width}x${pd.height}`) : resArt('16x10'),
|
||||
badges: host.fullscreen_hidpi ? [tr('hidpiPresetBadge')] : [],
|
||||
},
|
||||
{ value: CUSTOM, title: tr('resCustom'), sub: tr('resCustomSub'), art: <span className="screen-art custom" aria-hidden="true" /> },
|
||||
]}
|
||||
/>
|
||||
{customRes && (
|
||||
{customRes && !form.borderless && (
|
||||
<input
|
||||
className="input mono res-input"
|
||||
aria-label={tr('resolution')}
|
||||
@@ -446,6 +470,7 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, stats, host, op
|
||||
onChange={(e) => set({ resolution: e.target.value })}
|
||||
/>
|
||||
)}
|
||||
{hidpiAdvice && <div className="srow-desc res-advice">{hidpiAdvice}</div>}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
@@ -462,12 +487,6 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, stats, host, op
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SetRow
|
||||
{...rowProps('borderless')}
|
||||
title={tr('fullscreenLaunch')}
|
||||
desc={tr('fullscreenLaunchHint')}
|
||||
control={<Switch label={tr('fullscreenLaunch')} checked={!!form.borderless} onChange={(borderless) => set({ borderless })} />}
|
||||
/>
|
||||
</SetGroup>
|
||||
</>
|
||||
)
|
||||
@@ -748,6 +767,8 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, stats, host, op
|
||||
{ value: 'auto', label: tr('audioBackendAuto') },
|
||||
{ value: 'dsound', label: tr('audioBackendDsound') },
|
||||
{ value: 'none', label: tr('audioBackendNone') },
|
||||
// A backend set elsewhere (`reims-ctl set --audio-backend wav`) still shows as chosen.
|
||||
...(['auto', 'dsound', 'none'].includes(form.audio_backend || 'auto') ? [] : [{ value: form.audio_backend as string, label: form.audio_backend as string }]),
|
||||
]}
|
||||
/>
|
||||
}
|
||||
|
||||
+22
-2
@@ -390,6 +390,8 @@ const dict = {
|
||||
displayGroup: '显示器',
|
||||
resCustom: '自定义',
|
||||
resCustomSub: '宽 × 高',
|
||||
resFullscreen: '全屏',
|
||||
resLooksLike: '看起来像 {w} × {h}',
|
||||
resInvalid: '格式为 宽x高,例如 2560x1600',
|
||||
driveShareTitle: 'Windows 盘符共享',
|
||||
driveShareMaster: '共享 Windows 盘符',
|
||||
@@ -447,6 +449,11 @@ const dict = {
|
||||
optDiscreteGpuRec: '已检测到独立显卡({name}),新建时默认优先使用',
|
||||
optDiscreteGpuIntegrated: '仅检测到核显({name}),性能弱于独立显卡',
|
||||
optDiscreteGpuUnavailable: '未检测到可用 Vulkan 显卡,可先切换 vmware-svga 排障',
|
||||
optSchedTitle: 'Windows 处理器计划',
|
||||
optSchedPrograms: '程序优先',
|
||||
optSchedBackground: '后台服务',
|
||||
optSchedSub: '「程序」偏向前台窗口;「后台服务」让各进程平均分配 CPU。虚拟机常在后台跑任务时,选「后台服务」更稳定',
|
||||
optSchedOpen: '以管理员身份打开…',
|
||||
kernelIrqchipLabel: 'WHPX 中断模式',
|
||||
kernelIrqchipAuto: '自动',
|
||||
kernelIrqchipOn: '开启',
|
||||
@@ -460,9 +467,12 @@ const dict = {
|
||||
minimizeToTraySub: '关闭窗口后剪贴板和共享文件夹继续工作,可从托盘启停虚拟机',
|
||||
hostDisplays: '物理显示器',
|
||||
hostDisplayPrimary: '主屏',
|
||||
hostDisplayHint: '主屏 {w}×{h},{scale}% 缩放 · 推荐 {rec}',
|
||||
hostDisplayHint: '主屏 {w}×{h},{scale}% 缩放',
|
||||
multiDisplayHint: '检测到 {n} 块显示器,排列方式在 macOS「系统设置 › 显示器」里调整',
|
||||
hidpiPresetBadge: 'HiDPI',
|
||||
hidpiTipFullscreen: '窗口里的 macOS 只能 1x,文字会发虚;改用全屏可得到 HiDPI',
|
||||
hidpiTipScale: '这块屏幕上 macOS 只能 1x,文字会发虚;把 Windows 缩放调到 150% 或以上可得到 HiDPI',
|
||||
hidpiTipUnavailable: '这块屏幕像素不够,macOS 只能以 1x 显示',
|
||||
recommendedBadge: '推荐',
|
||||
fullscreenLaunch: '无边框全屏启动',
|
||||
fullscreenLaunchHint: '启动后直接进入无边框全屏',
|
||||
@@ -889,6 +899,8 @@ const dict = {
|
||||
displayGroup: 'Displays',
|
||||
resCustom: 'Custom',
|
||||
resCustomSub: 'Width × height',
|
||||
resFullscreen: 'Full screen',
|
||||
resLooksLike: 'Looks like {w} × {h}',
|
||||
resInvalid: 'Use WIDTHxHEIGHT, e.g. 2560x1600',
|
||||
driveShareTitle: 'Windows drive sharing',
|
||||
driveShareMaster: 'Share Windows drives',
|
||||
@@ -946,6 +958,11 @@ const dict = {
|
||||
optDiscreteGpuRec: 'Discrete GPU detected ({name}); preferred automatically',
|
||||
optDiscreteGpuIntegrated: 'Integrated GPU only ({name})',
|
||||
optDiscreteGpuUnavailable: 'No Vulkan GPU detected; use vmware-svga for troubleshooting',
|
||||
optSchedTitle: 'Windows processor scheduling',
|
||||
optSchedPrograms: 'Programs',
|
||||
optSchedBackground: 'Background services',
|
||||
optSchedSub: 'Programs favours the window in front; Background services shares the CPU evenly. If the VM often works while you use other apps, Background services keeps it steadier',
|
||||
optSchedOpen: 'Open as administrator…',
|
||||
kernelIrqchipLabel: 'WHPX interrupt mode',
|
||||
kernelIrqchipAuto: 'Auto',
|
||||
kernelIrqchipOn: 'On',
|
||||
@@ -959,9 +976,12 @@ const dict = {
|
||||
minimizeToTraySub: 'Clipboard and shared folders keep working; start and stop VMs from the tray',
|
||||
hostDisplays: 'Physical displays',
|
||||
hostDisplayPrimary: 'Primary',
|
||||
hostDisplayHint: 'Main display {w}×{h} at {scale}% · {rec} recommended',
|
||||
hostDisplayHint: 'Main display {w}×{h} at {scale}%',
|
||||
multiDisplayHint: '{n} displays found; arrange them in macOS System Settings › Displays',
|
||||
hidpiPresetBadge: 'HiDPI',
|
||||
hidpiTipFullscreen: 'In a window macOS runs at 1x with rough text; full screen gives HiDPI',
|
||||
hidpiTipScale: 'macOS runs at 1x on this screen, with rough text; Windows scaling at 150% or more gives HiDPI',
|
||||
hidpiTipUnavailable: 'This screen has too few pixels; macOS runs at 1x',
|
||||
recommendedBadge: 'Recommended',
|
||||
fullscreenLaunch: 'Launch borderless fullscreen',
|
||||
fullscreenLaunchHint: 'Opens macOS in borderless full screen',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { t } from '../i18n'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { DisplayPreset, GPUInfo, HostReport, Locale, VMDetail } from '../types'
|
||||
|
||||
// Human-readable values for the main view (docs/ui-redesign.md §4.3).
|
||||
@@ -133,13 +133,41 @@ export function formatUptime(sec: number, locale: Locale): string {
|
||||
return `${s}s`
|
||||
}
|
||||
|
||||
// Used only when the host report has no presets: with nothing known about the
|
||||
// screen, no size can be called HiDPI (internal/host/display.go).
|
||||
const DEFAULT_DISPLAY_PRESETS: DisplayPreset[] = [
|
||||
{ resolution: '1920x1080', label: '1920 × 1080', hidpi: false, recommended: true },
|
||||
{ resolution: '2560x1440', label: '2560 × 1440', hidpi: false },
|
||||
{ resolution: '2880x1800', label: '2880 × 1800', hidpi: true },
|
||||
{ resolution: '3840x2160', label: '3840 × 2160', hidpi: true },
|
||||
{ resolution: '2880x1800', label: '2880 × 1800', hidpi: false },
|
||||
]
|
||||
|
||||
type Tr = (k: I18nKey, v?: Record<string, string | number>) => string
|
||||
|
||||
// The resolution row's description: the main display and its scaling.
|
||||
export function hostDisplayDesc(host: HostReport, tr: Tr): string | undefined {
|
||||
const d = host.primary_display
|
||||
if (!d) return undefined
|
||||
return tr('hostDisplayHint', { w: d.width, h: d.height, scale: d.scale_pct || 100 })
|
||||
}
|
||||
|
||||
// How to get a HiDPI (sharp-text) macOS desktop when no window size gives
|
||||
// one on this screen; undefined when one does.
|
||||
export function hostDisplayAdvice(host: HostReport, tr: Tr): string | undefined {
|
||||
const tip: Record<string, I18nKey> = {
|
||||
fullscreen: 'hidpiTipFullscreen',
|
||||
scale: 'hidpiTipScale',
|
||||
unavailable: 'hidpiTipUnavailable',
|
||||
}
|
||||
const key = host.hidpi_advice ? tip[host.hidpi_advice] : undefined
|
||||
return key ? tr(key) : undefined
|
||||
}
|
||||
|
||||
// "Looks like" size of a HiDPI preset: macOS draws it at half each way.
|
||||
export function hidpiLooksLike(resolution: string, tr: Tr): string | undefined {
|
||||
const m = /^(\d+)\s*[x×]\s*(\d+)$/i.exec(resolution)
|
||||
return m ? tr('resLooksLike', { w: Math.round(Number(m[1]) / 2), h: Math.round(Number(m[2]) / 2) }) : undefined
|
||||
}
|
||||
|
||||
export function recommendedDisplayPresets(host: HostReport): DisplayPreset[] {
|
||||
if (host.display_presets && host.display_presets.length > 0) {
|
||||
return host.display_presets
|
||||
|
||||
@@ -523,6 +523,7 @@ h1, h2, h3, p { margin: 0; }
|
||||
.srow-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
|
||||
.srow-title { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text); }
|
||||
.srow-desc { font-size: var(--fs-12); color: var(--text-3); line-height: 1.5; }
|
||||
.res-advice { margin-top: var(--sp-2, 8px); color: var(--status-busy); }
|
||||
.srow-reason { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-12); color: var(--text-2); }
|
||||
.srow-ctrl { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
|
||||
.srow-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; transition: opacity var(--dur-fast); }
|
||||
|
||||
Vendored
+2
@@ -72,6 +72,8 @@ export function ListOfflineReleases():Promise<Array<installer.Release>>;
|
||||
|
||||
export function ListRemoteRuntimes():Promise<Array<runtime.Remote>>;
|
||||
|
||||
export function OpenProcessorScheduling():Promise<void>;
|
||||
|
||||
export function OpenSharedFolder(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenURL(arg1:string):Promise<void>;
|
||||
|
||||
@@ -134,6 +134,10 @@ export function ListRemoteRuntimes() {
|
||||
return window['go']['main']['App']['ListRemoteRuntimes']();
|
||||
}
|
||||
|
||||
export function OpenProcessorScheduling() {
|
||||
return window['go']['main']['App']['OpenProcessorScheduling']();
|
||||
}
|
||||
|
||||
export function OpenSharedFolder(arg1) {
|
||||
return window['go']['main']['App']['OpenSharedFolder'](arg1);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ export namespace host {
|
||||
scale_pct: number;
|
||||
refresh_hz?: number;
|
||||
primary: boolean;
|
||||
work_width?: number;
|
||||
work_height?: number;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new DisplayInfo(source);
|
||||
@@ -69,6 +71,8 @@ export namespace host {
|
||||
this.scale_pct = source["scale_pct"];
|
||||
this.refresh_hz = source["refresh_hz"];
|
||||
this.primary = source["primary"];
|
||||
this.work_width = source["work_width"];
|
||||
this.work_height = source["work_height"];
|
||||
}
|
||||
}
|
||||
export class DisplayPreset {
|
||||
@@ -178,6 +182,9 @@ export namespace host {
|
||||
primary_display?: DisplayInfo;
|
||||
recommended_resolution?: string;
|
||||
display_presets?: DisplayPreset[];
|
||||
hidpi_advice?: string;
|
||||
fullscreen_hidpi: boolean;
|
||||
processor_scheduling?: string;
|
||||
audio: AudioInfo;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
@@ -218,6 +225,9 @@ export namespace host {
|
||||
this.primary_display = this.convertValues(source["primary_display"], DisplayInfo);
|
||||
this.recommended_resolution = source["recommended_resolution"];
|
||||
this.display_presets = this.convertValues(source["display_presets"], DisplayPreset);
|
||||
this.hidpi_advice = source["hidpi_advice"];
|
||||
this.fullscreen_hidpi = source["fullscreen_hidpi"];
|
||||
this.processor_scheduling = source["processor_scheduling"];
|
||||
this.audio = this.convertValues(source["audio"], AudioInfo);
|
||||
}
|
||||
|
||||
@@ -392,11 +402,11 @@ export namespace main {
|
||||
root: string;
|
||||
selected: boolean;
|
||||
system: boolean;
|
||||
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new DriveShareInfo(source);
|
||||
}
|
||||
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.drive = source["drive"];
|
||||
@@ -410,11 +420,11 @@ export namespace main {
|
||||
read_only: boolean;
|
||||
required_agent_version: number;
|
||||
drives: DriveShareInfo[];
|
||||
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new DriveShareSettings(source);
|
||||
}
|
||||
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.enabled = source["enabled"];
|
||||
@@ -422,7 +432,7 @@ export namespace main {
|
||||
this.required_agent_version = source["required_agent_version"];
|
||||
this.drives = this.convertValues(source["drives"], DriveShareInfo);
|
||||
}
|
||||
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
|
||||
@@ -39,36 +39,36 @@ type VMListItem struct {
|
||||
}
|
||||
|
||||
type VMDetail struct {
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
Kind string `json:"kind"`
|
||||
Directory string `json:"directory"`
|
||||
CPUs int `json:"cpus"`
|
||||
Memory string `json:"memory"`
|
||||
Disk string `json:"disk"`
|
||||
DiskController string `json:"disk_controller"`
|
||||
Graphics string `json:"graphics"`
|
||||
Display string `json:"display"`
|
||||
Displays int `json:"displays"`
|
||||
Resolution string `json:"resolution"`
|
||||
GPU string `json:"gpu"`
|
||||
HasOpenCore bool `json:"has_opencore"`
|
||||
HasInstaller bool `json:"has_installer"`
|
||||
RecoveryMode bool `json:"recovery_mode"`
|
||||
InstallerPath string `json:"installer_path,omitempty"`
|
||||
CPUModel string `json:"cpu_model"`
|
||||
Audio bool `json:"audio"`
|
||||
AudioBackend string `json:"audio_backend,omitempty"`
|
||||
AudioRaw string `json:"audio_raw"`
|
||||
Network bool `json:"network"`
|
||||
NetworkSummary string `json:"network_summary"`
|
||||
SSHPort int `json:"ssh_port"`
|
||||
Logs bool `json:"logs"`
|
||||
LogLevel string `json:"log_level"`
|
||||
StopTimeout int `json:"stop_timeout"`
|
||||
Capture bool `json:"capture"`
|
||||
Borderless bool `json:"borderless"`
|
||||
ExtraArgs string `json:"extra_args"`
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
Kind string `json:"kind"`
|
||||
Directory string `json:"directory"`
|
||||
CPUs int `json:"cpus"`
|
||||
Memory string `json:"memory"`
|
||||
Disk string `json:"disk"`
|
||||
DiskController string `json:"disk_controller"`
|
||||
Graphics string `json:"graphics"`
|
||||
Display string `json:"display"`
|
||||
Displays int `json:"displays"`
|
||||
Resolution string `json:"resolution"`
|
||||
GPU string `json:"gpu"`
|
||||
HasOpenCore bool `json:"has_opencore"`
|
||||
HasInstaller bool `json:"has_installer"`
|
||||
RecoveryMode bool `json:"recovery_mode"`
|
||||
InstallerPath string `json:"installer_path,omitempty"`
|
||||
CPUModel string `json:"cpu_model"`
|
||||
Audio bool `json:"audio"`
|
||||
AudioBackend string `json:"audio_backend,omitempty"`
|
||||
AudioRaw string `json:"audio_raw"`
|
||||
Network bool `json:"network"`
|
||||
NetworkSummary string `json:"network_summary"`
|
||||
SSHPort int `json:"ssh_port"`
|
||||
Logs bool `json:"logs"`
|
||||
LogLevel string `json:"log_level"`
|
||||
StopTimeout int `json:"stop_timeout"`
|
||||
Capture bool `json:"capture"`
|
||||
Borderless bool `json:"borderless"`
|
||||
ExtraArgs string `json:"extra_args"`
|
||||
GuestToolsAttached bool `json:"guest_tools_attached"`
|
||||
GuestToolsConfigured bool `json:"guest_tools_configured"`
|
||||
GuestToolsConnected bool `json:"guest_tools_connected"`
|
||||
@@ -94,26 +94,26 @@ type CreateOpts struct {
|
||||
// Offline makes --macos an offline installer of one release (13 to 20 GB)
|
||||
// that installs with no network; upstream advises the VM's network off then
|
||||
// (`reims-ctl create --help`, 3731afd). Network defaults to false with it.
|
||||
Offline bool `json:"offline,omitempty"`
|
||||
Installer string `json:"installer,omitempty"`
|
||||
CPUs int `json:"cpus,omitempty"`
|
||||
Memory string `json:"memory,omitempty"`
|
||||
Offline bool `json:"offline,omitempty"`
|
||||
Installer string `json:"installer,omitempty"`
|
||||
CPUs int `json:"cpus,omitempty"`
|
||||
Memory string `json:"memory,omitempty"`
|
||||
DiskSize string `json:"disk_size,omitempty"`
|
||||
Disk string `json:"disk,omitempty"`
|
||||
DiskMode string `json:"disk_mode,omitempty"`
|
||||
DiskController string `json:"disk_controller,omitempty"`
|
||||
Graphics string `json:"graphics,omitempty"`
|
||||
GPU string `json:"gpu,omitempty"`
|
||||
Resolution string `json:"resolution,omitempty"`
|
||||
Displays int `json:"displays,omitempty"`
|
||||
Borderless *bool `json:"borderless,omitempty"`
|
||||
Capture *bool `json:"capture,omitempty"`
|
||||
Audio *bool `json:"audio,omitempty"`
|
||||
Network *bool `json:"network,omitempty"`
|
||||
SSHPort int `json:"ssh_port,omitempty"`
|
||||
Logs *bool `json:"logs,omitempty"`
|
||||
GuestLang string `json:"guest_lang,omitempty"`
|
||||
Start bool `json:"start,omitempty"`
|
||||
GPU string `json:"gpu,omitempty"`
|
||||
Resolution string `json:"resolution,omitempty"`
|
||||
Displays int `json:"displays,omitempty"`
|
||||
Borderless *bool `json:"borderless,omitempty"`
|
||||
Capture *bool `json:"capture,omitempty"`
|
||||
Audio *bool `json:"audio,omitempty"`
|
||||
Network *bool `json:"network,omitempty"`
|
||||
SSHPort int `json:"ssh_port,omitempty"`
|
||||
Logs *bool `json:"logs,omitempty"`
|
||||
GuestLang string `json:"guest_lang,omitempty"`
|
||||
Start bool `json:"start,omitempty"`
|
||||
}
|
||||
|
||||
type SetOpts struct {
|
||||
@@ -143,7 +143,10 @@ var (
|
||||
reVMName = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$`)
|
||||
reSizeG = regexp.MustCompile(`(?i)^(\d+)\s*([GM])$`)
|
||||
reRes = regexp.MustCompile(`^(\d{3,5})x(\d{3,5})$`)
|
||||
reMac = regexp.MustCompile(`(?i),?\s*mac\s+[0-9a-f]{2}(:[0-9a-f]{2}){5}`)
|
||||
// reResIn finds a WIDTHxHEIGHT inside `show`'s display line (reRes is a
|
||||
// whole-value check and never matched there).
|
||||
reResIn = regexp.MustCompile(`\b\d{3,5}x\d{3,5}\b`)
|
||||
reMac = regexp.MustCompile(`(?i),?\s*mac\s+[0-9a-f]{2}(:[0-9a-f]{2}){5}`)
|
||||
)
|
||||
|
||||
// ParseSizeGB parses "16G" or "4096M" into gigabytes.
|
||||
@@ -501,6 +504,26 @@ func showState(v string) string {
|
||||
return v
|
||||
}
|
||||
|
||||
// parseDisplayCount reads the count that starts `show`'s display line: a word
|
||||
// ("one") or a number ("2"); 1 where there is neither.
|
||||
func parseDisplayCount(v string) int {
|
||||
first := strings.ToLower(strings.TrimSpace(strings.SplitN(v, ",", 2)[0]))
|
||||
switch first {
|
||||
case "one":
|
||||
return 1
|
||||
case "two":
|
||||
return 2
|
||||
case "three":
|
||||
return 3
|
||||
case "four":
|
||||
return 4
|
||||
}
|
||||
if n, err := strconv.Atoi(first); err == nil && n >= 1 && n <= 4 {
|
||||
return n
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
// ParseShow parses the text output of `reims-ctl show <name>` while redacting MAC addresses.
|
||||
func ParseShow(name, text string) VMDetail {
|
||||
d := VMDetail{
|
||||
@@ -548,29 +571,24 @@ func ParseShow(name, text string) VMDetail {
|
||||
d.DiskController = "ahci"
|
||||
}
|
||||
case "graphics":
|
||||
if strings.HasPrefix(v, "vmware-svga") {
|
||||
// "VMware SVGA, no GPU acceleration, in QEMU's window" (3731afd
|
||||
// cli.rs describe); older builds printed "vmware-svga".
|
||||
if low := strings.ToLower(v); strings.HasPrefix(low, "vmware svga") || strings.HasPrefix(low, "vmware-svga") {
|
||||
d.Graphics = "vmware-svga"
|
||||
} else {
|
||||
d.Graphics = "reims-vgpu"
|
||||
}
|
||||
case "display":
|
||||
case "display", "displays":
|
||||
// One display: "display one, in a window opening at 1920x1080, ...";
|
||||
// more: "displays 2, in 2 windows opening at 1920x1080, ..." (3731afd).
|
||||
d.Display = v
|
||||
if m := reRes.FindString(v); m != "" {
|
||||
if m := reResIn.FindString(v); m != "" {
|
||||
d.Resolution = m
|
||||
}
|
||||
if strings.Contains(strings.ToLower(v), "borderless") {
|
||||
d.Borderless = true
|
||||
}
|
||||
switch {
|
||||
case strings.HasPrefix(v, "two"):
|
||||
d.Displays = 2
|
||||
case strings.HasPrefix(v, "three"):
|
||||
d.Displays = 3
|
||||
case strings.HasPrefix(v, "four"):
|
||||
d.Displays = 4
|
||||
default:
|
||||
d.Displays = 1
|
||||
}
|
||||
d.Displays = parseDisplayCount(v)
|
||||
case "gpu":
|
||||
if strings.HasPrefix(strings.ToLower(v), "automatic") {
|
||||
d.GPU = "auto"
|
||||
@@ -612,8 +630,11 @@ func ParseShow(name, text string) VMDetail {
|
||||
d.LogLevel = m[1]
|
||||
}
|
||||
case "stop timeout":
|
||||
// "90 s", or "none: stop waits until the guest shuts down" for 0.
|
||||
if m := regexp.MustCompile(`(\d+)`).FindString(v); m != "" {
|
||||
d.StopTimeout, _ = strconv.Atoi(m)
|
||||
} else if strings.HasPrefix(strings.ToLower(v), "none") {
|
||||
d.StopTimeout = 0
|
||||
}
|
||||
case "capture":
|
||||
low := strings.ToLower(strings.TrimSpace(v))
|
||||
|
||||
@@ -114,3 +114,62 @@ func TestParseShowStateDropsPID(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reims-ctl 3731afd prints one display as "display one, ..." and several as
|
||||
// "displays 2, in 2 windows ..."; both must read back.
|
||||
func TestParseShowDisplayCount(t *testing.T) {
|
||||
cases := []struct {
|
||||
line string
|
||||
want int
|
||||
wantRes string
|
||||
borderle bool
|
||||
}{
|
||||
{" display one, in a window opening at 1920x1080, whose size the guest follows", 1, "1920x1080", false},
|
||||
{" displays 2, in 2 windows opening at 1920x1080, whose sizes the guest follows", 2, "1920x1080", false},
|
||||
{" displays 4, in 4 windows opening at 2560x1600, whose sizes the guest follows", 4, "2560x1600", false},
|
||||
// Borderless lines name no size; Resolution keeps its default.
|
||||
{" displays 2, in 2 borderless windows, each filling its screen", 2, "1920x1080", true},
|
||||
{" display one, filling its screen, borderless", 1, "1920x1080", true},
|
||||
}
|
||||
for _, c := range cases {
|
||||
d := ParseShow("m0", "m0\n state stopped\n"+c.line+"\n")
|
||||
if d.Displays != c.want || d.Resolution != c.wantRes || d.Borderless != c.borderle {
|
||||
t.Errorf("%q: displays=%d res=%q borderless=%v, want %d %q %v", c.line, d.Displays, d.Resolution, d.Borderless, c.want, c.wantRes, c.borderle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Lines as reims-ctl 3731afd's describe (crates/reims-ctl/src/cli.rs) prints
|
||||
// non-default settings.
|
||||
func TestParseShowNonDefaultLines(t *testing.T) {
|
||||
text := "m0\n" +
|
||||
" state stopped\n" +
|
||||
" disk disk.qcow2 (qcow2, SATA)\n" +
|
||||
" graphics VMware SVGA, no GPU acceleration, in QEMU's window\n" +
|
||||
" audio none\n" +
|
||||
" network user, mac 52:54:00:12:34:56\n" +
|
||||
" logs on (trace)\n" +
|
||||
" stop timeout none: stop waits until the guest shuts down\n"
|
||||
d := ParseShow("m0", text)
|
||||
if d.Graphics != "vmware-svga" {
|
||||
t.Errorf("graphics = %q, want vmware-svga", d.Graphics)
|
||||
}
|
||||
if d.StopTimeout != 0 {
|
||||
t.Errorf("stop timeout = %d, want 0 (no limit)", d.StopTimeout)
|
||||
}
|
||||
if d.DiskController != "ahci" {
|
||||
t.Errorf("disk controller = %q, want ahci", d.DiskController)
|
||||
}
|
||||
if !d.Audio || d.AudioBackend != "none" {
|
||||
t.Errorf("audio = %v/%q, want on with backend none", d.Audio, d.AudioBackend)
|
||||
}
|
||||
if !d.Network || d.SSHPort != 0 {
|
||||
t.Errorf("network = %v ssh %d, want on with no ssh port", d.Network, d.SSHPort)
|
||||
}
|
||||
if !d.Logs || d.LogLevel != "trace" {
|
||||
t.Errorf("logs = %v/%q, want on (trace)", d.Logs, d.LogLevel)
|
||||
}
|
||||
if d := ParseShow("m0", "m0\n graphics reims-vgpu, its own GPU device and macOS drivers\n stop timeout 30 s\n"); d.Graphics != "reims-vgpu" || d.StopTimeout != 30 {
|
||||
t.Errorf("reims-vgpu / 30 s parsed as %q / %d", d.Graphics, d.StopTimeout)
|
||||
}
|
||||
}
|
||||
+134
-120
@@ -13,14 +13,19 @@ type DisplayInfo struct {
|
||||
ScalePct int `json:"scale_pct"` // Windows DPI scaling percentage, e.g. 100, 125, 150, 200
|
||||
RefreshHz int `json:"refresh_hz,omitempty"`
|
||||
Primary bool `json:"primary"`
|
||||
// WorkWidth and WorkHeight are the work area (the screen less the taskbar) in
|
||||
// pixels; 0 where unknown.
|
||||
WorkWidth int `json:"work_width,omitempty"`
|
||||
WorkHeight int `json:"work_height,omitempty"`
|
||||
}
|
||||
|
||||
// DisplayPreset is a suggested macOS VM resolution option tailored to the host monitor.
|
||||
type DisplayPreset struct {
|
||||
Resolution string `json:"resolution"`
|
||||
Label string `json:"label"`
|
||||
HiDPI bool `json:"hidpi"`
|
||||
Recommended bool `json:"recommended,omitempty"`
|
||||
Resolution string `json:"resolution"`
|
||||
Label string `json:"label"`
|
||||
// HiDPI: macOS starts this window size HiDPI on the primary screen (GuestStartsHiDPI).
|
||||
HiDPI bool `json:"hidpi"`
|
||||
Recommended bool `json:"recommended,omitempty"`
|
||||
}
|
||||
|
||||
// PrimaryDisplayOf picks the primary monitor (or the first detected monitor).
|
||||
@@ -38,139 +43,148 @@ func PrimaryDisplayOf(displays []DisplayInfo) *DisplayInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RecommendDisplayPresets computes crisp 1x / 2x HiDPI resolution presets
|
||||
// based on the host primary monitor's physical pixel dimensions and Windows DPI scaling.
|
||||
// When an x86-64 macOS guest on reims-vgpu starts its desktop HiDPI. Upstream
|
||||
// steelbrain/reims-vgpu 3731afd, guest/kext/src/RgfxDisplayIdentity.hpp:33-41
|
||||
// and 68-79, crates/reims-vgpu-window/features.md:138-150:
|
||||
// - the display has 110 pixels per inch a point at the host screen's scale;
|
||||
// - it starts HiDPI from a window of 2048 x 1536 pixels above 160 pixels per
|
||||
// inch, which is a screen at 150% or more (145% gives exactly 160);
|
||||
// - and from 3840 x 2160 pixels at any scale.
|
||||
//
|
||||
// On Windows the window's points are the screen's pixels
|
||||
// (crates/reims-vgpu-window/src/geometry.rs:68-73), so --resolution is the
|
||||
// window's size in pixels and a borderless window is the screen's.
|
||||
const (
|
||||
guestPointsPerInch = 110
|
||||
guestHiDPIMinPPI = 160
|
||||
guestHiDPIMinWidth = 2048
|
||||
guestHiDPIMinHeight = 1536
|
||||
guestHiDPIAnyWidth = 3840
|
||||
guestHiDPIAnyHeight = 2160
|
||||
windowTitleBarPoints = 32 // a window's title bar and frame, in Windows points
|
||||
defaultTaskbarPoints = 48 // used where the work area is unknown
|
||||
maxDisplayPresetCount = 4
|
||||
)
|
||||
|
||||
// guestPixelsPerInch mirrors rgfxDisplayPixelsPerInch for a screen at scalePct.
|
||||
func guestPixelsPerInch(scalePct int) int {
|
||||
if scalePct <= 0 {
|
||||
return guestPointsPerInch
|
||||
}
|
||||
scale120ths := (scalePct*120 + 50) / 100
|
||||
return (guestPointsPerInch*scale120ths + 60) / 120
|
||||
}
|
||||
|
||||
// GuestStartsHiDPI reports whether macOS starts HiDPI in a reims-vgpu window of
|
||||
// w x h pixels on a host screen at scalePct.
|
||||
func GuestStartsHiDPI(w, h, scalePct int) bool {
|
||||
if w >= guestHiDPIAnyWidth && h >= guestHiDPIAnyHeight {
|
||||
return true
|
||||
}
|
||||
return guestPixelsPerInch(scalePct) > guestHiDPIMinPPI && w >= guestHiDPIMinWidth && h >= guestHiDPIMinHeight
|
||||
}
|
||||
|
||||
// FullscreenStartsHiDPI reports whether a borderless window, which fills the
|
||||
// screen, starts macOS HiDPI on d.
|
||||
func FullscreenStartsHiDPI(d *DisplayInfo) bool {
|
||||
if d == nil || d.Width <= 0 || d.Height <= 0 {
|
||||
return false
|
||||
}
|
||||
return GuestStartsHiDPI(d.Width, d.Height, d.ScalePct)
|
||||
}
|
||||
|
||||
// What HiDPIAdvice returns.
|
||||
const (
|
||||
HiDPIAdviceFullscreen = "fullscreen" // a borderless window is HiDPI
|
||||
HiDPIAdviceScale = "scale" // the screen would be at 150% Windows scaling
|
||||
HiDPIAdviceUnavailable = "unavailable" // too few pixels at any scale
|
||||
)
|
||||
|
||||
// HiDPIAdvice says how to get a HiDPI desktop on d when none of presets is
|
||||
// one, and "" when one is or nothing is known about d.
|
||||
func HiDPIAdvice(d *DisplayInfo, presets []DisplayPreset) string {
|
||||
if d == nil || d.Width <= 0 || d.Height <= 0 {
|
||||
return ""
|
||||
}
|
||||
for _, p := range presets {
|
||||
if p.HiDPI {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
switch {
|
||||
case FullscreenStartsHiDPI(d):
|
||||
return HiDPIAdviceFullscreen
|
||||
case d.ScalePct < 150 && GuestStartsHiDPI(d.Width, d.Height, 150):
|
||||
return HiDPIAdviceScale
|
||||
default:
|
||||
return HiDPIAdviceUnavailable
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
presetSizes16x9 = [][2]int{{1280, 720}, {1600, 900}, {1920, 1080}, {2560, 1440}, {2880, 1620}, {3200, 1800}, {3840, 2160}}
|
||||
presetSizes16x10 = [][2]int{{1280, 800}, {1680, 1050}, {1920, 1200}, {2560, 1600}, {2880, 1800}, {3840, 2400}}
|
||||
)
|
||||
|
||||
// RecommendDisplayPresets lists window sizes that fit the primary screen's
|
||||
// work area below a title bar, largest first, each marked HiDPI where macOS
|
||||
// starts it so there. The recommended one is the largest HiDPI size, else the
|
||||
// largest size: text on a 1x macOS desktop is visibly rough, as macOS has no
|
||||
// subpixel antialiasing.
|
||||
func RecommendDisplayPresets(primary *DisplayInfo) ([]DisplayPreset, string) {
|
||||
if primary == nil || primary.Width <= 0 || primary.Height <= 0 {
|
||||
presets := []DisplayPreset{
|
||||
// Nothing known about the screen: no size can be called HiDPI.
|
||||
return []DisplayPreset{
|
||||
{Resolution: "1920x1080", Label: "1920 × 1080", Recommended: true},
|
||||
{Resolution: "2560x1440", Label: "2560 × 1440"},
|
||||
{Resolution: "2880x1800", Label: "2880 × 1800", HiDPI: true},
|
||||
{Resolution: "3840x2160", Label: "3840 × 2160", HiDPI: true},
|
||||
}
|
||||
return presets, "1920x1080"
|
||||
{Resolution: "2880x1800", Label: "2880 × 1800"},
|
||||
}, "1920x1080"
|
||||
}
|
||||
|
||||
w, h := primary.Width, primary.Height
|
||||
scale := primary.ScalePct
|
||||
if scale <= 0 {
|
||||
scale = 100
|
||||
}
|
||||
aspect := float64(w) / float64(h)
|
||||
is16by10 := math.Abs(aspect-1.6) < 0.08
|
||||
|
||||
type cand struct {
|
||||
res string
|
||||
label string
|
||||
hidpi bool
|
||||
usableW, usableH := primary.WorkWidth, primary.WorkHeight
|
||||
if usableW <= 0 || usableH <= 0 {
|
||||
usableW = primary.Width
|
||||
usableH = primary.Height - defaultTaskbarPoints*scale/100
|
||||
}
|
||||
usableH -= windowTitleBarPoints * scale / 100
|
||||
|
||||
var list []cand
|
||||
var rec string
|
||||
|
||||
add := func(res string, hidpi bool) {
|
||||
for _, existing := range list {
|
||||
if existing.res == res {
|
||||
return
|
||||
}
|
||||
}
|
||||
var cw, ch int
|
||||
_, _ = fmt.Sscanf(res, "%dx%d", &cw, &ch)
|
||||
lbl := res
|
||||
if cw > 0 && ch > 0 {
|
||||
lbl = fmt.Sprintf("%d × %d", cw, ch)
|
||||
}
|
||||
list = append(list, cand{res: res, label: lbl, hidpi: hidpi})
|
||||
sizes := presetSizes16x9
|
||||
if math.Abs(float64(primary.Width)/float64(primary.Height)-1.6) < 0.08 {
|
||||
sizes = presetSizes16x10
|
||||
}
|
||||
|
||||
switch {
|
||||
case w >= 3440:
|
||||
// 4K / ultrawide 4K host: 3840x2160 gives razor-sharp 2x HiDPI (1920x1080 logical).
|
||||
rec = "3840x2160"
|
||||
add("3840x2160", true)
|
||||
add("2880x1800", true)
|
||||
add("2560x1440", scale >= 150)
|
||||
add("1920x1080", false)
|
||||
case w >= 2880:
|
||||
// 3K / 2880x1800 laptop or 3200x1800 display.
|
||||
if is16by10 {
|
||||
rec = "2880x1800"
|
||||
add("2880x1800", true)
|
||||
add("2560x1600", scale >= 150)
|
||||
add("2560x1440", false)
|
||||
add("1920x1080", false)
|
||||
} else {
|
||||
rec = "2560x1440"
|
||||
add("2560x1440", scale >= 150)
|
||||
add("2880x1800", true)
|
||||
add("3840x2160", true)
|
||||
add("1920x1080", false)
|
||||
}
|
||||
case w >= 2560:
|
||||
// 2K / QHD (2560x1440 or 2560x1600): match aspect ratio cleanly.
|
||||
if is16by10 {
|
||||
rec = "2560x1600"
|
||||
add("2560x1600", scale >= 150)
|
||||
add("2880x1800", true)
|
||||
add("2560x1440", false)
|
||||
add("1920x1080", false)
|
||||
} else {
|
||||
rec = "2560x1440"
|
||||
add("2560x1440", scale >= 150)
|
||||
add("2880x1800", true)
|
||||
add("1920x1080", false)
|
||||
add("3840x2160", true)
|
||||
}
|
||||
case w >= 1920:
|
||||
// 1080p / 1920x1200 display.
|
||||
if is16by10 {
|
||||
rec = "1920x1200"
|
||||
add("1920x1200", false)
|
||||
add("1920x1080", false)
|
||||
add("2560x1600", true)
|
||||
add("2880x1800", true)
|
||||
} else {
|
||||
rec = "1920x1080"
|
||||
add("1920x1080", false)
|
||||
add("2560x1440", true)
|
||||
add("2880x1800", true)
|
||||
add("1600x900", false)
|
||||
}
|
||||
default:
|
||||
// Smaller laptops (e.g., 1366x768 or 1600x900).
|
||||
rec = "1600x900"
|
||||
if w >= 1280 && h >= 720 {
|
||||
native := fmt.Sprintf("%dx%d", w, h)
|
||||
rec = native
|
||||
add(native, false)
|
||||
}
|
||||
add("1600x900", false)
|
||||
add("1920x1080", false)
|
||||
}
|
||||
|
||||
// If host native resolution is standard even dimensions and not yet listed, offer it too.
|
||||
if w >= 1280 && h >= 720 && w%2 == 0 && h%2 == 0 {
|
||||
native := fmt.Sprintf("%dx%d", w, h)
|
||||
hasNative := false
|
||||
for _, c := range list {
|
||||
if c.res == native {
|
||||
hasNative = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasNative && len(list) < 5 {
|
||||
list = append(list, cand{res: native, label: fmt.Sprintf("%d × %d", w, h), hidpi: scale >= 150})
|
||||
var fit [][2]int
|
||||
for i := len(sizes) - 1; i >= 0; i-- {
|
||||
if sizes[i][0] <= usableW && sizes[i][1] <= usableH {
|
||||
fit = append(fit, sizes[i])
|
||||
}
|
||||
}
|
||||
if len(fit) == 0 {
|
||||
fit = [][2]int{sizes[0]} // a screen smaller than every size: the window shrinks to fit
|
||||
}
|
||||
if len(fit) > maxDisplayPresetCount {
|
||||
fit = fit[:maxDisplayPresetCount]
|
||||
}
|
||||
|
||||
out := make([]DisplayPreset, 0, len(list))
|
||||
for _, c := range list {
|
||||
out := make([]DisplayPreset, 0, len(fit))
|
||||
rec := -1
|
||||
for i, sz := range fit {
|
||||
hidpi := GuestStartsHiDPI(sz[0], sz[1], scale)
|
||||
if hidpi && rec < 0 {
|
||||
rec = i
|
||||
}
|
||||
out = append(out, DisplayPreset{
|
||||
Resolution: c.res,
|
||||
Label: c.label,
|
||||
HiDPI: c.hidpi,
|
||||
Recommended: c.res == rec,
|
||||
Resolution: fmt.Sprintf("%dx%d", sz[0], sz[1]),
|
||||
Label: fmt.Sprintf("%d × %d", sz[0], sz[1]),
|
||||
HiDPI: hidpi,
|
||||
})
|
||||
}
|
||||
return out, rec
|
||||
if rec < 0 {
|
||||
rec = 0
|
||||
}
|
||||
out[rec].Recommended = true
|
||||
return out, out[rec].Resolution
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package host
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -9,42 +10,93 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGuestStartsHiDPI(t *testing.T) {
|
||||
cases := []struct {
|
||||
w, h, scale int
|
||||
want bool
|
||||
}{
|
||||
{1920, 1080, 200, false}, // too small at any scale: the case of a 1x desktop on a 200% screen
|
||||
{2048, 1536, 150, true}, // smallest HiDPI window above 160 ppi
|
||||
{2047, 1536, 200, false},
|
||||
{2560, 1440, 200, false}, // 1440 high is under 1536
|
||||
{2560, 1600, 150, true},
|
||||
{2880, 1800, 145, false}, // 145% is exactly 160 ppi, not above
|
||||
{2880, 1800, 125, false},
|
||||
{3200, 1800, 100, false},
|
||||
{3840, 2160, 100, true}, // any density from 3840 x 2160
|
||||
{3840, 2152, 100, false},
|
||||
{2880, 1800, 0, false}, // unknown scale counts as 1x
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := GuestStartsHiDPI(c.w, c.h, c.scale); got != c.want {
|
||||
t.Errorf("GuestStartsHiDPI(%d, %d, %d%%) = %v, want %v", c.w, c.h, c.scale, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecommendDisplayPresets(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
primary *DisplayInfo
|
||||
wantRec string
|
||||
wantHi bool
|
||||
name string
|
||||
primary *DisplayInfo
|
||||
wantRec string
|
||||
wantHi bool
|
||||
wantSizes []string
|
||||
advice string
|
||||
}{
|
||||
{
|
||||
name: "4K at 150%",
|
||||
primary: &DisplayInfo{Width: 3840, Height: 2160, ScalePct: 150, Primary: true},
|
||||
wantRec: "3840x2160",
|
||||
wantHi: true,
|
||||
name: "3072x1920 at 200%, as a Retina remote display",
|
||||
primary: &DisplayInfo{Width: 3072, Height: 1920, ScalePct: 200, WorkWidth: 3072, WorkHeight: 1824},
|
||||
wantRec: "2560x1600",
|
||||
wantHi: true,
|
||||
wantSizes: []string{"2560x1600", "1920x1200", "1680x1050", "1280x800"},
|
||||
},
|
||||
{
|
||||
name: "2K 16:9 at 125%",
|
||||
primary: &DisplayInfo{Width: 2560, Height: 1440, ScalePct: 125, Primary: true},
|
||||
wantRec: "2560x1440",
|
||||
wantHi: false,
|
||||
name: "4K at 150%",
|
||||
primary: &DisplayInfo{Width: 3840, Height: 2160, ScalePct: 150, WorkWidth: 3840, WorkHeight: 2088},
|
||||
wantRec: "3200x1800",
|
||||
wantHi: true,
|
||||
wantSizes: []string{"3200x1800", "2880x1620", "2560x1440", "1920x1080"},
|
||||
},
|
||||
{
|
||||
name: "2.5K 16:10 at 150%",
|
||||
primary: &DisplayInfo{Width: 2560, Height: 1600, ScalePct: 150, Primary: true},
|
||||
wantRec: "2560x1600",
|
||||
wantHi: true,
|
||||
// No window fits 3840 x 2160, the one size HiDPI at 100%; full screen is.
|
||||
name: "4K at 100%",
|
||||
primary: &DisplayInfo{Width: 3840, Height: 2160, ScalePct: 100, WorkWidth: 3840, WorkHeight: 2112},
|
||||
wantRec: "3200x1800",
|
||||
wantHi: false,
|
||||
wantSizes: []string{"3200x1800", "2880x1620", "2560x1440", "1920x1080"},
|
||||
advice: HiDPIAdviceFullscreen,
|
||||
},
|
||||
{
|
||||
name: "1080p at 100%",
|
||||
primary: &DisplayInfo{Width: 1920, Height: 1080, ScalePct: 100, Primary: true},
|
||||
wantRec: "1920x1080",
|
||||
wantHi: false,
|
||||
name: "2.5K 16:10 laptop at 150%",
|
||||
primary: &DisplayInfo{Width: 2560, Height: 1600, ScalePct: 150, WorkWidth: 2560, WorkHeight: 1528},
|
||||
wantRec: "1920x1200",
|
||||
wantHi: false,
|
||||
wantSizes: []string{"1920x1200", "1680x1050", "1280x800"},
|
||||
// The whole 2560 x 1600 screen is HiDPI at 150%.
|
||||
advice: HiDPIAdviceFullscreen,
|
||||
},
|
||||
{
|
||||
name: "nil fallback",
|
||||
primary: nil,
|
||||
wantRec: "1920x1080",
|
||||
wantHi: false,
|
||||
name: "1080p at 100%, work area unknown",
|
||||
primary: &DisplayInfo{Width: 1920, Height: 1080, ScalePct: 100},
|
||||
wantRec: "1600x900",
|
||||
wantHi: false,
|
||||
wantSizes: []string{"1600x900", "1280x720"},
|
||||
advice: HiDPIAdviceUnavailable,
|
||||
},
|
||||
{
|
||||
name: "2880x1800 laptop at 100%",
|
||||
primary: &DisplayInfo{Width: 2880, Height: 1800, ScalePct: 100, WorkWidth: 2880, WorkHeight: 1752},
|
||||
wantRec: "2560x1600",
|
||||
wantHi: false,
|
||||
wantSizes: []string{"2560x1600", "1920x1200", "1680x1050", "1280x800"},
|
||||
advice: HiDPIAdviceScale,
|
||||
},
|
||||
{
|
||||
name: "nil fallback",
|
||||
primary: nil,
|
||||
wantRec: "1920x1080",
|
||||
wantHi: false,
|
||||
wantSizes: []string{"1920x1080", "2560x1440", "2880x1800"},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -54,23 +106,34 @@ func TestRecommendDisplayPresets(t *testing.T) {
|
||||
if rec != tc.wantRec {
|
||||
t.Fatalf("rec = %q, want %q", rec, tc.wantRec)
|
||||
}
|
||||
if len(presets) < 3 {
|
||||
t.Fatalf("expected >= 3 presets, got %d", len(presets))
|
||||
}
|
||||
var foundRec bool
|
||||
var sizes []string
|
||||
recs := 0
|
||||
for _, p := range presets {
|
||||
sizes = append(sizes, p.Resolution)
|
||||
var w, h int
|
||||
_, _ = fmt.Sscanf(p.Resolution, "%dx%d", &w, &h)
|
||||
scale := 0
|
||||
if tc.primary != nil {
|
||||
scale = tc.primary.ScalePct
|
||||
}
|
||||
if p.HiDPI != (tc.primary != nil && GuestStartsHiDPI(w, h, scale)) {
|
||||
t.Errorf("%s HiDPI = %v disagrees with GuestStartsHiDPI", p.Resolution, p.HiDPI)
|
||||
}
|
||||
if p.Recommended {
|
||||
foundRec = true
|
||||
if p.Resolution != tc.wantRec {
|
||||
t.Fatalf("recommended preset %q != %q", p.Resolution, tc.wantRec)
|
||||
}
|
||||
if p.HiDPI != tc.wantHi {
|
||||
t.Fatalf("recommended preset HiDPI = %v, want %v", p.HiDPI, tc.wantHi)
|
||||
recs++
|
||||
if p.Resolution != tc.wantRec || p.HiDPI != tc.wantHi {
|
||||
t.Errorf("recommended %s HiDPI=%v, want %s HiDPI=%v", p.Resolution, p.HiDPI, tc.wantRec, tc.wantHi)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !foundRec {
|
||||
t.Fatalf("no preset marked recommended")
|
||||
if recs != 1 {
|
||||
t.Errorf("%d presets recommended, want 1", recs)
|
||||
}
|
||||
if fmt.Sprint(sizes) != fmt.Sprint(tc.wantSizes) {
|
||||
t.Errorf("sizes = %v, want %v", sizes, tc.wantSizes)
|
||||
}
|
||||
if got := HiDPIAdvice(tc.primary, presets); got != tc.advice {
|
||||
t.Errorf("HiDPIAdvice = %q, want %q", got, tc.advice)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ var (
|
||||
procGetDC = user32.NewProc("GetDC")
|
||||
procReleaseDC = user32.NewProc("ReleaseDC")
|
||||
|
||||
gdi32 = syscall.NewLazyDLL("gdi32.dll")
|
||||
gdi32 = syscall.NewLazyDLL("gdi32.dll")
|
||||
procGetDeviceCaps = gdi32.NewProc("GetDeviceCaps")
|
||||
|
||||
shcore = syscall.NewLazyDLL("shcore.dll")
|
||||
@@ -34,11 +34,11 @@ type winRect struct {
|
||||
}
|
||||
|
||||
type monitorInfoExW struct {
|
||||
Size uint32
|
||||
Monitor winRect
|
||||
Work winRect
|
||||
Flags uint32
|
||||
Device [32]uint16
|
||||
Size uint32
|
||||
Monitor winRect
|
||||
Work winRect
|
||||
Flags uint32
|
||||
Device [32]uint16
|
||||
}
|
||||
|
||||
type devModeW struct {
|
||||
@@ -116,13 +116,22 @@ func probeDisplays() []DisplayInfo {
|
||||
}
|
||||
|
||||
if w > 0 && h > 0 {
|
||||
// The work area in the same units as the monitor rectangle (pixels for a
|
||||
// DPI-aware process, scaled points otherwise), carried over to w x h.
|
||||
var workW, workH int
|
||||
if monW, monH := int(mi.Monitor.Right-mi.Monitor.Left), int(mi.Monitor.Bottom-mi.Monitor.Top); monW > 0 && monH > 0 {
|
||||
workW = int(mi.Work.Right-mi.Work.Left) * w / monW
|
||||
workH = int(mi.Work.Bottom-mi.Work.Top) * h / monH
|
||||
}
|
||||
displays = append(displays, DisplayInfo{
|
||||
Name: name,
|
||||
Width: w,
|
||||
Height: h,
|
||||
ScalePct: scalePct,
|
||||
RefreshHz: refresh,
|
||||
Primary: mi.Flags&monitorInfoPrimary != 0,
|
||||
Name: name,
|
||||
Width: w,
|
||||
Height: h,
|
||||
ScalePct: scalePct,
|
||||
RefreshHz: refresh,
|
||||
Primary: mi.Flags&monitorInfoPrimary != 0,
|
||||
WorkWidth: workW,
|
||||
WorkHeight: workH,
|
||||
})
|
||||
}
|
||||
return 1
|
||||
|
||||
+11
-8
@@ -35,11 +35,11 @@ type WHPXCapabilities struct {
|
||||
}
|
||||
|
||||
type Report struct {
|
||||
OS string `json:"os"`
|
||||
Arch string `json:"arch"`
|
||||
LogicalCPUs int `json:"logical_cpus"`
|
||||
PhysicalCores int `json:"physical_cores"`
|
||||
HasHybridCores bool `json:"has_hybrid_cores"`
|
||||
OS string `json:"os"`
|
||||
Arch string `json:"arch"`
|
||||
LogicalCPUs int `json:"logical_cpus"`
|
||||
PhysicalCores int `json:"physical_cores"`
|
||||
HasHybridCores bool `json:"has_hybrid_cores"`
|
||||
PCoreCount int `json:"p_core_count"`
|
||||
ECoreCount int `json:"e_core_count"`
|
||||
LPECoreCount int `json:"lpe_core_count,omitempty"`
|
||||
@@ -50,9 +50,9 @@ type Report struct {
|
||||
NonLPEMask uint64 `json:"non_lpe_mask,omitempty"`
|
||||
NonLPEMaskHex string `json:"non_lpe_mask_hex,omitempty"`
|
||||
NonLPELogicalCPUs []int `json:"non_lpe_logical_cpus,omitempty"`
|
||||
TotalRAMGB float64 `json:"total_ram_gb"`
|
||||
AvailRAMGB float64 `json:"avail_ram_gb"`
|
||||
MemoryLoadPct int `json:"memory_load_pct"`
|
||||
TotalRAMGB float64 `json:"total_ram_gb"`
|
||||
AvailRAMGB float64 `json:"avail_ram_gb"`
|
||||
MemoryLoadPct int `json:"memory_load_pct"`
|
||||
// Commit memory: QEMU commits all guest RAM at start (CreateFileMapping), so
|
||||
// a VM needs its memory free in the commit charge, not just in physical RAM.
|
||||
// Measured 2026-11-28: 14.7 GiB commit free with 17.3 GiB physical free, and a
|
||||
@@ -71,6 +71,9 @@ type Report struct {
|
||||
PrimaryDisplay *DisplayInfo `json:"primary_display,omitempty"`
|
||||
RecommendedResolution string `json:"recommended_resolution,omitempty"`
|
||||
DisplayPresets []DisplayPreset `json:"display_presets,omitempty"`
|
||||
HiDPIAdvice string `json:"hidpi_advice,omitempty"` // how to reach HiDPI when no preset does (display.go)
|
||||
FullscreenHiDPI bool `json:"fullscreen_hidpi"` // a borderless window on the primary screen is HiDPI
|
||||
ProcessorScheduling string `json:"processor_scheduling,omitempty"` // "programs" or "background" (scheduling.go)
|
||||
Audio AudioInfo `json:"audio"`
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,9 @@ func Inspect(dataRoot string) Report {
|
||||
rep.Displays = probeDisplays()
|
||||
rep.PrimaryDisplay = PrimaryDisplayOf(rep.Displays)
|
||||
rep.DisplayPresets, rep.RecommendedResolution = RecommendDisplayPresets(rep.PrimaryDisplay)
|
||||
rep.HiDPIAdvice = HiDPIAdvice(rep.PrimaryDisplay, rep.DisplayPresets)
|
||||
rep.FullscreenHiDPI = FullscreenStartsHiDPI(rep.PrimaryDisplay)
|
||||
rep.ProcessorScheduling = probeProcessorScheduling()
|
||||
rep.Audio = ProbeAudio()
|
||||
return rep
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//go:build !windows
|
||||
|
||||
package host
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// ErrOtherProcess: the PID now names a process other than the one expected.
|
||||
var ErrOtherProcess = errors.New("pid belongs to another process")
|
||||
|
||||
// WaitProcessExit is not implemented off Windows; callers fall back to polling.
|
||||
func WaitProcessExit(ctx context.Context, pid uint32, imageSuffix string) error {
|
||||
return errors.ErrUnsupported
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
//go:build windows
|
||||
|
||||
package host
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
procWaitForSingleObject = kernel32.NewProc("WaitForSingleObject")
|
||||
procQueryFullProcessImageNameW = kernel32.NewProc("QueryFullProcessImageNameW")
|
||||
)
|
||||
|
||||
const (
|
||||
processSynchronize = 0x00100000
|
||||
errorInvalidParameter syscall.Errno = 87 // ERROR_INVALID_PARAMETER: no process with that PID
|
||||
waitObject0 = 0x00000000
|
||||
waitTimeoutCode = 0x00000102
|
||||
// waitSliceMs is how long one wait blocks before checking ctx; the exit
|
||||
// itself is reported the moment it happens.
|
||||
waitSliceMs = 1000
|
||||
)
|
||||
|
||||
// ErrOtherProcess: the PID now names a process other than the one expected.
|
||||
var ErrOtherProcess = errors.New("pid belongs to another process")
|
||||
|
||||
// WaitProcessExit blocks until process pid exits and returns nil, or returns
|
||||
// ctx.Err() once ctx ends. A process already gone counts as exited. When
|
||||
// imageSuffix is set the process's image path must end with it (case
|
||||
// insensitive), else ErrOtherProcess: a guard against a reused PID.
|
||||
func WaitProcessExit(ctx context.Context, pid uint32, imageSuffix string) error {
|
||||
if pid == 0 {
|
||||
return errors.New("no pid")
|
||||
}
|
||||
h, _, err := procOpenProcess.Call(uintptr(processSynchronize|processQueryLimitedInfo), 0, uintptr(pid))
|
||||
if h == 0 {
|
||||
if errno, ok := err.(syscall.Errno); ok && errno == errorInvalidParameter {
|
||||
return nil // no such process: it has exited
|
||||
}
|
||||
return fmt.Errorf("open process %d: %w", pid, err)
|
||||
}
|
||||
defer procCloseHandle.Call(h)
|
||||
|
||||
// An exited process another handle keeps alive opens fine but has no
|
||||
// image name to read: settle that first.
|
||||
if r, _, _ := procWaitForSingleObject.Call(h, 0); r == waitObject0 {
|
||||
return nil
|
||||
}
|
||||
if imageSuffix != "" {
|
||||
var buf [syscall.MAX_PATH * 2]uint16
|
||||
size := uint32(len(buf))
|
||||
if r, _, err := procQueryFullProcessImageNameW.Call(h, 0, uintptr(unsafe.Pointer(&buf[0])), uintptr(unsafe.Pointer(&size))); r == 0 {
|
||||
return fmt.Errorf("image name of process %d: %w", pid, err)
|
||||
}
|
||||
if !strings.HasSuffix(strings.ToLower(syscall.UTF16ToString(buf[:size])), strings.ToLower(imageSuffix)) {
|
||||
return ErrOtherProcess
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
r, _, err := procWaitForSingleObject.Call(h, waitSliceMs)
|
||||
switch r {
|
||||
case waitObject0:
|
||||
return nil
|
||||
case waitTimeoutCode:
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("wait for process %d: %w", pid, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
//go:build windows
|
||||
|
||||
package host
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os/exec"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func startPing(t *testing.T, pings string) *exec.Cmd {
|
||||
t.Helper()
|
||||
cmd := exec.Command("ping", "-n", pings, "127.0.0.1")
|
||||
if err := cmd.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = cmd.Process.Kill(); _ = cmd.Wait() })
|
||||
return cmd
|
||||
}
|
||||
|
||||
func TestWaitProcessExitReturnsWhenTheProcessEnds(t *testing.T) {
|
||||
cmd := startPing(t, "30")
|
||||
pid := uint32(cmd.Process.Pid)
|
||||
done := make(chan error, 1)
|
||||
go func() { done <- WaitProcessExit(context.Background(), pid, "ping.exe") }()
|
||||
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
killedAt := time.Now()
|
||||
if err := cmd.Process.Kill(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
select {
|
||||
case err := <-done:
|
||||
if err != nil {
|
||||
t.Fatalf("WaitProcessExit = %v", err)
|
||||
}
|
||||
// The exit is signalled, not found by the next wait slice.
|
||||
if d := time.Since(killedAt); d > 500*time.Millisecond {
|
||||
t.Fatalf("noticed the exit after %v", d)
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("WaitProcessExit did not return after the process was killed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWaitProcessExitStopsWithContext(t *testing.T) {
|
||||
cmd := startPing(t, "30")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 200*time.Millisecond)
|
||||
defer cancel()
|
||||
err := WaitProcessExit(ctx, uint32(cmd.Process.Pid), "")
|
||||
if !errors.Is(err, context.DeadlineExceeded) {
|
||||
t.Fatalf("err = %v, want deadline exceeded", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWaitProcessExitChecksTheImage(t *testing.T) {
|
||||
cmd := startPing(t, "30")
|
||||
err := WaitProcessExit(context.Background(), uint32(cmd.Process.Pid), "qemu-system-x86_64.exe")
|
||||
if !errors.Is(err, ErrOtherProcess) {
|
||||
t.Fatalf("err = %v, want ErrOtherProcess", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWaitProcessExitOnAGoneProcess(t *testing.T) {
|
||||
cmd := exec.Command("cmd", "/c", "exit")
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
// Its PID is free (or, rarely, reused by something that is not ping).
|
||||
if err := WaitProcessExit(ctx, uint32(cmd.Process.Pid), "ping.exe"); err != nil && !errors.Is(err, ErrOtherProcess) {
|
||||
t.Fatalf("err = %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package host
|
||||
|
||||
// Windows "Processor scheduling" (System Properties > Advanced > Performance >
|
||||
// Advanced): Programs gives the foreground window's process longer CPU
|
||||
// quanta, Background services gives every process the same fixed quanta.
|
||||
const (
|
||||
SchedulingPrograms = "programs"
|
||||
SchedulingBackground = "background"
|
||||
)
|
||||
|
||||
// SchedulingFromPrioritySeparation reads the setting from the registry's
|
||||
// Win32PrioritySeparation value: its low two bits are the foreground quantum
|
||||
// boost, which Programs sets (0x26 from that dialog, 0x2 on a fresh install)
|
||||
// and Background services clears (0x18).
|
||||
func SchedulingFromPrioritySeparation(v uint32) string {
|
||||
if v&0x3 != 0 {
|
||||
return SchedulingPrograms
|
||||
}
|
||||
return SchedulingBackground
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//go:build !windows
|
||||
|
||||
package host
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// ErrElevationDeclined: the person said no at the UAC prompt.
|
||||
var ErrElevationDeclined = errors.New("UAC prompt declined")
|
||||
|
||||
func probeProcessorScheduling() string { return "" }
|
||||
|
||||
func OpenPerformanceOptionsElevated() error {
|
||||
return fmt.Errorf("processor scheduling is a Windows setting (current OS: %s)", runtime.GOOS)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package host
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSchedulingFromPrioritySeparation(t *testing.T) {
|
||||
cases := map[uint32]string{
|
||||
0x26: SchedulingPrograms, // Programs, as the dialog writes it
|
||||
0x02: SchedulingPrograms, // a fresh client install
|
||||
0x18: SchedulingBackground, // Background services
|
||||
0x00: SchedulingBackground,
|
||||
}
|
||||
for v, want := range cases {
|
||||
if got := SchedulingFromPrioritySeparation(v); got != want {
|
||||
t.Errorf("0x%02x: %q, want %q", v, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
//go:build windows
|
||||
|
||||
package host
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
regDWORD = 4
|
||||
priorityControlKey = `SYSTEM\CurrentControlSet\Control\PriorityControl`
|
||||
prioritySeparationValue = "Win32PrioritySeparation"
|
||||
// ShellExecuteW's result when the person declines the UAC prompt.
|
||||
seErrAccessDenied = 5
|
||||
)
|
||||
|
||||
// ErrElevationDeclined: the person said no at the UAC prompt.
|
||||
var ErrElevationDeclined = errors.New("UAC prompt declined")
|
||||
|
||||
// probeProcessorScheduling returns SchedulingPrograms or SchedulingBackground,
|
||||
// or "" where the value cannot be read. Reading needs no elevation.
|
||||
func probeProcessorScheduling() string {
|
||||
v, ok := regReadDWORD(hkeyLocalMachine, priorityControlKey, prioritySeparationValue)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return SchedulingFromPrioritySeparation(v)
|
||||
}
|
||||
|
||||
// OpenPerformanceOptionsElevated opens System Properties' Performance Options
|
||||
// through a UAC prompt, so the processor scheduling choice saves without a
|
||||
// second prompt. It returns once the dialog is launched.
|
||||
func OpenPerformanceOptionsElevated() error {
|
||||
verb, _ := syscall.UTF16PtrFromString("runas")
|
||||
file, _ := syscall.UTF16PtrFromString("SystemPropertiesPerformance.exe")
|
||||
r, _, err := procShellExecuteW.Call(0, uintptr(unsafe.Pointer(verb)), uintptr(unsafe.Pointer(file)), 0, 0, 1 /* SW_SHOWNORMAL */)
|
||||
switch {
|
||||
case r == seErrAccessDenied:
|
||||
return ErrElevationDeclined
|
||||
case r <= 32:
|
||||
return fmt.Errorf("ShellExecuteW runas SystemPropertiesPerformance failed (code %d): %w", r, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func regReadDWORD(root uintptr, subKey, valueName string) (uint32, bool) {
|
||||
sk, err := syscall.UTF16PtrFromString(subKey)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
var hKey uintptr
|
||||
if r, _, _ := procRegOpenKeyExW.Call(root, uintptr(unsafe.Pointer(sk)), 0, keyRead, uintptr(unsafe.Pointer(&hKey))); r != 0 {
|
||||
return 0, false
|
||||
}
|
||||
defer procRegCloseKey.Call(hKey)
|
||||
vn, err := syscall.UTF16PtrFromString(valueName)
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
var typ uint32
|
||||
var v uint32
|
||||
size := uint32(unsafe.Sizeof(v))
|
||||
r, _, _ := procRegQueryValueExW.Call(hKey, uintptr(unsafe.Pointer(vn)), 0, uintptr(unsafe.Pointer(&typ)), uintptr(unsafe.Pointer(&v)), uintptr(unsafe.Pointer(&size)))
|
||||
if r != 0 || typ != regDWORD {
|
||||
return 0, false
|
||||
}
|
||||
return v, true
|
||||
}
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
// Version is the current Reims-Go release version. Release builds may override
|
||||
// it at link time with:
|
||||
//
|
||||
// -ldflags "-X github.com/Nwflower/reims-go/internal/version.Version=v0.2.3"
|
||||
var Version = "v0.2.3"
|
||||
// -ldflags "-X github.com/Nwflower/reims-go/internal/version.Version=v0.2.4"
|
||||
var Version = "v0.2.4"
|
||||
|
||||
const (
|
||||
DefaultReleasesRepo = "Nwflower/Reims-Go"
|
||||
|
||||
Reference in new issue
Block a user