Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
38ede15
fix(textarea): rewrap only the paragraphs an edit changed
t8y2 Nov 23, 2026
4994181
fix(textarea): lay out only the rows in view and follow program edits
t8y2 Nov 23, 2026
08903fb
ci(size): report release sizes instead of failing a fixed limit
t8y2 Nov 23, 2026
5367dd8
ci(dmg): run the real disk image tests only when packaging changes
t8y2 Nov 23, 2026
055db2a
feat(app): add PostAfter for delayed work on the event loop
t8y2 Nov 24, 2026
5e8cf0a
fix(dmg): wait for the owned disk image after a busy detach
caichangqing1120 Nov 24, 2026
5145dd0
ci(dmg): run the signing disk image tests in the disk-image job
caichangqing1120 Nov 24, 2026
836bb00
fix(linux): discard unselected GTK preedit on window focus loss
caichangqing1120 Nov 24, 2026
575283b
fix(windows): don't report the minimized frame as the window position
woliubang256 Nov 24, 2026
aca8795
fix(linux): keep selected text on Fcitx 4 preedit cancellation
caichangqing1120 Nov 24, 2026
9d8321e
feat(app): add a per-page WebView User-Agent suffix
imjakey Nov 24, 2026
8254375
fix(ibus): find the daemon address from WAYLAND_DISPLAY first
t8y2 Nov 24, 2026
8b9d0bd
fix(ui): end an open Select's popup presence
t8y2 Nov 24, 2026
cc61233
docs(release): v0.6.8 notes
t8y2 Nov 24, 2026
a4d4554
docs: point at v0.6.8
t8y2 Nov 24, 2026
0f247cc
feat(gfx): keep square corners square around outset shapes
t8y2 Nov 24, 2026
a7dfe0f
feat(feed): add --patch-max-ratio to drop oversized delta patches
t8y2 Nov 24, 2026
b026682
feat(gfx): add interruptible spring motion for animated values
t8y2 Nov 24, 2026
19ad31a
feat(gfx): add paint-only poses and glided layout moves
t8y2 Nov 24, 2026
9c192c6
feat(gfx): let a glided element start from where a drag set it down
t8y2 Nov 24, 2026
3b1da02
fix(gfx): move the hit regions of a posed element with its paint
t8y2 Nov 24, 2026
d999ee9
feat(base): glide list and tree rows to the place a change gives them
t8y2 Nov 24, 2026
99cc68d
fix(base): glide list rows that carry no hit of their own
t8y2 Nov 24, 2026
78157ea
feat(base): give any element an entrance and an exit
t8y2 Nov 24, 2026
23732a7
feat(gfx): add the pieces of a thrown drag
t8y2 Nov 24, 2026
eba61a6
feat(gfx): turn and scale posed elements, text included
t8y2 Nov 24, 2026
dfba876
feat(base): add Box.Pose for the element tree
t8y2 Nov 24, 2026
133dcae
perf(feed): cut update patches in parallel
t8y2 Nov 24, 2026
8d9ec23
feat(menu): add MenuItem.Toggled to change a setting without closing …
t8y2 Nov 24, 2026
5e86608
feat(app): drag promised files out of a window on every desktop
t8y2 Nov 24, 2026
f1d672b
fix(cli): refresh installable component templates
caichangqing1120 Nov 24, 2026
1778c08
perf(linux): copy only the selected X11 PRIMARY text
caichangqing1120 Nov 24, 2026
c7f8b01
perf(linux): avoid full-document AT-SPI text copies
caichangqing1120 Nov 24, 2026
a40b065
fix(darwin): fail fast when started off the main thread
Ezreal-byte Nov 24, 2026
398d0a9
fix(linux): wait for the clipboard owner just after focus
szmcdull Nov 24, 2026
e203cde
fix(windows): fall back to DIB when the PNG clipboard read fails
DeanCen Nov 24, 2026
cfae170
fix(dbusmenu): stay quiet about the layout a first read builds
t8y2 Nov 25, 2026
802cf5c
fix(textview): paint the requested scroll line in the current frame
1lck Nov 25, 2026
05ef238
test(linux): wait for the X11 clipboard owner to change
caichangqing1120 Nov 25, 2026
eb02d4b
fix(linux): retry interrupted X11 selection waits
caichangqing1120 Nov 25, 2026
76bb5c1
fix(linux): preserve redraws during X11 file drops
caichangqing1120 Nov 25, 2026
db9984c
feat(app): support an initial directory in native folder pickers
lizhuangs Nov 25, 2026
f05ab80
fix(components): honor the textarea custom painter for selected text
imjakey Nov 25, 2026
cc7c3ea
feat(headless): let macOS pick the low-power Metal device on request
shubo83 Nov 25, 2026
0da1fe2
feat(webview): add an entry to open the page developer tools
imjakey Nov 25, 2026
e7c3dd1
refactor(windows): keep the OpenDevToolsWindow vtable index with the …
t8y2 Nov 25, 2026
e938577
fix(linux): keep GTK Wayland preedit on content pointer entry
caichangqing1120 Nov 25, 2026
13b5c06
test(ui): guard against idle tooltip paint allocations
caichangqing1120 Nov 25, 2026
ef49cae
fix(update): keep the installer's Add or Remove Programs entry curren…
t8y2 Nov 25, 2026
f795db1
test(windows): compare signing ACLs by SDDL alias and hand sh an MSYS…
t8y2 Nov 25, 2026
245768e
feat(toast): compact the recipe and add per-toast options
t8y2 Nov 25, 2026
3a0474e
feat(app): add systemauth for Windows Hello and macOS user verification
Ezreal-byte Nov 25, 2026
b9cbce6
feat(docs): generate API tables for every component page
t8y2 Nov 25, 2026
d988684
feat(ui): replace the ID and With twins of a control with one function
t8y2 Nov 25, 2026
f5ca1fb
feat(ui): give each Table column its own title and sort flag
t8y2 Nov 25, 2026
9caa8de
feat(ui): add a step bar (ui/steps)
t8y2 Nov 25, 2026
9c40899
feat(ui): add a labelled-values list (ui/descriptions)
t8y2 Nov 25, 2026
f7b411b
feat(ui): add a timeline (ui/timeline)
t8y2 Nov 25, 2026
cec768a
feat(ui): add a star rating (ui/rate)
t8y2 Nov 25, 2026
a0247ca
feat(ui): add a number field (ui/inputnumber)
t8y2 Nov 25, 2026
7bc763e
feat(ui): add a date picker (ui/datepicker)
t8y2 Nov 25, 2026
1177fee
feat(ui): add a time picker (ui/timepicker)
t8y2 Nov 25, 2026
c87c3f4
feat(ui): add a two-list transfer (ui/transfer)
t8y2 Nov 25, 2026
f6d52d5
docs: list the new opt-in page packages
t8y2 Nov 25, 2026
ae85c2c
feat(style): add a Warning theme color and a shared Status vocabulary
t8y2 Nov 25, 2026
e21bfd7
feat(ui): add a notice that stays in the page (ui/alert)
t8y2 Nov 25, 2026
c01b73c
feat(ui): add a tag (ui/tag)
t8y2 Nov 25, 2026
34c5941
feat(ui): add a breadcrumb (ui/breadcrumb)
t8y2 Nov 25, 2026
ddd25b9
feat(ui): add a card (ui/card)
t8y2 Nov 25, 2026
dad30ab
feat(ui): add an empty state (ui/empty)
t8y2 Nov 25, 2026
f43abe3
feat(ui): add a result page (ui/result)
t8y2 Nov 25, 2026
c7613a2
feat(ui): add a pagination row that assembles itself (ui/pagination)
t8y2 Nov 25, 2026
50b7750
feat(ui): add MaxLength and ShowCount options for text fields
t8y2 Nov 25, 2026
a359cba
docs: list the page packages added since the last list
t8y2 Nov 25, 2026
aab6e6d
docs: list the Warning theme color in the init guide
t8y2 Nov 25, 2026
11aa1b5
feat(ui): show the system's menu for a text field's secondary press
t8y2 Nov 25, 2026
423e389
feat(ui): add a strip of tabs the user can close and add (ui/editable…
t8y2 Nov 25, 2026
70ea3a0
feat(ui): add a column of checkboxes to Table (TableSpec.Checked)
t8y2 Nov 25, 2026
e0e46e3
feat(ui): add a filter button to a Table column (TableColumn.Filterable)
t8y2 Nov 25, 2026
40c75d5
feat(ui): add a warning border to text controls (Warning)
t8y2 Nov 25, 2026
2c8ac55
feat(app): add Config.Transparent and CapabilityTransparentWindow
t8y2 Nov 25, 2026
75c66ab
feat(windows): composite a Transparent window over the desktop
t8y2 Nov 25, 2026
15fafcc
feat(ui): add a light confirmation next to its button (ui/popconfirm)
t8y2 Nov 25, 2026
63a8c2c
feat(ui): color a Progress by its status (Box.Status)
t8y2 Nov 25, 2026
0e200a0
feat(ui): add a busy state to Button (Box.Loading)
t8y2 Nov 25, 2026
575f22f
feat(ui): add a rule that carries a word (ui/divider)
t8y2 Nov 25, 2026
00c9a26
feat(ui): add text cut to a few lines that expands and copies (ui/typ…
t8y2 Nov 25, 2026
c3c060d
feat(ui): add marks to a Slider (Box.Marks)
t8y2 Nov 25, 2026
1529f01
feat(app): report whether a Transparent window is composited, and add…
t8y2 Nov 25, 2026
34fd398
chore(demo): keep transparent-demo to the one window it shows
t8y2 Nov 25, 2026
56a6411
feat(ui): add a busy state to Switch (Box.Loading)
t8y2 Nov 25, 2026
389d956
feat(ui): draw a Progress as a ring (Box.Circle)
t8y2 Nov 25, 2026
bf7eea3
feat(ui): add group headings to a Select (ui.SelectGroups)
t8y2 Nov 25, 2026
a92ba0d
feat(ui): draw a Progress bar in segments (Box.Segments)
t8y2 Nov 25, 2026
c320433
feat(ui/validate): add typed form validation rules
t8y2 Nov 25, 2026
aa3f0e3
feat(ui): route files dragged from the system to page areas
t8y2 Nov 25, 2026
5b5e063
feat(ui/upload): add an upload area with a file list
t8y2 Nov 25, 2026
5c196b2
fix(ci): name new components in zh, skip headless tests on js, compar…
t8y2 Nov 25, 2026
b2568fe
feat(ui): add anchor and comment page controls
t8y2 Nov 25, 2026
b3f5a84
fix(docs): file the comment page under the existing Data Display cate…
t8y2 Nov 25, 2026
cb9df66
docs(website): add English copy for the new component pages
t8y2 Nov 25, 2026
a5f403e
feat(ui/imagepreview): add an image preview dialog
t8y2 Nov 25, 2026
9d7590a
fix(ci): skip path-based file drop tests on the browser target
t8y2 Nov 25, 2026
64ff0f3
feat(ui/mentions): add a text field that offers mentions after a trigger
t8y2 Nov 25, 2026
2f50922
feat(ui/tour): add a guided tour over the page's controls
t8y2 Nov 25, 2026
5d0ec18
feat(ui): show a spinner on a tree branch whose children are loading
t8y2 Nov 25, 2026
ac665a8
fix(cmd/viva): regenerate the tree installer template
t8y2 Nov 25, 2026
652ee6e
merge: sync upstream main (ac665a8f) into fork
xiaoyumuxi Nov 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
49 changes: 38 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
code: ${{ steps.paths.outputs.code }}
diskimage: ${{ steps.paths.outputs.diskimage }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -38,14 +39,16 @@ jobs:
# A release tag always runs the whole gate: the tag is what ships, so
# nothing about its contents may skip a check.
case "${{ github.ref }}" in
refs/tags/*) echo "code=true" >> "$GITHUB_OUTPUT"; exit 0 ;;
refs/tags/*) printf 'code=true\ndiskimage=true\n' >> "$GITHUB_OUTPUT"; exit 0 ;;
esac
base="${{ github.event.pull_request.base.sha }}"
[ -n "$base" ] || base="${{ github.event.before }}"
code=true
diskimage=true
if [ -n "$base" ] && git cat-file -e "$base^{commit}" 2>/dev/null; then
git diff --name-only --no-renames "$base" HEAD > "$RUNNER_TEMP/changed"
code=false
diskimage=false
while IFS= read -r file; do
case "$file" in
# Nothing here can change what the gate builds, runs or measures.
Expand All @@ -54,15 +57,20 @@ jobs:
*.md | docs/* | LICENSE | NOTICE | .github/ISSUE_TEMPLATE/*) ;;
*) code=true ;;
esac
case "$file" in
# What makes or tests a disk image: the disk-image job.
tools/dmg/* | tools/appbundle/* | cmd/viva/package* | go.mod | go.sum | .github/workflows/ci.yml) diskimage=true ;;
esac
done < "$RUNNER_TEMP/changed"
else
echo "no base commit to compare with; running the gate" >&2
fi
echo "code=$code" >> "$GITHUB_OUTPUT"
echo "diskimage=$diskimage" >> "$GITHUB_OUTPUT"
{
echo "### changed files"
head -50 "$RUNNER_TEMP/changed" 2>/dev/null | sed 's/^/ /' || true
echo "code=$code"
echo "code=$code diskimage=$diskimage"
} >> "$GITHUB_STEP_SUMMARY"

# Formatting and the Linux type-check of every package. Both are the same on
Expand Down Expand Up @@ -174,7 +182,7 @@ jobs:
run: |
sudo apt-get install -y xvfb libxcb-shape0 libgtk-3-0 ||
{ sudo apt-get update && sudo apt-get install -y xvfb libxcb-shape0 libgtk-3-0; }
xvfb-run -a -s '-screen 0 1280x1024x24 -noreset' go test ./internal/platform/linux -run '^Test(PreviewNativeX11Contract|NotificationNativeX11|TrayWindowQueuedRedrawBeforeInput|TrayWindowRepaintsLaterExposure)$' -count=1 -v
xvfb-run -a -s '-screen 0 1280x1024x24 -noreset' go test ./internal/platform/linux -run '^Test(PreviewNativeX11Contract|NotificationNativeX11|TrayWindowQueuedRedrawBeforeInput|TrayWindowRepaintsLaterExposure|AFileDragOutReachesAnotherClient)$' -count=1 -v
GDK_BACKEND=x11 VIVA_TEST_GTK_NOTIFICATION=1 xvfb-run -a go test -tags vivagtk ./internal/platform/linux -run '^TestGTKNotificationFocusHints$' -count=1 -v
- name: Native X11 global shortcut
env:
Expand Down Expand Up @@ -367,6 +375,8 @@ jobs:
# WARP is a Windows API: this cannot run anywhere else. The file icon and
# native structure ABI tests are here for the same reason: they build only
# on Windows.
- name: directory picker initial location
run: go test ./internal/platform/windows ./app -run '^Test(FileDialogInitialDirectory|DriverInterceptsOpenDirectory)$' -count=1 -v
- name: Material contracts and controls (WARP)
run: go test ./internal/platform/windows ./ui ./components ./headless ./app -run 'Test(Backdrop|WindowBackdrop|OpeningMaximized|Notification|TaskbarCreated|CompositionClear|CompositionFallback|CompositionCreation|CustomBackdrop|AcrylicAccent|LegacyAcrylic|RoundedOutline|Translucent|MonospaceFamilies|FontWeights|(The)?MonoWeights|(The)?InterfaceWeights|EveryListedFamilyResolves|EngineReportsTheFontsUnderline|AlwaysOnTop|SaveDialogCheckbox|FileIcon|NativeStructureABI|ResizePresents|WindowSwapChain|LiveResize|FlipWindowResize|RedrawWaits|ContinuousRedraw|NoOpFrame|SameSize|ZeroSize|ResizeTimer|RedrawQueue|NativeRedrawMessage|CompositionSupersededFrame|DragPreview|QueuedMenuKeysLeaveTerminalCompositionWithItsOwner|MenuKeysPreserveSystemChordsAndShift|TerminalMenuStopsCapturingWhenWindowLosesFocus|DisabledIMEOffersMenuShortcutDuringComposition)' -count=1 -v
- name: Web view partitions
Expand All @@ -385,6 +395,8 @@ jobs:
run: go test ./internal/platform/windows -run '^TestNativeGlobalShortcutRegistration$' -count=1 -v
- name: Native Direct2D text origins and hidden labels
run: go test ./internal/platform/windows -run '^Test(DirectTextLayoutOriginByValue|HiddenNativeEditorDoesNotDrawColorEmoji|TextEngineRasterizesProportionalText)$' -count=1 -v
- name: Promised file drag
run: go test ./internal/platform/windows -run '^Test(ThePromiseDataObject|ThePromiseStream|ThePromiseEnumerator|PromiseNames)' -count=1 -v
# The installer contracts, including WinVerifyTrust's struct layout, only
# compile and run on Windows.
- name: Update installer contracts
Expand Down Expand Up @@ -440,14 +452,34 @@ jobs:
- name: compare
run: go run ./tools/perfhistory compare -threshold 0.20 -min-ns 100 /tmp/base.txt < /tmp/head.txt

# The tests that make real disk images with hdiutil. The disk image service of a
# shared macOS runner fails now and then whatever the code does (busy, not
# mountable, permission denied), so these run when a change can affect how an
# image is made, not on every change; the darwin job skips them. Their logic
# is tested on every change against a stand-in hdiutil.
disk-image:
needs: changes
if: needs.changes.outputs.diskimage == 'true'
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: disk images made with hdiutil
env:
VIVA_DISK_IMAGE_TESTS: "1"
run: go test ./tools/dmg ./cmd/viva -run 'DiskImage|BuiltImage' -count=1

# The single check to require in branch protection. It reports success when
# every job this change needed passed and the rest were skipped, so a
# documentation-only pull request is green without running anything and a
# change that skipped a job by path filter can never sit pending forever.
passed:
name: ci passed
if: always()
needs: [changes, lint, dev-attributes, cross-vet, web, web-browser, test, darwin, windows-materials, windows-arm64-text, benchmarks]
needs: [changes, lint, dev-attributes, cross-vet, web, web-browser, test, darwin, disk-image, windows-materials, windows-arm64-text, benchmarks, size]
runs-on: ubuntu-latest
steps:
- name: every job this change needed passed
Expand All @@ -462,17 +494,12 @@ jobs:
esac
done

# Release sizes on every change, without blocking: hello is over its own
# alarm limit while the ui/components boundary decision (see
# docs/benchmarks/2026-11-12-size-attribution-darwin-arm64.md) is open, so
# the job records the number on each run and the hard limit returns with
# the boundary. Builds the same targets benchmarks/size.sh checks on a
# release machine; remove continue-on-error when the limit is honest again.
# Release sizes on every change, reported in the job summary to watch across
# changes; benchmarks/size.sh judges no size against a fixed limit.
size:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: macos-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/text-input.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ jobs:
if: runner.os == 'Linux'
run: |
for backend in x11 wayland; do
tests='^TestGTKNativeSeatKeyboardAfterContentClick$'
tests='^TestGTKNative(SeatKeyboardAfterContentClick|InputMethodWindowTeardown)$'
if [ "$backend" = wayland ]; then
tests='^Test(GTKNative(SeatKeyboardAfterContentClick|WaylandSeatHideShow|WaylandWidgetExternalFocus|WaylandAttachFailure|WaylandInputRegions)|GTKWaylandWindowAttrLP64Layout)$'
tests='^Test(GTKNative(SeatKeyboardAfterContentClick|InputMethodWindowTeardown|WaylandSeatHideShow|WaylandPointerKeepsFcitxPreedit|WaylandWidgetExternalFocus|WaylandAttachFailure|WaylandInputRegions)|GTKWaylandWindowAttrLP64Layout)$'
fi
xvfb-run -a -s '-screen 0 800x600x24' env VIVA_GTK_SEAT_NATIVE=1 VIVA_GTK_SEAT_REMAP=1 VIVA_GTK_NATIVE_WIDGET_FOCUS=1 VIVA_GTK_ATTACH_NATIVE=1 VIVA_GTK_REGION_NATIVE=1 VIVA_GTK_IME_NATIVE=1 VIVA_FCITX_ENGINE=pinyin G_DEBUG=fatal-criticals VIVA_FCITX_TEST_BINARY="$RUNNER_TEMP/viva-ibus-frontend.test" VIVA_IBUS_TEST_RUN="$tests" sh internal/ibus/testdata/native-fcitx-service.sh "$backend"
xvfb-run -a -s '-screen 0 800x600x24' env VIVA_GTK_SEAT_NATIVE=1 VIVA_GTK_SEAT_REMAP=1 VIVA_GTK_NATIVE_WIDGET_FOCUS=1 VIVA_GTK_ATTACH_NATIVE=1 VIVA_GTK_REGION_NATIVE=1 VIVA_GTK_CLOSE_NATIVE=1 VIVA_GTK_IME_NATIVE=1 VIVA_FCITX_ENGINE=pinyin G_DEBUG=fatal-criticals VIVA_FCITX_TEST_BINARY="$RUNNER_TEMP/viva-ibus-frontend.test" VIVA_IBUS_TEST_RUN="$tests" sh internal/ibus/testdata/native-fcitx-service.sh "$backend"
done
- name: Linux text callback ordering
if: runner.os == 'Linux'
Expand All @@ -191,7 +191,7 @@ jobs:
run: go test ./internal/platform/linux -run '^TestLinux(TextInputAlignmentMatchesGlyphCaretUnderlineAndPointer|RightToLeftAlignmentUsesLineWidthNotLogicalEndCaret|CandidateWindowFollowsAlignmentWhenNativeOverlaysAreHidden)$' -count=1
- name: GTK input method teardown ordering
if: runner.os == 'Linux'
run: go test -tags vivagtk ./internal/platform/linux -run '^TestGTKDestroyDetachesInputMethodBeforeNativeWidget$' -count=1 -v
run: go test -tags vivagtk ./internal/platform/linux -run '^TestGTK(DestroyDetachesInputMethodBeforeNativeWidget|WaylandUnmapEndsPointerActivatedIME|WaylandIMECursorTracksContentOrigin)$' -count=1 -v
- name: Linux clipboard, compositing and icon contracts
if: runner.os == 'Linux'
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Wayland client and needs the system's GTK 3), and a Vulkan loader and driver for
and DirectWrite. Viva loads the system libraries at runtime and bundles none of
them.

The current release is `v0.6.7`; name it explicitly (`@v0.6.7`) to pin it. Guides,
The current release is `v0.6.8`; name it explicitly (`@v0.6.8`) to pin it. Guides,
the API reference, and a component catalog with live previews live in
[`website/`](website/); run it with `npm run dev` there, or read them on
[vivaui.dev](https://vivaui.dev/en/), which is also available in
Expand Down
2 changes: 1 addition & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ viva dev . # hot reload: save a file, the window updates and keeps its st

环境要求:Go 1.26 或更新版本(缺失时 viva 会自己下载)。macOS 上需要 Xcode 命令行工具,因为 Viva 通过 cgo 访问 Cocoa 和 Metal;Linux 上需要带系统 XCB、Pango 和 Cairo 库的 X11(可选的 GTK 3 外壳用 `-tags vivagtk` 构建,是原生 Wayland 客户端,需要系统的 GTK 3),Vulkan 加载库和驱动用于 GPU 加速,缺失时窗口用 CPU 渲染;Windows 上需要 Win32、Direct3D 11 和 DirectWrite。Viva 在运行时加载系统库,自身不捆绑任何一个。

当前版本是 `v0.6.7`;要固定版本就写明(`@v0.6.7`)。指南、API 参考和带实时预览的组件目录在 [`website/`](website/) 里,本地用 `npm run dev` 运行;也已经发布在 [vivaui.dev](https://vivaui.dev/zh/)。
当前版本是 `v0.6.8`;要固定版本就写明(`@v0.6.8`)。指南、API 参考和带实时预览的组件目录在 [`website/`](website/) 里,本地用 `npm run dev` 运行;也已经发布在 [vivaui.dev](https://vivaui.dev/zh/)。

下面的一切描述的都是这个仓库:它的测量、它自己的程序,以及如何开发框架本身,而不是如何用框架。

Expand Down
26 changes: 25 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ type Config struct {
// supplied it. Without one the panel is centered on the screen.
Anchor StatusAnchor
ClearColor Color
// Transparent composites the window over the desktop: the part of the canvas
// left at ClearColor's alpha shows what is behind the window. It makes a
// ClearColor of zero mean fully transparent instead of the default fill, and
// is how a window asks for per-pixel transparency at creation. Ask
// CapabilityTransparentWindow first; where it is missing the window is
// opaque and takes the default fill. On Linux the window must be a
// WindowCustomTitlebar one and a compositing manager must own the screen;
// OnTransparentChange says whether it did.
Transparent bool
// OnTransparentChange is told once the window exists whether the desktop
// really shows through it. It reports false where Transparent could not be
// honored at run time: a Linux desktop with no compositing manager, or a
// window kind without an alpha surface. A window that asked for Transparent
// then paints as if it were opaque. It runs on the window thread; update
// paint state without blocking, and schedule a repaint.
OnTransparentChange func(active bool)
// WindowBorderColor is read at every paint and names the color of the
// border Windows 11 draws around a custom-titlebar window. The system
// composites that border against what is behind the window rather than
Expand Down Expand Up @@ -266,6 +282,11 @@ type Config struct {
// application-owned native editor. Returning nil disables native editing.
// The callback runs on the window thread after painting.
TextInput TextInputProvider
// TextMenu asks for the menu a text field opens on a secondary press: the
// system's own on macOS and Windows, with these words. Nil leaves it to the
// page, which draws one of its own where the platform has none to show.
// The words are read when the menu opens, so a language change reaches it.
TextMenu *TextMenuLabels
// OnCloseRequest, when set, intercepts window close (the red traffic
// light). Call allow to close the window immediately or later; never
// calling it keeps the window open.
Expand Down Expand Up @@ -337,8 +358,11 @@ func (config Config) normalize() (Config, error) {
return Config{}, err
}

if !Supports(CapabilityTransparentWindow) {
config.Transparent = false
}
color := config.ClearColor
if color == (Color{}) && config.WindowMode != windowPreview {
if color == (Color{}) && config.WindowMode != windowPreview && !config.Transparent {
config.ClearColor = Color{Red: 0.055, Green: 0.065, Blue: 0.09, Alpha: 1}
} else if !validColor(color) {
return Config{}, fmt.Errorf("app: clear color components must be between 0 and 1")
Expand Down
23 changes: 23 additions & 0 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,26 @@ func TestSystemIntegrationValidation(t *testing.T) {
t.Fatal("SendNotification accepted empty notification")
}
}

func TestTransparentWindowKeepsAZeroClearColorWhereSupported(t *testing.T) {
config, err := (Config{Transparent: true}).normalize()
if err != nil {
t.Fatal(err)
}
if Supports(CapabilityTransparentWindow) {
if !config.Transparent || config.ClearColor != (Color{}) {
t.Fatalf("a transparent window lost its clear color: %+v", config)
}
return
}
if config.Transparent || config.ClearColor.Alpha != 1 {
t.Fatalf("an unsupported transparent window must stay opaque: %+v", config)
}
}

func TestOpaqueWindowKeepsTheDefaultFill(t *testing.T) {
config, err := (Config{}).normalize()
if err != nil || config.Transparent || config.ClearColor.Alpha != 1 {
t.Fatalf("a window without Transparent must stay opaque: %+v, %v", config, err)
}
}
32 changes: 32 additions & 0 deletions app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"sync"
"sync/atomic"
"time"

"github.com/vivaui/viva/gfx"
"github.com/vivaui/viva/keymap"
Expand Down Expand Up @@ -73,6 +74,37 @@ func (application *Application) Post(fn func()) {
application.host.Post(fn)
}

// PostAfter is Post after a delay: fn runs on the event-loop thread once d has
// passed, through the same host post as Post. It does not wait for a window to
// paint, so a hidden, minimized, or covered window still runs the work on time;
// anything it changes is read by the next wake or paint that comes.
//
// A non-positive d posts on the next loop turn. The returned stop cancels the
// call: after stop returns fn will not start, and stop is idempotent and safe
// from any goroutine. Each call owns one timer until fn runs or stop is called;
// PostAfter starts no goroutine, and an application that never calls it owns no
// timer.
func (application *Application) PostAfter(d time.Duration, fn func()) (stop func()) {
if application == nil || application.host == nil || fn == nil {
return func() {}
}
if d < 0 {
d = 0
}
var stopped atomic.Bool
timer := time.AfterFunc(d, func() {
application.Post(func() {
if !stopped.Load() {
fn()
}
})
})
return func() {
stopped.Store(true)
timer.Stop()
}
}

// Window is one independently retained native window. Close is idempotent and
// may be called from a window callback or another goroutine; the platform
// adapter performs the actual close on its native event-loop thread.
Expand Down
2 changes: 2 additions & 0 deletions app/application_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
// RunApplication starts the native application loop. start runs once on the
// locked native event-loop thread and must open at least one window. The call
// blocks until the final window closes or a platform error terminates the loop.
// On macOS, call runtime.LockOSThread in an init function in package main and
// start the native application from main to satisfy AppKit's main-thread requirement.
func RunApplication(start func(*Application) error) error {
attendFaults()
if applicationRunner != nil {
Expand Down
44 changes: 44 additions & 0 deletions app/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"runtime"
"testing"
"time"

"github.com/vivaui/viva/gfx"
"github.com/vivaui/viva/keymap"
Expand Down Expand Up @@ -577,3 +578,46 @@ func TestPostDelegatesToTheHost(t *testing.T) {
var nilApplication *Application
nilApplication.Post(func() { t.Fatal("a nil application ran work") })
}

// PostAfter hands the work to the host's loop once the delay has passed, not on
// the caller's goroutine.
func TestPostAfterRunsTheWorkOnTheHost(t *testing.T) {
host := &fakeHost{}
application := &Application{host: host}
ran := make(chan struct{}, 1)
stop := application.PostAfter(time.Millisecond, func() { ran <- struct{}{} })
select {
case <-ran:
case <-time.After(time.Second):
t.Fatal("the host did not run the delayed work")
}
stop() // idempotent
stop()
}

// Stop takes back a call that has not started: the loop never runs it.
func TestPostAfterStopPreventsTheWork(t *testing.T) {
host := &fakeHost{}
application := &Application{host: host}
ran := make(chan struct{}, 1)
stop := application.PostAfter(50*time.Millisecond, func() { ran <- struct{}{} })
stop()
select {
case <-ran:
t.Fatal("stopped work ran")
case <-time.After(150 * time.Millisecond):
}

var nilApplication *Application
stop = nilApplication.PostAfter(time.Millisecond, func() { t.Fatal("a nil application ran work") })
stop()
}

func BenchmarkPostAfterStop(b *testing.B) {
application := &Application{host: &fakeHost{}}
b.ReportAllocs()
for b.Loop() {
stop := application.PostAfter(time.Hour, func() {})
stop()
}
}
2 changes: 2 additions & 0 deletions app/backend_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ func runNative(config platform.Config) error { return darwin.Run(config) }
func runNativeApplication(start platform.ApplicationStart) error {
return darwin.RunApplication(start)
}

func checkNativeApplicationThread() error { return darwin.CheckApplicationThread() }
7 changes: 7 additions & 0 deletions app/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ const (
// picture on the clipboard, completing before the call returns on a desktop
// and on the event loop in a browser.
CapabilityClipboardImageWriteAsync
// CapabilityFileDrag means files can be taken out of a window, by path
// (StartFileDrag) or by produced content (StartFilePromiseDrag). A platform
// without it can still copy files to the clipboard.
CapabilityFileDrag
// CapabilityTransparentWindow means Config.Transparent can composite a
// window over the desktop; without it the window is opaque.
CapabilityTransparentWindow
)

// Capabilities is a set of platform integrations.
Expand Down
Loading
Loading