Skip to content

feat: Open a window as a wlr-layer-shell surface via WindowOptions.layerShell. - #64

Merged
remorses merged 1 commit into
remorses:mainfrom
Kiite-Org:feat/layer-shell-window-kind
Sep 12, 2026
Merged

remorses merged 1 commit into
remorses:mainfrom
Kiite-Org:feat/layer-shell-window-kind

Conversation

@dim-ghub

Copy link
Copy Markdown
Contributor

In zed/ there is already an implemention of layer-shell at Rust level (Window Kind::Layer Shell, layershell::Layer Shell Options) but nothing was exposed to JS. The Window Options did not provide any way of requesting it so it could not be used outside of it to open normal floating windows. Either a panel or a dock or a notification-shade or a wallpaper required an edge anchored surface which must have exclusive zone which is precisely whatlayershellwas intended for.

Add two fields to napi Window Options:

  • layerShell?: Layer Shell Options - containsnamespace, layer (background | bottom | top | overlay), anchor (top | bottom | left | right, in the two corners opposite in Y axes, it is used for extending an axis from an edge), exclusiveZone, exclusiveEdge, margin ([top, right, bottom, left]), keyboardInteractivity (none | on-demand | exclusive). All these options are optional, it is assumed by default anchor covers top and left and right edges (anchored top bar) and it assumes layer is 'top'.
  • appId?: string - WMCLASS for X11 or appid for Wayland. This field is already useful to be declared to allow a compositor targeting layer surface by rule, it can also be useful by itself.

The function togpuiwindowoptions will use layerShell on Window Kind::Layer Shell and will remove the titlebar. The Variant only is available for linux gpui on wayland-enabled target, so the layerShell argument is only translated when cfg(targetos="linux"), it is ignored on macOS, Windows and an appId still apply. The functioninit_threaded opens a surface at origin rather thanBounds::centered (compositor places based on anchor and exclusivezone)

The GPUI fork in zed/ already implements layer-shell at the Rust level
(WindowKind::LayerShell, layer_shell::LayerShellOptions), but nothing
reached JS: WindowOptions had no way to ask for it, so @gpuix/react
could only open normal floating windows. A panel, dock, notification
shade or wallpaper needs an edge-anchored surface with an exclusive
zone, which is exactly what layer-shell is for.

Add to the napi WindowOptions:

- layerShell?: LayerShellOptions - namespace, layer (background |
  bottom | top | overlay), anchor (top / bottom / left / right, two
  opposite edges stretch that axis), exclusiveZone, exclusiveEdge,
  margin ([top, right, bottom, left]), keyboardInteractivity (none |
  on-demand | exclusive). All optional; the default anchor is a top
  bar (top | left | right) and the default layer is top.
- appId?: string - Wayland app_id / X11 WM_CLASS, useful on its own
  and needed for a compositor to target a layer surface by rule.

to_gpui_window_options maps layerShell onto WindowKind::LayerShell and
drops the titlebar. The WindowKind variant only exists on a
wayland-enabled Linux gpui build, so the mapping is
cfg(target_os = "linux"); on macOS and Windows layerShell is ignored
and appId still applies. init_threaded opens a layer surface at the
origin instead of Bounds::centered, since the compositor places it
from its anchor.

index.d.ts is hand-edited rather than regenerated: the @napi-rs/cli
in node_modules emits a much smaller index.d.ts than the committed
one (it drops every doc comment and all of TestGpuixRenderer's
methods), so a full `napi build` regen here would be a large
destructive diff unrelated to this change. The added block matches
the shape napi produces for these structs.

Tests in renderer.rs cover the mapping (anchor union, exclusive zone
and edge, margin, keyboard interactivity, titlebar dropped) and that a
window with no layerShell stays Normal with a titlebar.

Verified on Hyprland (3 monitors): a @gpuix/react app calling
render(<Bar/>, { layerShell: { anchor: ['top','left','right'],
exclusiveZone: 34 } }) opens a 34px top bar, hyprctl reports the
kite-panel layer surface and reserved: [0, 34, 0, 0], and a React
setInterval clock re-renders live on the surface.
@remorses
remorses merged commit e47bd1c into remorses:main Sep 12, 2026
@remorses

Copy link
Copy Markdown
Owner

thanks!

