TRE-REQ-004: Tesserae Layer and Popup Windows¶
Warning
Superseded by ADR-0006 Shell Independent of Tesserae UI (2026-10-25)
Withdrawn before it was carried to Tesserae. The shell no longer depends on tesserae-ui, so nothing is requested of Tesserae. The requirements (R1 to R9) and open questions move into the shell's own design: ADR-0007 Shell UI Layer. The note stays as a record of what Tesserae does today.
Note
Let a Tesserae view be the content of a tre LayerWindow or PopupWindow, and let a Tesserae app run with no main window. Tesserae 0.5.1 opens only ordinary windows, so a shell built on tesserae-ui (ADR-0002 Relationship to Tesserae UI) cannot put a bar on screen from a YAML view. This request is addressed to the Tesserae project, not to tre: tre 0.5.8 already has the mechanism.
This note is carried to the Tesserae project by the maintainer (Vault Reference > Requests between projects). It is not filed from this vault. Numbers 002 and 003 stay reserved (see 80 Requests).
Shell Need¶
A shell opens, from YAML views and Python:
| Need | Use case (Personas and Use Cases) |
|---|---|
A view as the content of a LayerWindow (bar, OSD, launcher, widget, panel), bound to one monitor |
UC1, UC3, UC4, UC5, UC6, UC11 |
The same view opened on several monitors, each with its own Output |
UC1, UC10, UC11 |
A view as the content of a PopupWindow hung off a rectangle of a layer window |
UC2 |
| Layer-surface settings in the view file, changed live by hot reload | UC8 |
| An app with no main window, which stays up when any one surface closes | UC10 |
Why it Belongs in Tesserae¶
tre owns the mechanism: surface roles, outputs, input regions, margin animation. Tesserae owns how a view becomes a window: the widget: Window root, open_window, the ViewModel, theme and stylesheet binding, and hot reload (Vault Reference > Layering principle). The shell should not duplicate that composition path. If it did, the shell would carry a second way to build and re-theme a view, which is the dialect split ADR-0002 Relationship to Tesserae UI avoids.
What Tesserae Does Today¶
Source: local clone ~/Projects/pyDev/projects/tesserae at commit 0eda3fe (version 0.5.1.4, unreleased), read 2026-10-25. PyPI has tesserae-ui 0.5.1 (2026-10-19). #needs-verification: confirm each item below against the 0.5.1 release; the clone is ahead of PyPI.
| Fact | Where |
|---|---|
The pin is tesserae-engine==0.5.8. |
pyproject.toml |
No source file, doc, plan or changelog mentions LayerWindow, PopupWindow or layer-shell. |
search of src, docs, design, PLAN.md, CHANGELOG.md |
App creates one main Window in its constructor and run() always adds it. |
src/tesserae/app.py:318, :1844 |
open_window(view, name, parent, modal, center) builds a plain Window(width=480, height=320), applies the view's widget: Window options, and returns an AppWindow. |
app.py:935-965 (the Window(...) at :944) |
| Closing the main window closes every other window and ends the app. | appwindows.py docstring; docs/guide/windows-and-docks.md ("Several windows") |
Opening a window whose name is already open raises ValueError; a window is found by its view's name. |
app.py:950, :998 |
The ViewModel is the one that serves the view's name; the theme, stylesheet and app are the app's. |
docs/guide/windows-and-docks.md |
widget: Window options are read when the window opens; hot reload does not re-apply them. |
docs/guide/hot-reload.md |
modal=True dims the parent with a scrim layer; center cannot place a window on Wayland. |
appwindows.py, app.py:962 |
tre side, for contrast (TRE-REQ-001 Layer Surface Window > Delivered (tre #195 closed)): tre.App.run() raises RuntimeError when no window is registered and ends when every window has closed (App reference). A LayerWindow is constructed with namespace and binds to an Output at construction only.
Proposed API¶
Caution
Proposal, not existing API Every name below is proposed for Tesserae. Nothing here exists. The Tesserae project decides names and shape. Keys that mirror tre keep tre's names (TRE-REQ-001 Layer Surface Window).
1. A Layer Window Root in a View¶
A view whose root is widget: LayerWindow is the content of a LayerWindow, as widget: Window is for a window.
name: Bar
widget: LayerWindow
namespace: tesserae-shell.bar # required, constructor only
layer: top
anchor: [top, left, right]
size: [0, 32]
exclusive_zone: 32
keyboard: none
input_region: auto
children:
- widget: Text
text: "{{ clock.time }}"
- Keys:
namespace,layer,anchor,size,exclusive_zone,exclusive_edge,margin,keyboard,input_region.outputis not a view key (see 2). - A key that has no meaning for a layer surface (
title,borderless,min_width,min_height,fullscreen,maximized,remember,title_bar) is a load error that names the key and the file position, not a silent ignore. This matches tre, whoseset()raises for the same keys (LayerWindow reference). - The root is transparent with no padding or gap, as tre's layer window is.
style:on the root paints the surface. transparentis on;blur_behindandclick_throughare the existing window keys, withclick_throughmeaninginput_region: [].
2. Opening it¶
bar = app.open_layer("Bar", name="bar-DP-1", output=output, params={"output": output.name})
bar.window # the tre LayerWindow
bar.output # the Output it is bound to
open_layer(view, name=None, *, output=None, params=None, **overrides) -> AppWindow.overridesreplace view keys for this opening (for example a differentmargin).outputtakes anOutputor a connector name and is required unless the shell accepts tre's deterministic default.- The same view may be opened many times under different
names, one per monitor. Thenameis the key, as inopen_window. paramsreach the view and ViewModel so one instance knows its monitor (see Open questions on ViewModel per opening).AppWindowgainsoutputandset(**props)(forwards toLayerWindow.set). It keepswindow,close(),on_close()andclosed.- Before
run()the window opens with the others; while it runs, on the loop's next turn, asopen_windowdoes.
3. A Popup Root¶
name: TrayMenu
widget: PopupWindow
size: [180, 120]
constraint_adjustment: [flip_y, slide_x]
grab: true
children: [...]
menu = app.open_popup("TrayMenu", parent=bar, anchor_rect=(100, 0, 60, 32), anchor="bottom_left", gravity="bottom_right")
- View keys:
size,anchor,gravity,constraint_adjustment,offset,grab.parentandanchor_rectare per opening, in the parent's coordinates. parentis anAppWindowfor aLayerWindoworPopupWindow. A closed or unopened parent fails with a clear error (tre reports reason"failed").- The
closedsignal carries tre's reason ("dismissed"on an outside click or Escape). A click on another window of the same application reaches that window, so the shell closes the menu itself (PopupWindow reference). modalandcenterdo not apply and raise if given.
4. An App with No Main Window¶
app = App(main_window=False, root=HERE)
app.open_layer("Bar", output=output)
app.run()
- With
main_window=False,Appdoes not create or register the mainWindow.app.windowis unavailable and says why. - The app ends when every window has closed, not when one does, matching
tre.App.run(). An explicitapp.quit()ends it earlier. - With no windows registered, tre raises
RuntimeError. Tesserae gives a clear error, or runs idle if the shell opened none yet (a monitor set to "none", or no outputs). See Open questions. - Screens, routes and the main-window title bar are not available, as for any second window today.
5. Hot Reload¶
- Saving a
widget: LayerWindowview re-applieslayer,anchor,size,exclusive_zone,exclusive_edge,margin,keyboardandinput_regionthroughLayerWindow.set, which is live and one commit (tre). This differs fromwidget: Window, whose options are read only at open (Hot Reload). namespaceandoutputcannot change on a live window. Changingnamespacein the file logs a warning that names the file and asks for a reopen. The shell reopens the window.- A bad value leaves the window as it was and logs an
ERRORwithfile:line:column, as for any view.
6. Events and Animation Reach the View¶
- tre events that matter to a shell are available as ViewModel handlers:
configure,moved,closed(withreason),warning,output_changed. Minimum: Python can listen onAppWindow.windowtoday, so this is a convenience; it is listed to avoid each shell wrapping the same thing. - Margin animation and
window_region: drag_marginalready pass throughAppWindow.window.animate(...)and the node property. No new Tesserae API is requested for them.
Requirements¶
| # | Requirement |
|---|---|
| R1 | A widget: LayerWindow view opens a tre LayerWindow with the keys above and the view's content, themed with the app's theme and stylesheet. |
| R2 | A view opens any number of times under distinct names, each bound to its own Output. |
| R3 | A widget: PopupWindow view opens parented to an open layer or popup window with a given anchor_rect. |
| R4 | App(main_window=False) runs without a main window and ends when the last window closes. |
| R5 | Hot reload re-applies the live layer keys without recreating the window and reports the constructor-only keys. |
| R6 | A key with no meaning for a layer surface is a load error with a position. |
| R7 | Headless: a layer or popup view builds, themes and responds to simulate with no display, using tre's headless LayerWindow (LayerWindow reference). |
| R8 | No Python in layout or paint: all new Tesserae code runs in callbacks (Vault Reference > Layering principle). |
| R9 | Threading: opening and closing run on the loop thread; other threads use thread_handle().call_soon. |
Alternatives¶
| Alternative | Verdict |
|---|---|
The shell builds LayerWindow itself and calls Tesserae's internal _open_view(view, name, window) (app.py:911). |
Works today but depends on a private method and skips open_window's bookkeeping (AppWindow, close handling, themed registration). Fragile across Tesserae releases. Prototype only. |
| The shell wraps Tesserae with its own window opener and view loader. | Duplicates composition and theming; two paths to maintain. Against ADR-0002 Relationship to Tesserae UI. |
Drop tesserae-ui and build on tre directly. |
Rejected in ADR-0002 Relationship to Tesserae UI (Option B). |
If Declined¶
- Use the private-method prototype above, labelled throwaway, in
90 Research/. - Write an ADR superseding ADR-0002 Relationship to Tesserae UI if the private path proves unstable. The shell would then own a thin view-to-window layer on tre.
Open Questions¶
- Should each opening get its own ViewModel instance, or share one with
params? Context: Tesserae serves a view with "the ViewModel that serves its name". A bar opened on three monitors has three windows and, today, one ViewModel. The shell needs per-monitor state (the monitor name, its workspaces) and shared state (the clock). Recommendation: one ViewModel instance per opening, with shared services passed in. #needs-verification against the ViewModel binding code. - With no registered window, should Tesserae keep the loop alive, or should the shell open nothing and let
run()return? Context: tre raisesRuntimeErrorwith no registered window. A shell whose every monitor is "none" (V1 Scope > Multi-monitor) has none. Recommendation: keep the loop alive with thekeep_aliveargument ofrun()from TRE-REQ-005 Keep-Alive and Loop Stop, not with an idle hidden anchor window. - Should Tesserae expose output hot-plug (
app.outputs,app.on("output_added")), or should the shell usetre.Appdirectly throughapp._tre_app? Context:App.outputs()and theoutput_*events are tre's. Recommendation: Tesserae exposes them, so the shell stays off private attributes. - Should the TDL spell the surfaces
widget: LayerWindowandwidget: PopupWindow, or use akind:key onwidget: Window? Context: this is Tesserae's choice, which you carry. Recommendation: separatewidget: LayerWindowandwidget: PopupWindow, which mirror tre's class names and keep one spelling per widget. - Which Tesserae release carries this, and should the pin be
tesserae-engine>=0.5.8? Context:PopupWindowarrived in tre 0.5.8 (TRE-REQ-001 Layer Surface Window). Recommendation: pintesserae-engine>=0.5.8unless Tesserae ships it later.
Acceptance Criteria¶
- A
Bar_View.yamlwith awidget: LayerWindowroot opens a bar on KWin that reserves its exclusive zone, usingapp.open_layer, with no main window. - The same view opened on two outputs under two names yields two bars, each on its output.
- A
widget: PopupWindowview opens next to itsanchor_rect, flips at the screen edge, and firesclosedwith reason"dismissed"on an outside click. - Editing
exclusive_zonein the view file changes the live bar in one commit, with no restart. - A key with no layer meaning (
borderless,title) in awidget: LayerWindowview fails to load withfile:line:column. - Closing one bar leaves the app running; closing the last window ends it.
- A layer view builds and answers
simulateheadless in CI. - An unplugged output closes its bar (reason
"output_removed") and the app continues.