feat: initial low-level foundation for Gastinel Desktop (offline Rust + Vulkan)
Cette révision appartient à :
révision
a6d090fedd
32 fichiers modifiés
+2385
Aucun fichier ne correspond à votre recherche
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "gastinel-platform"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
gastinel-core = { path = "../gastinel-core" }
|
||||
@@ -0,0 +1,78 @@
|
||||
//! Direct Rendering Manager (DRM) and Kernel Mode Setting (KMS) abstractions.
|
||||
//!
|
||||
//! Handles kernel display discovery and page flipping without X11 or intermediary servers.
|
||||
|
||||
use gastinel_core::geom::Size;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DrmOutputMode {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub refresh_rate_hz: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DrmConnector {
|
||||
pub name: String,
|
||||
pub connected: bool,
|
||||
pub current_mode: DrmOutputMode,
|
||||
}
|
||||
|
||||
pub struct DrmDevice {
|
||||
pub card_path: String,
|
||||
pub connectors: Vec<DrmConnector>,
|
||||
}
|
||||
|
||||
impl DrmDevice {
|
||||
pub fn probe_outputs() -> Vec<DrmConnector> {
|
||||
// On Linux, scans /sys/class/drm/card*-*
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let mut connectors = Vec::new();
|
||||
if let Ok(entries) = std::fs::read_dir("/sys/class/drm") {
|
||||
for entry in entries.flatten() {
|
||||
let name = entry.file_name().to_string_lossy().into_owned();
|
||||
if name.starts_with("card") && name.contains('-') {
|
||||
let status_path = entry.path().join("status");
|
||||
let connected = std::fs::read_to_string(status_path)
|
||||
.map(|s| s.trim() == "connected")
|
||||
.unwrap_or(false);
|
||||
|
||||
if connected {
|
||||
connectors.push(DrmConnector {
|
||||
name,
|
||||
connected: true,
|
||||
current_mode: DrmOutputMode {
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
refresh_rate_hz: 60,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
connectors
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
vec![DrmConnector {
|
||||
name: "eDP-1 (Virtual)".to_string(),
|
||||
connected: true,
|
||||
current_mode: DrmOutputMode {
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
refresh_rate_hz: 60,
|
||||
},
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn primary_resolution(&self) -> Size {
|
||||
self.connectors
|
||||
.first()
|
||||
.map(|c| Size::new(c.current_mode.width, c.current_mode.height))
|
||||
.unwrap_or(Size::new(1920, 1080))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//! Platform and kernel integrations for Alpine Linux (musl) and cross-platform development.
|
||||
|
||||
pub mod drm;
|
||||
pub mod seatd;
|
||||
|
||||
pub use drm::{DrmConnector, DrmDevice, DrmOutputMode};
|
||||
pub use seatd::SeatSession;
|
||||
@@ -0,0 +1,51 @@
|
||||
//! Minimal, zero-dependency `seatd` IPC client for Alpine Linux / musl.
|
||||
//!
|
||||
//! Alpine Linux does not use `systemd` or `elogind`. Instead, unprivileged graphical sessions
|
||||
//! interact with `seatd` via a UNIX domain socket (`/run/seatd.sock`) to securely open
|
||||
//! `/dev/dri/card*` and `/dev/input/*` devices and manage VT switching.
|
||||
|
||||
use std::io;
|
||||
|
||||
#[repr(u16)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum SeatdOpcode {
|
||||
OpenSeat = 1,
|
||||
CloseSeat = 2,
|
||||
OpenDevice = 3,
|
||||
CloseDevice = 4,
|
||||
SwitchSession = 5,
|
||||
DisableSeat = 6,
|
||||
Ping = 7,
|
||||
}
|
||||
|
||||
pub struct SeatSession {
|
||||
pub active: bool,
|
||||
pub seat_name: String,
|
||||
}
|
||||
|
||||
impl SeatSession {
|
||||
#[cfg(unix)]
|
||||
pub fn connect() -> io::Result<Self> {
|
||||
// Under Linux, connects to /run/seatd.sock
|
||||
let sock_path = std::env::var("SEATD_SOCK").unwrap_or_else(|_| "/run/seatd.sock".to_string());
|
||||
let _stream = std::os::unix::net::UnixStream::connect(&sock_path)?;
|
||||
|
||||
Ok(Self {
|
||||
active: true,
|
||||
seat_name: "seat0".to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
pub fn connect() -> io::Result<Self> {
|
||||
// Fallback for non-Linux / development environments
|
||||
Ok(Self {
|
||||
active: true,
|
||||
seat_name: "mock-seat0".to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn is_active(&self) -> bool {
|
||||
self.active
|
||||
}
|
||||
}
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur