feat(compositor): implement weft-shell-protocol server side
Add the WEFT compositor-shell Wayland protocol and wire it into the
compositor state.
Protocol definition:
- protocol/weft-shell-unstable-v1.xml: defines zweft_shell_manager_v1
(global, bound once by servo-shell) and zweft_shell_window_v1
(per-window slot). Requests: destroy, create_window,
update_metadata, set_geometry. Events: configure, focus_changed,
window_closed, presentation_feedback.
Generated code + bindings:
- crates/weft-compositor/src/protocols/mod.rs: uses wayland-scanner
generate_interfaces! inside a __interfaces sub-module and
generate_server_code! at the server module level, following the
wayland-protocols-wlr crate structure. Exports WeftShellState
(holds the GlobalId) and WeftShellWindowData (per-window user data).
Server-side dispatch (state.rs):
- GlobalDispatch<ZweftShellManagerV1, ()>: binds the global, inits
each bound resource with unit user data.
- Dispatch<ZweftShellManagerV1, ()>: handles create_window by
initialising a ZweftShellWindowV1 and sending an initial configure.
- Dispatch<ZweftShellWindowV1, WeftShellWindowData>: handles
update_metadata (stores advisory data) and set_geometry (echoes
compositor-adjusted configure back to client).
WeftCompositorState.weft_shell_state initialised in new() alongside
all other protocol globals.
New direct deps in weft-compositor: wayland-scanner, wayland-server,
wayland-backend, bitflags (all version-matched to Smithay 0.7).
2026-03-11 06:59:56 +00:00
|
|
|
#[allow(dead_code, non_camel_case_types, unused_unsafe, unused_variables)]
|
|
|
|
|
#[allow(non_upper_case_globals, non_snake_case, unused_imports)]
|
|
|
|
|
#[allow(missing_docs, clippy::all)]
|
|
|
|
|
pub mod server {
|
|
|
|
|
use wayland_server;
|
|
|
|
|
use wayland_server::protocol::*;
|
|
|
|
|
|
|
|
|
|
pub mod __interfaces {
|
|
|
|
|
use wayland_server::protocol::__interfaces::*;
|
|
|
|
|
wayland_scanner::generate_interfaces!("../../protocol/weft-shell-unstable-v1.xml");
|
|
|
|
|
}
|
|
|
|
|
use self::__interfaces::*;
|
|
|
|
|
|
|
|
|
|
wayland_scanner::generate_server_code!("../../protocol/weft-shell-unstable-v1.xml");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub use server::zweft_shell_manager_v1::ZweftShellManagerV1;
|
|
|
|
|
pub use server::zweft_shell_window_v1::ZweftShellWindowV1;
|
|
|
|
|
|
feat: appd IPC relay, WIT interfaces, UI kit, gesture routing, and CI hardening
- weft-appd: per-session IPC socket paths; bidirectional Wasm-HTML JSON relay
via spawn_ipc_relay; SO_PEERCRED UID check on Unix socket connections;
PanelGesture request and NavigationGesture broadcast for compositor gestures
- weft-runtime: weft:app/ipc, weft:app/fetch, weft:app/notifications WIT
interfaces; IpcState non-blocking Unix socket host functions; ureq-backed
net:fetch host function (net-fetch feature); notify-send notifications host
- weft-file-portal: spawn a thread per accepted connection for concurrent access
- weft-app-shell: weft-system:// URL translation; WEFT UI Kit UserScript
injection; resolve_weft_system_url helper
- weft-servo-shell: forward compositor navigation gestures to weft-appd
WebSocket as PanelGesture; WEFT UI Kit UserScript injection
- infra/shell: weft-ui-kit.js with 11 custom elements (weft-button, weft-card,
weft-dialog, weft-icon, weft-list, weft-list-item, weft-menu, weft-menu-item,
weft-progress, weft-input, weft-label); system-ui.html handles
NAVIGATION_GESTURE messages and dispatches weft:navigation-gesture CustomEvent
- infra/systemd: add missing env vars to weft-appd.service; correct
servo-shell.service binary path and system-ui.html argument
- .github/workflows/ci.yml: exclude weft-servo-shell and weft-app-shell from
cross-platform job; add them to linux-only job with libsystemd-dev dependency
2026-03-12 11:49:45 +00:00
|
|
|
use wayland_server::{DisplayHandle, GlobalDispatch, Resource, backend::GlobalId};
|
feat(compositor): implement weft-shell-protocol server side
Add the WEFT compositor-shell Wayland protocol and wire it into the
compositor state.
Protocol definition:
- protocol/weft-shell-unstable-v1.xml: defines zweft_shell_manager_v1
(global, bound once by servo-shell) and zweft_shell_window_v1
(per-window slot). Requests: destroy, create_window,
update_metadata, set_geometry. Events: configure, focus_changed,
window_closed, presentation_feedback.
Generated code + bindings:
- crates/weft-compositor/src/protocols/mod.rs: uses wayland-scanner
generate_interfaces! inside a __interfaces sub-module and
generate_server_code! at the server module level, following the
wayland-protocols-wlr crate structure. Exports WeftShellState
(holds the GlobalId) and WeftShellWindowData (per-window user data).
Server-side dispatch (state.rs):
- GlobalDispatch<ZweftShellManagerV1, ()>: binds the global, inits
each bound resource with unit user data.
- Dispatch<ZweftShellManagerV1, ()>: handles create_window by
initialising a ZweftShellWindowV1 and sending an initial configure.
- Dispatch<ZweftShellWindowV1, WeftShellWindowData>: handles
update_metadata (stores advisory data) and set_geometry (echoes
compositor-adjusted configure back to client).
WeftCompositorState.weft_shell_state initialised in new() alongside
all other protocol globals.
New direct deps in weft-compositor: wayland-scanner, wayland-server,
wayland-backend, bitflags (all version-matched to Smithay 0.7).
2026-03-11 06:59:56 +00:00
|
|
|
|
|
|
|
|
pub struct WeftShellState {
|
|
|
|
|
_global: GlobalId,
|
feat: appd IPC relay, WIT interfaces, UI kit, gesture routing, and CI hardening
- weft-appd: per-session IPC socket paths; bidirectional Wasm-HTML JSON relay
via spawn_ipc_relay; SO_PEERCRED UID check on Unix socket connections;
PanelGesture request and NavigationGesture broadcast for compositor gestures
- weft-runtime: weft:app/ipc, weft:app/fetch, weft:app/notifications WIT
interfaces; IpcState non-blocking Unix socket host functions; ureq-backed
net:fetch host function (net-fetch feature); notify-send notifications host
- weft-file-portal: spawn a thread per accepted connection for concurrent access
- weft-app-shell: weft-system:// URL translation; WEFT UI Kit UserScript
injection; resolve_weft_system_url helper
- weft-servo-shell: forward compositor navigation gestures to weft-appd
WebSocket as PanelGesture; WEFT UI Kit UserScript injection
- infra/shell: weft-ui-kit.js with 11 custom elements (weft-button, weft-card,
weft-dialog, weft-icon, weft-list, weft-list-item, weft-menu, weft-menu-item,
weft-progress, weft-input, weft-label); system-ui.html handles
NAVIGATION_GESTURE messages and dispatches weft:navigation-gesture CustomEvent
- infra/systemd: add missing env vars to weft-appd.service; correct
servo-shell.service binary path and system-ui.html argument
- .github/workflows/ci.yml: exclude weft-servo-shell and weft-app-shell from
cross-platform job; add them to linux-only job with libsystemd-dev dependency
2026-03-12 11:49:45 +00:00
|
|
|
panels: Vec<ZweftShellWindowV1>,
|
feat(compositor): implement weft-shell-protocol server side
Add the WEFT compositor-shell Wayland protocol and wire it into the
compositor state.
Protocol definition:
- protocol/weft-shell-unstable-v1.xml: defines zweft_shell_manager_v1
(global, bound once by servo-shell) and zweft_shell_window_v1
(per-window slot). Requests: destroy, create_window,
update_metadata, set_geometry. Events: configure, focus_changed,
window_closed, presentation_feedback.
Generated code + bindings:
- crates/weft-compositor/src/protocols/mod.rs: uses wayland-scanner
generate_interfaces! inside a __interfaces sub-module and
generate_server_code! at the server module level, following the
wayland-protocols-wlr crate structure. Exports WeftShellState
(holds the GlobalId) and WeftShellWindowData (per-window user data).
Server-side dispatch (state.rs):
- GlobalDispatch<ZweftShellManagerV1, ()>: binds the global, inits
each bound resource with unit user data.
- Dispatch<ZweftShellManagerV1, ()>: handles create_window by
initialising a ZweftShellWindowV1 and sending an initial configure.
- Dispatch<ZweftShellWindowV1, WeftShellWindowData>: handles
update_metadata (stores advisory data) and set_geometry (echoes
compositor-adjusted configure back to client).
WeftCompositorState.weft_shell_state initialised in new() alongside
all other protocol globals.
New direct deps in weft-compositor: wayland-scanner, wayland-server,
wayland-backend, bitflags (all version-matched to Smithay 0.7).
2026-03-11 06:59:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct WeftShellWindowData {
|
|
|
|
|
pub app_id: String,
|
|
|
|
|
pub title: String,
|
|
|
|
|
pub role: String,
|
2026-03-11 13:33:17 +00:00
|
|
|
pub surface: Option<wayland_server::protocol::wl_surface::WlSurface>,
|
2026-03-11 07:12:11 +00:00
|
|
|
pub closed: std::sync::atomic::AtomicBool,
|
feat(compositor): implement weft-shell-protocol server side
Add the WEFT compositor-shell Wayland protocol and wire it into the
compositor state.
Protocol definition:
- protocol/weft-shell-unstable-v1.xml: defines zweft_shell_manager_v1
(global, bound once by servo-shell) and zweft_shell_window_v1
(per-window slot). Requests: destroy, create_window,
update_metadata, set_geometry. Events: configure, focus_changed,
window_closed, presentation_feedback.
Generated code + bindings:
- crates/weft-compositor/src/protocols/mod.rs: uses wayland-scanner
generate_interfaces! inside a __interfaces sub-module and
generate_server_code! at the server module level, following the
wayland-protocols-wlr crate structure. Exports WeftShellState
(holds the GlobalId) and WeftShellWindowData (per-window user data).
Server-side dispatch (state.rs):
- GlobalDispatch<ZweftShellManagerV1, ()>: binds the global, inits
each bound resource with unit user data.
- Dispatch<ZweftShellManagerV1, ()>: handles create_window by
initialising a ZweftShellWindowV1 and sending an initial configure.
- Dispatch<ZweftShellWindowV1, WeftShellWindowData>: handles
update_metadata (stores advisory data) and set_geometry (echoes
compositor-adjusted configure back to client).
WeftCompositorState.weft_shell_state initialised in new() alongside
all other protocol globals.
New direct deps in weft-compositor: wayland-scanner, wayland-server,
wayland-backend, bitflags (all version-matched to Smithay 0.7).
2026-03-11 06:59:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl WeftShellState {
|
|
|
|
|
pub fn new<D>(display: &DisplayHandle) -> Self
|
|
|
|
|
where
|
|
|
|
|
D: GlobalDispatch<ZweftShellManagerV1, ()>,
|
|
|
|
|
D: 'static,
|
|
|
|
|
{
|
feat: appd IPC relay, WIT interfaces, UI kit, gesture routing, and CI hardening
- weft-appd: per-session IPC socket paths; bidirectional Wasm-HTML JSON relay
via spawn_ipc_relay; SO_PEERCRED UID check on Unix socket connections;
PanelGesture request and NavigationGesture broadcast for compositor gestures
- weft-runtime: weft:app/ipc, weft:app/fetch, weft:app/notifications WIT
interfaces; IpcState non-blocking Unix socket host functions; ureq-backed
net:fetch host function (net-fetch feature); notify-send notifications host
- weft-file-portal: spawn a thread per accepted connection for concurrent access
- weft-app-shell: weft-system:// URL translation; WEFT UI Kit UserScript
injection; resolve_weft_system_url helper
- weft-servo-shell: forward compositor navigation gestures to weft-appd
WebSocket as PanelGesture; WEFT UI Kit UserScript injection
- infra/shell: weft-ui-kit.js with 11 custom elements (weft-button, weft-card,
weft-dialog, weft-icon, weft-list, weft-list-item, weft-menu, weft-menu-item,
weft-progress, weft-input, weft-label); system-ui.html handles
NAVIGATION_GESTURE messages and dispatches weft:navigation-gesture CustomEvent
- infra/systemd: add missing env vars to weft-appd.service; correct
servo-shell.service binary path and system-ui.html argument
- .github/workflows/ci.yml: exclude weft-servo-shell and weft-app-shell from
cross-platform job; add them to linux-only job with libsystemd-dev dependency
2026-03-12 11:49:45 +00:00
|
|
|
let global = display.create_global::<D, ZweftShellManagerV1, ()>(2, ());
|
|
|
|
|
Self {
|
|
|
|
|
_global: global,
|
|
|
|
|
panels: Vec::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn add_panel(&mut self, window: ZweftShellWindowV1) {
|
|
|
|
|
self.panels.push(window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn reconfigure_panels(&self, x: i32, y: i32, width: i32, height: i32) {
|
|
|
|
|
for panel in &self.panels {
|
|
|
|
|
if panel.is_alive() {
|
|
|
|
|
panel.configure(x, y, width, height, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn send_navigation_gesture_to_panels(
|
|
|
|
|
&self,
|
|
|
|
|
gesture_type: u32,
|
|
|
|
|
fingers: u32,
|
|
|
|
|
dx: f64,
|
|
|
|
|
dy: f64,
|
|
|
|
|
) {
|
|
|
|
|
for panel in &self.panels {
|
|
|
|
|
if panel.is_alive() && panel.version() >= 2 {
|
|
|
|
|
panel.navigation_gesture(gesture_type, fingers, dx, dy);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn retain_alive_panels(&mut self) {
|
|
|
|
|
self.panels.retain(|p| p.is_alive());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn panels(&self) -> impl Iterator<Item = &ZweftShellWindowV1> {
|
|
|
|
|
self.panels.iter()
|
feat(compositor): implement weft-shell-protocol server side
Add the WEFT compositor-shell Wayland protocol and wire it into the
compositor state.
Protocol definition:
- protocol/weft-shell-unstable-v1.xml: defines zweft_shell_manager_v1
(global, bound once by servo-shell) and zweft_shell_window_v1
(per-window slot). Requests: destroy, create_window,
update_metadata, set_geometry. Events: configure, focus_changed,
window_closed, presentation_feedback.
Generated code + bindings:
- crates/weft-compositor/src/protocols/mod.rs: uses wayland-scanner
generate_interfaces! inside a __interfaces sub-module and
generate_server_code! at the server module level, following the
wayland-protocols-wlr crate structure. Exports WeftShellState
(holds the GlobalId) and WeftShellWindowData (per-window user data).
Server-side dispatch (state.rs):
- GlobalDispatch<ZweftShellManagerV1, ()>: binds the global, inits
each bound resource with unit user data.
- Dispatch<ZweftShellManagerV1, ()>: handles create_window by
initialising a ZweftShellWindowV1 and sending an initial configure.
- Dispatch<ZweftShellWindowV1, WeftShellWindowData>: handles
update_metadata (stores advisory data) and set_geometry (echoes
compositor-adjusted configure back to client).
WeftCompositorState.weft_shell_state initialised in new() alongside
all other protocol globals.
New direct deps in weft-compositor: wayland-scanner, wayland-server,
wayland-backend, bitflags (all version-matched to Smithay 0.7).
2026-03-11 06:59:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-11 07:12:11 +00:00
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use std::sync::atomic::Ordering;
|
|
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn window_data_stores_fields() {
|
|
|
|
|
let d = WeftShellWindowData {
|
|
|
|
|
app_id: "com.example.test".into(),
|
|
|
|
|
title: "Test Window".into(),
|
|
|
|
|
role: "normal".into(),
|
2026-03-11 13:33:17 +00:00
|
|
|
surface: None,
|
2026-03-11 07:12:11 +00:00
|
|
|
closed: std::sync::atomic::AtomicBool::new(false),
|
|
|
|
|
};
|
|
|
|
|
assert_eq!(d.app_id, "com.example.test");
|
|
|
|
|
assert_eq!(d.title, "Test Window");
|
|
|
|
|
assert_eq!(d.role, "normal");
|
|
|
|
|
assert!(!d.closed.load(Ordering::Relaxed));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn closed_flag_transition() {
|
|
|
|
|
let d = WeftShellWindowData {
|
|
|
|
|
app_id: String::new(),
|
|
|
|
|
title: String::new(),
|
|
|
|
|
role: String::new(),
|
2026-03-11 13:33:17 +00:00
|
|
|
surface: None,
|
2026-03-11 07:12:11 +00:00
|
|
|
closed: std::sync::atomic::AtomicBool::new(false),
|
|
|
|
|
};
|
|
|
|
|
assert!(!d.closed.load(Ordering::Relaxed));
|
|
|
|
|
d.closed.store(true, Ordering::Relaxed);
|
|
|
|
|
assert!(d.closed.load(Ordering::Relaxed));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn manager_interface_name_and_version() {
|
|
|
|
|
let iface = ZweftShellManagerV1::interface();
|
|
|
|
|
assert_eq!(iface.name, "zweft_shell_manager_v1");
|
feat: appd IPC relay, WIT interfaces, UI kit, gesture routing, and CI hardening
- weft-appd: per-session IPC socket paths; bidirectional Wasm-HTML JSON relay
via spawn_ipc_relay; SO_PEERCRED UID check on Unix socket connections;
PanelGesture request and NavigationGesture broadcast for compositor gestures
- weft-runtime: weft:app/ipc, weft:app/fetch, weft:app/notifications WIT
interfaces; IpcState non-blocking Unix socket host functions; ureq-backed
net:fetch host function (net-fetch feature); notify-send notifications host
- weft-file-portal: spawn a thread per accepted connection for concurrent access
- weft-app-shell: weft-system:// URL translation; WEFT UI Kit UserScript
injection; resolve_weft_system_url helper
- weft-servo-shell: forward compositor navigation gestures to weft-appd
WebSocket as PanelGesture; WEFT UI Kit UserScript injection
- infra/shell: weft-ui-kit.js with 11 custom elements (weft-button, weft-card,
weft-dialog, weft-icon, weft-list, weft-list-item, weft-menu, weft-menu-item,
weft-progress, weft-input, weft-label); system-ui.html handles
NAVIGATION_GESTURE messages and dispatches weft:navigation-gesture CustomEvent
- infra/systemd: add missing env vars to weft-appd.service; correct
servo-shell.service binary path and system-ui.html argument
- .github/workflows/ci.yml: exclude weft-servo-shell and weft-app-shell from
cross-platform job; add them to linux-only job with libsystemd-dev dependency
2026-03-12 11:49:45 +00:00
|
|
|
assert_eq!(iface.version, 2);
|
2026-03-11 07:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn window_interface_name_and_version() {
|
|
|
|
|
let iface = ZweftShellWindowV1::interface();
|
|
|
|
|
assert_eq!(iface.name, "zweft_shell_window_v1");
|
feat: appd IPC relay, WIT interfaces, UI kit, gesture routing, and CI hardening
- weft-appd: per-session IPC socket paths; bidirectional Wasm-HTML JSON relay
via spawn_ipc_relay; SO_PEERCRED UID check on Unix socket connections;
PanelGesture request and NavigationGesture broadcast for compositor gestures
- weft-runtime: weft:app/ipc, weft:app/fetch, weft:app/notifications WIT
interfaces; IpcState non-blocking Unix socket host functions; ureq-backed
net:fetch host function (net-fetch feature); notify-send notifications host
- weft-file-portal: spawn a thread per accepted connection for concurrent access
- weft-app-shell: weft-system:// URL translation; WEFT UI Kit UserScript
injection; resolve_weft_system_url helper
- weft-servo-shell: forward compositor navigation gestures to weft-appd
WebSocket as PanelGesture; WEFT UI Kit UserScript injection
- infra/shell: weft-ui-kit.js with 11 custom elements (weft-button, weft-card,
weft-dialog, weft-icon, weft-list, weft-list-item, weft-menu, weft-menu-item,
weft-progress, weft-input, weft-label); system-ui.html handles
NAVIGATION_GESTURE messages and dispatches weft:navigation-gesture CustomEvent
- infra/systemd: add missing env vars to weft-appd.service; correct
servo-shell.service binary path and system-ui.html argument
- .github/workflows/ci.yml: exclude weft-servo-shell and weft-app-shell from
cross-platform job; add them to linux-only job with libsystemd-dev dependency
2026-03-12 11:49:45 +00:00
|
|
|
assert_eq!(iface.version, 2);
|
2026-03-11 07:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn defunct_window_error_code() {
|
|
|
|
|
let code = server::zweft_shell_window_v1::Error::DefunctWindow as u32;
|
|
|
|
|
assert_eq!(code, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|