Skip to content

Add window services: persisted placement, menus, tray and window options on every engine (#764) - #797

Open
ambroise-leclerc wants to merge 26 commits into
763-hmrfrom
764-window-services
Open

ambroise-leclerc wants to merge 26 commits into
763-hmrfrom
764-window-services

Conversation

@ambroise-leclerc

@ambroise-leclerc ambroise-leclerc commented Dec 6, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #764. Completes the work started in #788. Stacked on #796.

What changes

  • app.windowControl() and WindowOptions::rememberAs, alwaysOnTop, stateDirectory: geometry and states with per-application persistence, application and context menus with shortcuts, tray, under WebKitGTK, WKWebView, WebView2 and CEF; unsupported where the toolkit cannot.
  • Optional webfront::services::Window, which answers the embedded view only, and windowService() in @webfront/services. Menu and tray calls carry a generation so a selection reaches the menu that produced it.
  • Unit, lifecycle and Wayland (headless weston, added to the Linux CI image) tests; docs/FRONTENDS.md, ADR-020 and ADR-007 amendments (proposed), changelog.

Limits

  • No menu bar or tray under CEF, no tray under GTK 4. No position or always-on-top under Wayland (also for CEF on a Wayland session). activate("context") is unsupported on WKWebView and WebView2. Secondary windows are neither controlled nor remembered. Global shortcuts are not delivered.
  • Maximize, full screen and minimize are not verified on Linux with a real window manager. Under GTK 4 the normal position is sampled every 100 ms, so a maximize within about 200 ms of a move keeps the previous position (documented).
  • Reopening at the previous position and size is demonstrated on X11 and by the lifecycle cases of the Windows and macOS jobs.

Checks

Desktop jobs (Linux, Windows with /analyze, macOS) and the CEF GCC/Clang and sanitizer jobs, dispatched on the branch, are green. Seven Codex review passes; every finding fixed or answered.

Comment thread js/services/index.mjs Resolved
Comment thread js/services/index.mjs Resolved
Comment thread js/services/index.mjs Resolved
Comment thread js/services/index.mjs Resolved
Geometry, state and activation calls reached the window after the service was disposed; they now go through the same live check as the menu, tray and context menu calls.
…under X11

screens() returned the whole X screen as one rectangle, so a position in the gap between two monitors, or in the unused corner of the bounding box, was accepted. It now lists the GdkMonitor geometries in the pixels a position is given in, and falls back to the X screen only when GDK lists none. The other engines already test against per-monitor work areas (EnumDisplayMonitors, NSScreen, CefDisplay).
…ft by an exception

The delegate kept a raw pointer to the stack control past the end of the function if an exception escaped before the normal clean-up; a guard now releases the control and clears the pointer on every exit.
…tion as unsupported on Wayland

The loss window of a window moved then maximized before two samples agree shrinks from 500 ms to about 200 ms and is documented; the kept position is always an earlier normal one. CEF positionable() no longer trusts cef_get_xdisplay() in a Wayland session, where XWayland is reachable but Chromium cannot place its windows.
Comment thread js/services/index.mjs Resolved
…2, WKWebView)

The new tray icon and menu, and the new menu bar, are built and checked before the old ones are taken away; the tray is replaced in place with NIM_MODIFY. WebKitGTK has no tray and its setMenu has no refusal after validation; CEF has no native menu.
setMenu and setTray carry a generation number that C++ returns with every selection. The page keeps a handler per generation (pending, installed or gone): a selection reaches the menu it was made in, a refused call forgets only itself, an accepted one supersedes the older generations. Specs cover pending B while A is active, B refused, B accepted then a late A event, and an older call answered after a newer one.

This branch has not been deployed

No deployments
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.

2 participants