Skip to content

all: move the compositor into internal packages - #20

Merged
DeedleFake merged 8 commits into
masterfrom
refactor-internal
Oct 2, 2026
Merged

DeedleFake merged 8 commits into
masterfrom
refactor-internal

Conversation

@DeedleFake

Copy link
Copy Markdown
Owner

Why

kawa was a single main package at the repository root, so background scaling, -out parsing, layer surface placement, and text drawing could only be exercised through a running compositor. This moves the compositor into internal/kawa behind a small cmd/kawa and pulls those four pieces into packages that build without cgo and have their own tests. Runtime behavior does not change.

Scope

  • cmd/kawa parses the flags, starts the PPROF_ADDR server, calls wlr.InitLog, and runs a kawa.Server.
  • internal/kawa is the old main package. Server has exported Terms, OutputConfigs, Background, and BackgroundScale fields and one exported method, Run(ctx), which does not use its context. Release and Shutdown are now release and shutdown.
  • internal/bg replaces scaleFunc and parseScale with bg.Scale, which implements encoding.TextMarshaler and TextUnmarshaler for flag.TextVar. The unused scaleTile is gone.
  • internal/output replaces OutputConfig, parseOutputConfigs, and parseTransform with output.Config, output.Transform, and output.Parse. kawa maps output.Transform to wlr.OutputTransform with a table.
  • internal/anchor replaces placeLayerSurface, placeSpan, and excludeZone with anchor.Place and anchor.Exclude, which take an anchor.State that layers.go builds from the layer surface.
  • draw moves to internal/draw, and CreateTextTexture becomes Text, which returns an *image.NRGBA that kawa uploads.
  • CI builds ./... and runs go test ./..., plus the extracted packages' tests with CGO_ENABLED=0. The README, launch.sh, and the verify-kawa docs use the new paths.

Existing bugs stay as they are. A small image under -bgscale fit still sits at the corner, a malformed -out entry still panics, and an unknown transform still means normal.

Blast Radius

The install path changes from deedles.dev/kawa to deedles.dev/kawa/cmd/kawa. Nothing outside this module imports the moved code, and the old and new binaries behave the same in every check below.

Verification

  • Every commit builds, vets, and passes its tests. go fix -diff reports the same two suggestions as on master.
  • A throwaway equivalence test ran verbatim copies of the old functions against the new packages on random inputs. 800,000 background placements, 500,000 -out strings, 1,000,000 layer placements and exclusions, and 6,045 rendered strings all matched. The -out strings that panic before also panic now.
  • -h output is byte-identical. stretch, center, fit, and fill parse the same, and ten invalid -bgscale values fail with the same message and exit status 2.
  • verify-kawa ran against both builds with the same script. It covered boot and the registry, both menus, New, Tile, Hide, swaybg, waybar's exclusive zone, mako, Xwayland, Log Out, eight -bg and -bgscale combinations plus a missing file, and fifteen -out values. All 39 screenshots are pixel-identical, and the kawa logs match apart from Xwayland event ordering.
  • SIGTERM exits with 143 and Log Out exits with 0 in both builds. Backend and socket failures log the same text and exit with 1.

The scaling methods become a bg.Scale enum, and -bgscale parses it with
flag.TextVar. The unused scaleTile is dropped. CI now runs the tests and
builds the extracted packages without cgo so that wlr stays out of them.
-out now parses into output.Config, whose Transform is its own enum
that kawa maps to wlr.OutputTransform when it configures an output.
cmd/kawa now holds the flags and fills in Server's exported fields,
and Server.Run does what Main did after flag parsing. release and
shutdown are unexported, so Run is Server's only exported method. Run
accepts a context but does not use it. Errors are logged with the same
text as before.
Placement and exclusive zone math now works on an anchor.State that
layers.go builds from the layer surface's current state. anchor.Edges
has the same bits as the protocol's anchors and wlr_edges, which a
test in internal/kawa checks.
draw.Text returns the *image.NRGBA that CreateTextTexture used to
upload, so the package no longer needs wlr. kawa uploads it with a
small textTexture helper.
@DeedleFake
DeedleFake merged commit b5c23d9 into master Oct 2, 2026
2 checks passed
@DeedleFake
DeedleFake deleted the refactor-internal branch October 2, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant