feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
// Non-Linux: DRM/KMS backend is unavailable; callers must use --winit.
|
|
|
|
|
#[cfg(not(target_os = "linux"))]
|
|
|
|
|
pub fn run() -> anyhow::Result<()> {
|
|
|
|
|
anyhow::bail!("DRM/KMS backend requires Linux; pass --winit for development on other platforms")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Linux DRM/KMS backend.
|
2026-03-10 20:20:28 +00:00
|
|
|
// GPU enumeration and rendering are deferred; this skeleton establishes the
|
|
|
|
|
// session, socket, and event loop that the full implementation will extend.
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
pub fn run() -> anyhow::Result<()> {
|
2026-03-10 20:20:28 +00:00
|
|
|
use std::sync::Arc;
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
|
|
|
|
|
use smithay::{
|
|
|
|
|
backend::{
|
2026-03-10 20:20:28 +00:00
|
|
|
session::{libseat::LibSeatSession, Session},
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
udev::{UdevBackend, UdevEvent},
|
|
|
|
|
},
|
2026-03-10 20:20:28 +00:00
|
|
|
reexports::calloop::{generic::Generic, EventLoop, Interest, Mode, PostAction},
|
|
|
|
|
wayland::socket::ListeningSocketSource,
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
};
|
|
|
|
|
|
2026-03-10 20:20:28 +00:00
|
|
|
use crate::state::{WeftClientState, WeftCompositorState};
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
|
2026-03-10 20:20:28 +00:00
|
|
|
let mut display =
|
|
|
|
|
smithay::reexports::wayland_server::Display::<WeftCompositorState>::new()?;
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
let display_handle = display.handle();
|
|
|
|
|
|
|
|
|
|
let mut event_loop: EventLoop<'static, WeftCompositorState> = EventLoop::try_new()?;
|
|
|
|
|
let loop_handle = event_loop.handle();
|
|
|
|
|
let loop_signal = event_loop.get_signal();
|
|
|
|
|
|
2026-03-10 20:20:28 +00:00
|
|
|
// Gain DRM device access without root via libseat.
|
|
|
|
|
let (session, _notifier) = LibSeatSession::new()
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
.map_err(|e| anyhow::anyhow!("libseat session failed: {e}"))?;
|
|
|
|
|
|
2026-03-10 20:20:28 +00:00
|
|
|
let listening_socket = ListeningSocketSource::new_auto()
|
|
|
|
|
.map_err(|e| anyhow::anyhow!("Wayland socket creation failed: {e}"))?;
|
|
|
|
|
let socket_name = listening_socket.socket_name().to_os_string();
|
|
|
|
|
std::env::set_var("WAYLAND_DISPLAY", &socket_name);
|
|
|
|
|
tracing::info!(?socket_name, "Wayland compositor socket open");
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
|
2026-03-10 20:20:28 +00:00
|
|
|
loop_handle
|
|
|
|
|
.insert_source(listening_socket, |client_stream, _, state| {
|
|
|
|
|
state
|
|
|
|
|
.display_handle
|
|
|
|
|
.insert_client(client_stream, Arc::new(WeftClientState::default()))
|
|
|
|
|
.unwrap();
|
|
|
|
|
})
|
|
|
|
|
.map_err(|e| anyhow::anyhow!("socket source insertion failed: {e}"))?;
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
|
2026-03-10 20:20:28 +00:00
|
|
|
loop_handle
|
|
|
|
|
.insert_source(
|
|
|
|
|
Generic::new(display, Interest::READ, Mode::Level),
|
|
|
|
|
|_, display, state| {
|
|
|
|
|
// Safety: the display is owned by this Generic source and is never
|
|
|
|
|
// dropped while the event loop runs.
|
|
|
|
|
unsafe {
|
|
|
|
|
display.get_mut().dispatch_clients(state).unwrap();
|
|
|
|
|
}
|
|
|
|
|
Ok(PostAction::Continue)
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
.map_err(|e| anyhow::anyhow!("display source insertion failed: {e}"))?;
|
|
|
|
|
|
|
|
|
|
// Enumerate GPU nodes via udev; hotplug events arrive through calloop.
|
|
|
|
|
let udev_backend = UdevBackend::new(session.seat())?;
|
|
|
|
|
loop_handle
|
|
|
|
|
.insert_source(udev_backend, move |event, _, _state| match event {
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
UdevEvent::Added { device_id, path } => {
|
|
|
|
|
tracing::info!(?device_id, ?path, "GPU device added");
|
|
|
|
|
}
|
|
|
|
|
UdevEvent::Changed { device_id } => {
|
|
|
|
|
tracing::debug!(?device_id, "GPU device changed");
|
|
|
|
|
}
|
|
|
|
|
UdevEvent::Removed { device_id } => {
|
|
|
|
|
tracing::info!(?device_id, "GPU device removed");
|
|
|
|
|
}
|
2026-03-10 20:20:28 +00:00
|
|
|
})
|
|
|
|
|
.map_err(|e| anyhow::anyhow!("udev source insertion failed: {e}"))?;
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
|
2026-03-10 20:20:28 +00:00
|
|
|
let mut state = WeftCompositorState::new(
|
|
|
|
|
display_handle,
|
|
|
|
|
loop_signal,
|
|
|
|
|
loop_handle,
|
|
|
|
|
session.seat(),
|
|
|
|
|
);
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
|
2026-03-10 20:20:28 +00:00
|
|
|
tracing::info!("DRM/KMS backend initialised; entering event loop");
|
|
|
|
|
event_loop.run(None, &mut state, |_| {})?;
|
feat(compositor): add weft-compositor crate
- Implement WeftCompositorState with all Wayland protocol globals:
compositor, xdg-shell, layer-shell, shm, dmabuf, output, presentation,
text-input, input-method, pointer-constraints, cursor-shape, seat.
- Implement process_input_event covering keyboard, pointer (relative +
absolute), axis, touch, and all gesture types (swipe, pinch, hold).
- Implement Winit backend with damage-tracked rendering loop and frame
callbacks.
- Add DRM/KMS backend skeleton: libseat session, udev device discovery,
calloop integration (rendering path deferred).
- Add infra/systemd/weft-compositor.service (Type=notify).
- Split CI into cross-platform and linux-only jobs.
- Exclude weft-compositor from Windows check scripts.
2026-03-10 19:56:35 +00:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|