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;
|
|
|
|
|
|
|
|
|
|
use wayland_server::{DisplayHandle, GlobalDispatch, backend::GlobalId};
|
|
|
|
|
|
|
|
|
|
pub struct WeftShellState {
|
|
|
|
|
_global: GlobalId,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
pub struct WeftShellWindowData {
|
|
|
|
|
pub app_id: String,
|
|
|
|
|
pub title: String,
|
|
|
|
|
pub role: String,
|
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,
|
|
|
|
|
{
|
|
|
|
|
let global = display.create_global::<D, ZweftShellManagerV1, ()>(1, ());
|
|
|
|
|
Self { _global: global }
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-11 07:12:11 +00:00
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use std::sync::atomic::Ordering;
|
|
|
|
|
use wayland_server::Resource;
|
|
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn window_data_stores_fields() {
|
|
|
|
|
let d = WeftShellWindowData {
|
|
|
|
|
app_id: "com.example.test".into(),
|
|
|
|
|
title: "Test Window".into(),
|
|
|
|
|
role: "normal".into(),
|
|
|
|
|
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(),
|
|
|
|
|
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");
|
|
|
|
|
assert_eq!(iface.version, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn window_interface_name_and_version() {
|
|
|
|
|
let iface = ZweftShellWindowV1::interface();
|
|
|
|
|
assert_eq!(iface.name, "zweft_shell_window_v1");
|
|
|
|
|
assert_eq!(iface.version, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn defunct_window_error_code() {
|
|
|
|
|
let code = server::zweft_shell_window_v1::Error::DefunctWindow as u32;
|
|
|
|
|
assert_eq!(code, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|