Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
89787db
feat(ui): add statistic, input tag, autocomplete and indicator controls
t8y2 Nov 26, 2026
ab8b9c1
feat(ui/overflowlist): add a toolbar row that folds into a More menu
t8y2 Nov 26, 2026
56f9fe3
fix(windows): draw fallbacks from registered fonts
t8y2 Nov 26, 2026
40c51dd
perf(app): diff each paint's hits against the published ones once
t8y2 Nov 26, 2026
38dd048
fix(text): read grapheme context from the leaves and skip bidi in LTR…
t8y2 Nov 26, 2026
ccd13a3
fix(render): apply mixed delete and insert batches without a rebuild
t8y2 Nov 26, 2026
0c822d2
fix(render): release batch scratch once the page shrinks
t8y2 Nov 26, 2026
89e823c
test(windows): check incremental frames draw what a rebuild draws
t8y2 Nov 26, 2026
ccccd88
feat(ui): select and copy read-only text in a TextSelectionArea
t8y2 Nov 26, 2026
d5b05cd
test(ci): require the Windows offscreen frame regression
caichangqing1120 Nov 26, 2026
33778eb
test(ci): run registered font fallback on both Windows archs
caichangqing1120 Nov 26, 2026
3df9fdf
feat(ui): show the full text of an ellipsized label on hover
xiaoyumuxi Nov 26, 2026
2bf8188
feat(app): confirm live window decoration changes
t8y2 Nov 26, 2026
a2262b9
fix(windows): apply the monitor's DPI before the first frame
Ezreal-byte Nov 26, 2026
a491326
feat(app): preview a status item on native pointer hover
Ezreal-byte Nov 26, 2026
79c3557
feat(components): add optional letter mnemonics to focus a menu item
lijhnihaoa Nov 26, 2026
e185c3b
merge: sync upstream main (79c3557b) into fork
xiaoyumuxi Nov 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,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|AFileDragOutReachesAnotherClient)$' -count=1 -v
xvfb-run -a -s '-screen 0 1280x1024x24 -noreset' go test ./internal/platform/linux -run '^Test(PreviewNativeX11Contract|NotificationNativeX11|TrayWindowQueuedRedrawBeforeInput|TrayWindowRepaintsLaterExposure|TrayPanelPreservesHostAnchorAtScale|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 @@ -379,12 +379,21 @@ jobs:
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: Offscreen incremental frame pixels
run: |
$test = 'TestOffscreenIncrementalUpdatesDrawWhatARebuildDraws'
go test -json ./internal/platform/windows -run "^${test}$" -count=1 -timeout=2m | Tee-Object -Variable events
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$passed = $events | ConvertFrom-Json | Where-Object { $_.Action -eq 'pass' -and $_.Test -eq $test }
if (-not $passed) { throw "$test did not pass on the Windows runner" }
- name: Web view partitions
run: go test ./internal/platform/windows -run '^Test(APageWithoutAPartitionAsksForNoProfileOfItsOwn|APartitionNamesTheWebView2Profile|AnEphemeralPartitionIsAnOffTheRecordProfile|EphemeralPagesWithoutAPartitionEachGetAProfileOfTheirOwn)$' -count=1 -v
- name: Terminal keyboard routing
run: go test ./internal/platform/windows -run '^TestATerminalGetsEditingKeysAndChordsAsRawKeys$' -count=1 -v
- name: Native window and grouped taskbar icons
run: go test ./internal/platform/windows -run '^TestWindowIconUpdatesOnTheWindowThread$' -count=1 -v
- name: Native window decoration changes
run: go test ./internal/platform/windows -run '^TestNativeWindowDecoration' -count=1 -v -timeout=90s
- name: Non-activating desktop notification
env:
VIVA_TEST_NOTIFICATION_DESKTOP: '1'
Expand All @@ -397,8 +406,8 @@ jobs:
env:
VIVA_WINDOWS_CLIPBOARD: '1'
run: go test ./internal/platform/windows -run '^TestColumnClipboardNative' -count=1 -v -timeout=2m
- name: Native Direct2D text origins and hidden labels
run: go test ./internal/platform/windows -run '^Test(DirectTextLayoutOriginByValue|HiddenNativeEditorDoesNotDrawColorEmoji|TextEngineRasterizesProportionalText)$' -count=1 -v
- name: Native Direct2D text origins, hidden labels and font fallback
run: go test ./internal/platform/windows -run '^Test(DirectTextLayoutOriginByValue|HiddenNativeEditorDoesNotDrawColorEmoji|TextEngineRasterizesProportionalText|RegisteredFontDrawsFallbackCharacters)$' -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
Expand All @@ -416,17 +425,21 @@ jobs:
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: windows-11-arm
env:
VIVA_SOFTWARE_RENDERING: '1'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
architecture: arm64
cache: true
- name: Native ARM64 Direct2D text origins
- name: Native ARM64 Direct2D text origins and font fallback
run: |
if ((go env GOARCH) -ne 'arm64') { throw 'Expected native ARM64 Go' }
go test ./internal/platform/windows -run '^TestDirectTextLayoutOriginByValue$' -count=1 -v
go test ./internal/platform/windows -run '^Test(DirectTextLayoutOriginByValue|RegisteredFontDrawsFallbackCharacters)$' -count=1 -v
- name: Native ARM64 window decoration changes
run: go test ./internal/platform/windows -run '^TestNativeWindowDecoration' -count=1 -v -timeout=90s