fdarian referenced this pull request in fdarian/ghia Oct 21, 2026
…yback controls: `time` and `speed` to read and assign, `duration`, `iterationDuration`, `state` ("running", "paused", "finished", "idle"), `pause()`, `play()`, `stop()`, `cancel()` and `complete()`, typed `AnimationPlaybackControls` and `AnimationPlaybackControlsWithThen` (`AnimationControls` is gone, no alias) (#64, slice A). `finished` and `then` resolve only when the animation finishes by itself or `complete()` ends it, are a new promise after `play()` starts a finished animation again, and stay pending after `stop()`, `cancel()` and a replacement, which leave the old controls inert with state "idle"; they never reject. Natively a source keeps its animation as a track on a `Playback` clock (`motion/web_animation.rs`, as it was for CSS animations): `Track::sample_at` samples at an elapsed time, `Track::span` gives the iteration and the end (a spring's from the settle scan), and `Sample.moving` tells a held animation, which stays in effect and keeps `isMotionValueAnimating` and the start and complete events but asks for no frame and has no velocity, from one that moves. The renderer gets `pauseMotionValue`, `playMotionValue`, `seekMotionValue(id, seconds)`, `setMotionValueSpeed`, `completeMotionValue` and `getMotionValuePlayback`, which `Repaint::MotionWrite` repaints like any other write. A run backwards that gets to its first keyframe completes like a forward finish; a finished run is kept so `play()` and `seek` can start it again, and a command that meets it latches its end so a change of speed cannot take it off. Controls used before the value is bound apply when the animation starts. The `(from, to, {host})` overload of `animate` destroys its temporary value on an internal settlement and not on `finished`, which no longer resolves on stop. Deviations from Motion, each named in the test by row: the time setter reads back as set (Motion counts the delay in it), a speed other than 0 after 0 resumes without `play()`, `isAnimating()` is false after the controls' `stop()` and `cancel()` and true while a seeked or replayed animation runs, `time` stops at the end of the last repeat, and `play()` after `cancel()` does nothing (Motion starts it again). Test: motion-controls-native against motion-controls-oracle (Motion 14.1.0 itself on a stepped clock, 41 rows: the fluid-hover loop paused mid-loop and played again, pause in and after a delay, seek running, held, finished, past the end and into a repeat, speed 2, 0.5, 0 then 1 and -1, stop, cancel, complete, replacement, play after the finish), `cargo test --lib` motion, motion-value.test.ts
fdarian referenced this pull request in fdarian/ghia Oct 21, 2026
…frame at the speed it had, as in Motion; only `stop()` ends the controls for good (#64, slice A). Motion's cancel does not set its `isStopped`, so its `play()` starts the animation again, which the first commit had as a no-op. The value keeps the animation that `cancel()` ended until another animation takes the value, and a cancel that found the animation finished (value left on its end) jumps back to the first keyframe when it plays. The `cancel while running` row of the oracle is now an exact match, with rows added for cancel then play at speed 2 and cancel after the finish then play; `isAnimating()` stays in the stale-flag set. Test: motion-controls-native (54), motion-value.test.ts, `cargo test --lib` motion
fdarian referenced this pull request in fdarian/ghia Oct 21, 2026
… slice A). The fluid-hover cursor (keyframes with times, easeInOut, repeat Infinity) is held mid-loop by pause() and the element holds across fast-forwards, then play() goes on from the held time and a lap later it is where it was; the time, speed (2, -1, 0), duration, state, finished and then, stop, cancel and play after cancel are read through a motion value bound to an element's width. A paused animation or a speed of 0 draws no frame on its own where a running one draws each (setInlineDraws(false) and drawFrame against getPaintedFrameCount). An unmounted component's paused animation keeps its value until the animation is stopped, and its cleanup's stop() frees the node. Test: motion-controls (19) in react and solid
fdarian referenced this pull request in fdarian/ghia Oct 21, 2026
… they do and where they differ from Motion (#64, slice A). Test: none (docs)
fdarian referenced this pull request in fdarian/ghia Oct 21, 2026
… wait for the ring's last retarget, which fractional layout now makes visible (#65). With lengths rounded to a device pixel before layout, the last 1/16 px of the panel's spring changed no box, so the observer's last report came a frame earlier and a ring that was a fraction short rounded to its target. Now the container still grows by 119.9375 then 120 in the last frame, the observer reports it there, and the ring is sent to its last target by a retarget that Solid queues for a microtask a synchronous test never reaches: it was sent by the next read of a bounds, which put the ring 107.9375 where the row asks for 108 and, in the combined test, started its spring inside the idle frames (30 elements built a frame where the roots build 10). `followResize` sends the queue with `flushSync` and gives the ring a frame to spring in. Reverting zed 4c6fde1478 alone made both tests pass unchanged, the playback controls (#64) are not involved; the ring does end exactly on 108. Test: retained-cull-wrapper (5) plain, with GPUIX_RETAIN_VERIFY and GPUIX_RETAIN_OFF, the solid suite plain and verifying
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