# A noise-tolerant benchmark regression gate for the pure-Go paths: the base
# revision and the pull request run the same benchmarks on the same runner,
Expand Down
22 changes: 22 additions & 0 deletions app/accessibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,25 @@ func TestSyncSemanticsUpdatesZeroIDContainerOnIncrementalPaint(t *testing.T) {
t.Fatalf("stale zero-ID container accessibility node: %+v", nodes)
}
}

// A pointer region over painted words (a selectable text's) is no node of its own and
// takes no focus, while the control it belongs to stays one.
func TestPresentationalHitsAreNoAccessibilityNodes(t *testing.T) {
var canvas gfx.Canvas
config := Config{Title: "presentational", Width: 200, Height: 120}
config.Paint = func(canvas *gfx.Canvas, size gfx.Size) {
canvas.HitWithOptions(gfx.Item(1), gfx.Rect{Width: 200, Height: 100}, "", gfx.HitOptions{Role: gfx.RoleGroup, SkipTab: true})
canvas.HitWithOptions(gfx.Item(2), gfx.Rect{Y: 10, Width: 120, Height: 16}, "", gfx.HitOptions{
Role: gfx.RoleGroup, Cursor: gfx.PointerCursorText, Presentational: true,
})
}
painter := newTestPainter(t, &canvas, config)
if len(painter.accessibility) != 1 || painter.accessibility[0].ID != gfx.Item(1) {
t.Fatalf("accessibility = %+v", painter.accessibility)
}
for _, hit := range canvas.Hits() {
if hit.ID == gfx.Item(2) && (hit.Focusable || hit.Cursor != gfx.PointerCursorText) {
t.Fatalf("the pointer region is %+v", hit)
}
}
}
6 changes: 4 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const (
// bottom-right of the pointer monitor's work area without taking keyboard
// focus. Mark the parts the user may drag with gfx.Canvas.MoveRegion or
// ui.Box.MovesWindow and save Frame's X and Y for Config.Origin.
// On Windows and macOS, an Anchor takes precedence over Origin and
// places the notification beside the status item.
// On native Wayland, the compositor decides placement, stacking and
// keyboard focus. Use SendNotification for a system-managed notification.
WindowNotification WindowMode = WindowMode(platform.WindowNotification)
Expand Down Expand Up @@ -109,8 +111,8 @@ type Config struct {
// change. Nil, or a zero field, takes a color that suits ClearColor. Use
// TitlebarInsets to keep your own content clear of the buttons.
WindowControls func() WindowControlsStyle
// Anchor is where a WindowPanel opens: beside the status item whose click
// supplied it. Without one the panel is centered on the screen.
// Anchor places a WindowPanel or WindowNotification beside a status item.
// Without one, a WindowPanel is centered on the screen.
Anchor StatusAnchor
ClearColor Color
// Transparent composites the window over the desktop: the part of the canvas
Expand Down
22 changes: 21 additions & 1 deletion app/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var ErrNoWindows = errors.New("app: application opened no windows")
// before resize/frame callbacks and repaints afterward.
// An always-on-top host additionally implements SetAlwaysOnTop(bool) error.
// A size-capable host additionally implements SetSize(int, int) error.
// A decoration-capable host additionally implements SetDecorated(bool, func(error)) error.
type WindowControl interface {
Close()
Hide()
Expand Down Expand Up @@ -371,11 +372,30 @@ func (application *Application) AddStatusItem(config StatusItemConfig) (*StatusI
if err := config.Icon.validate(); err != nil {
return nil, err
}
item := &StatusItem{application: application}
dismiss := func() {
if preview := item.preview.Load(); preview != nil {
preview.close()
}
}
if click := config.OnClick; click != nil {
config.OnClick = func(event StatusClick) {
dismiss()
click(event)
}
}
if menu := config.Menu; menu != nil {
config.Menu = func() []MenuItem {
dismiss()
return menu()
}
}
control, err := application.host.AddStatusItem(config)
if err != nil {
return nil, err
}
return &StatusItem{control: control}, nil
item.control = control
return item, nil
}

// SetDockBadge marks the application's Dock icon with text, the red badge macOS
Expand Down
17 changes: 17 additions & 0 deletions app/application_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ func (window resultWindow) SetAlwaysOnTop(enabled bool) error {
return control.SetAlwaysOnTop(enabled)
}

func (window resultWindow) SetDecorated(decorated bool, done func(error)) error {
control, ok := window.WindowControl.(decorationControl)
if !ok {
return platform.ErrWindowDecorationUnsupported
}
return control.SetDecorated(decorated, done)
}

func (window resultWindow) MoveTo(origin gfx.Point) {
if control, ok := window.WindowControl.(platform.WindowMover); ok {
control.MoveTo(origin)
Expand Down Expand Up @@ -265,3 +273,12 @@ func (item nativeStatusItem) SetIcon(icon StatusIcon) error {
}
func (item nativeStatusItem) SetTooltip(tooltip string) { item.item.SetTooltip(tooltip) }
func (item nativeStatusItem) Remove() { item.item.Remove() }
func (item nativeStatusItem) SetStatusHover(handler func(StatusAnchor, bool)) bool {
if handler == nil {
return item.item.SetHover(nil)
}
return item.item.SetHover(func(event platform.StatusHover) {
handler(StatusAnchor{rect: event.Anchor, set: event.Entered}, event.Entered)
})
}
func (item nativeStatusItem) RefreshMenu() { item.item.RefreshMenu() }
17 changes: 17 additions & 0 deletions app/application_native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,20 @@ func TestResultWindowForwardsSetTitle(t *testing.T) {
t.Fatalf("wrapped unsupported window error = %v", err)
}
}

func TestResultWindowForwardsSetDecorated(t *testing.T) {
native := &decorationTestControl{decorated: true}
window := &Window{control: resultWindow{WindowControl: native}}
called := false
if err := window.SetDecorated(false, func(error) { called = true }); err != nil || native.decorated || native.done == nil || called {
t.Fatalf("decorations did not reach the native control: %v", err)
}
native.done(nil)
if !called {
t.Fatal("native completion did not reach caller")
}
unsupported := &Window{control: resultWindow{WindowControl: &fakeWindow{}}}
if err := unsupported.SetDecorated(false, func(error) {}); !errors.Is(err, ErrUnsupported) {
t.Fatalf("wrapped unsupported native error = %v", err)
}
}
43 changes: 43 additions & 0 deletions app/decoration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package app

import (
"errors"
"fmt"

"github.com/vivaui/viva/internal/platform"
)

type decorationControl interface {
SetDecorated(bool, func(error)) error
}

// SetDecorated changes the native decorations of a normal, mapped window
// without replacing it or moving its content. It does not change fullscreen
// or always-on-top state. It is safe to call from any goroutine.
//
// A non-nil error rejects the request without calling done. An accepted
// request calls done once on the native window loop after the transition is
// confirmed, fails, or is interrupted by closing the window. Do not block
// the window loop waiting for done. Hosts without this capability return an
// error wrapping ErrUnsupported.
func (window *Window) SetDecorated(decorated bool, done func(error)) error {
if done == nil {
return fmt.Errorf("app: window decoration completion callback is required")
}
if window == nil || window.closed.Load() {
return fmt.Errorf("app: window is closed")
}
control, ok := window.control.(decorationControl)
if !ok {
return fmt.Errorf("%w: window decorations", ErrUnsupported)
}
err := control.SetDecorated(decorated, func(err error) { done(windowDecorationError(err)) })
return windowDecorationError(err)
}

func windowDecorationError(err error) error {
if errors.Is(err, platform.ErrWindowDecorationUnsupported) {
return fmt.Errorf("%w: window decorations", ErrUnsupported)
}
return err
}
55 changes: 55 additions & 0 deletions app/decoration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package app

import (
"errors"
"testing"

"github.com/vivaui/viva/internal/platform"
)

type decorationTestControl struct {
WindowControl
decorated bool
done func(error)
err error
}

func (c *decorationTestControl) SetDecorated(decorated bool, done func(error)) error {
c.decorated, c.done = decorated, done
return c.err
}

func TestSetDecoratedReportsCompletionOnlyFromHost(t *testing.T) {
control := &decorationTestControl{decorated: true}
window := &Window{control: control}
var completed []error
if err := window.SetDecorated(false, func(err error) { completed = append(completed, err) }); err != nil {
t.Fatal(err)
}
if control.decorated || control.done == nil || len(completed) != 0 {
t.Fatal("submission did not reach the host, or completed before the host replied")
}
rollback := errors.New("previous frame restored")
control.done(rollback)
if len(completed) != 1 || !errors.Is(completed[0], rollback) {
t.Fatalf("completion = %v", completed)
}
}

func TestSetDecoratedRejectsUnsupportedAndClosedWindows(t *testing.T) {
unsupported := &Window{control: struct{ WindowControl }{}}
for _, window := range []*Window{unsupported, {control: &decorationTestControl{err: platform.ErrWindowDecorationUnsupported}}} {
if err := window.SetDecorated(false, func(error) { t.Error("unsupported submission completed") }); !errors.Is(err, ErrUnsupported) {
t.Fatalf("unsupported submission: %v", err)
}
}
control := &decorationTestControl{}
window := &Window{control: control}
if err := window.SetDecorated(false, nil); err == nil {
t.Fatal("submission without a completion callback succeeded")
}
window.closed.Store(true)
if err := window.SetDecorated(false, func(error) {}); err == nil || control.done != nil {
t.Fatalf("closed submission reached host: %v", err)
}
}
29 changes: 21 additions & 8 deletions app/hit_gate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,29 @@ func TestRepaintReleasesFocusWhenThePaintAsksWithoutChangingHits(t *testing.T) {

// A page that formats its labels every frame declares the same text in a new
// allocation each time: that is an unchanged hit list, which keeps the repaint on
// the path that skips the semantic mirror.
func TestSameHitsComparesLabelsByText(t *testing.T) {
// the path that skips the semantic mirror. Changed words still reach it.
func TestRepaintComparesLabelsByText(t *testing.T) {
page := &hitGatePage{label: "Clicked 3 times", bounds: gfx.Rect{Width: 80, Height: 20}}
fresh := func(text string) string { return string([]byte(text)) }
published := []gfx.Hit{{ID: gfx.Item(1), Label: fresh("Clicked 3 times"), Value: fresh("3")}}
current := []gfx.Hit{{ID: gfx.Item(1), Label: fresh("Clicked 3 times"), Value: fresh("3")}}
if !sameHits(published, current) {
t.Fatal("the same labels in new allocations compared as a change")
config := Config{Title: "gate", Width: 200, Height: 80, Paint: page.paint}
var canvas gfx.Canvas
painter := newTestPainter(t, &canvas, config)

page.label = fresh("Clicked 3 times")
frame, err := painter.repaint()
if err != nil {
t.Fatal(err)
}
if frame.Accessibility != nil {
t.Fatal("the same label in a new allocation republished the accessibility payload")
}

page.label = fresh("Clicked 4 times")
frame, err = painter.repaint()
if err != nil {
t.Fatal(err)
}
current[0].Label = fresh("Clicked 4 times")
if sameHits(published, current) {
if frame.Accessibility == nil || painter.accessibility[0].Label != "Clicked 4 times" {
t.Fatal("a changed label compared as unchanged")
}
}
14 changes: 8 additions & 6 deletions app/key_traversal_frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ func TestContinueTraversalKeyPublishesOneConsistentFrame(t *testing.T) {
if count >= base {
t.Fatalf("the popup did not close: %d -> %d", base, count)
}
// The platform still holds base rectangles. A frame that carries a different
// number of them has to say so with a rebuild.
if len(frame.Rectangles) != base && !frame.Update.Rebuild {
t.Fatalf("frame does not match the platform's base: base=%d frame=%d update=%+v", base, len(frame.Rectangles), frame.Update)
// The platform still holds base rectangles. A frame that carries fewer has
// to say so: a rebuild, or a shrink whose range runs to the new end, which
// every backend applies to the base and then truncates.
update := frame.Update
if len(frame.Rectangles) != count {
t.Fatalf("frame carries %d rectangles, the renderer holds %d", len(frame.Rectangles), count)
}
if !frame.Update.Rebuild || frame.Update.Count != count {
t.Fatalf("update = %+v, want a rebuild of all %d rectangles", frame.Update, count)
if !update.Rebuild && (!update.Shrink || update.First > count || update.First+update.Count != count) {
t.Fatalf("update = %+v cannot take the platform from %d rectangles to %d", update, base, count)
}
}

Expand Down
Loading
Loading