feat: wayland feature
This commit is contained in:
@@ -31,7 +31,7 @@ send_wrapper = "0.6.0"
|
|||||||
prisma = "0.1.1"
|
prisma = "0.1.1"
|
||||||
slog = "2.7.0"
|
slog = "2.7.0"
|
||||||
slog-stdlog = "4.1.1"
|
slog-stdlog = "4.1.1"
|
||||||
xkbcommon = { version = "0.5.0", default-features = false }
|
xkbcommon = { version = "0.5.0", default-features = false, optional = true }
|
||||||
stardust-xr = "0.7.1"
|
stardust-xr = "0.7.1"
|
||||||
directories = "4.0.1"
|
directories = "4.0.1"
|
||||||
serde = { version = "1.0.145", features = ["derive"] }
|
serde = { version = "1.0.145", features = ["derive"] }
|
||||||
@@ -46,3 +46,8 @@ git = "https://github.com/Smithay/smithay.git"
|
|||||||
default-features = false
|
default-features = false
|
||||||
features = ["desktop", "renderer_gl", "wayland_frontend"]
|
features = ["desktop", "renderer_gl", "wayland_frontend"]
|
||||||
version = "*"
|
version = "*"
|
||||||
|
optional = true
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["wayland"]
|
||||||
|
wayland = ["dep:smithay", "dep:xkbcommon"]
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@@ -1,6 +1,7 @@
|
|||||||
mod core;
|
mod core;
|
||||||
mod nodes;
|
mod nodes;
|
||||||
mod objects;
|
mod objects;
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
mod wayland;
|
mod wayland;
|
||||||
|
|
||||||
use crate::core::destroy_queue;
|
use crate::core::destroy_queue;
|
||||||
@@ -8,13 +9,11 @@ use crate::nodes::{drawable, hmd, input};
|
|||||||
use crate::objects::input::mouse_pointer::MousePointer;
|
use crate::objects::input::mouse_pointer::MousePointer;
|
||||||
use crate::objects::input::sk_controller::SkController;
|
use crate::objects::input::sk_controller::SkController;
|
||||||
use crate::objects::input::sk_hand::SkHand;
|
use crate::objects::input::sk_hand::SkHand;
|
||||||
use crate::wayland::Wayland;
|
|
||||||
|
|
||||||
use self::core::eventloop::EventLoop;
|
use self::core::eventloop::EventLoop;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
use slog::Drain;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use stereokit::input::Handed;
|
use stereokit::input::Handed;
|
||||||
use stereokit::lifecycle::DepthMode;
|
use stereokit::lifecycle::DepthMode;
|
||||||
@@ -42,8 +41,6 @@ struct CliArgs {
|
|||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let project_dirs = ProjectDirs::from("", "", "stardust").unwrap();
|
let project_dirs = ProjectDirs::from("", "", "stardust").unwrap();
|
||||||
let cli_args = Arc::new(CliArgs::parse());
|
let cli_args = Arc::new(CliArgs::parse());
|
||||||
let log = ::slog::Logger::root(::slog_stdlog::StdLog.fuse(), slog::o!());
|
|
||||||
slog_stdlog::init()?;
|
|
||||||
|
|
||||||
let mut stereokit = Settings::default()
|
let mut stereokit = Settings::default()
|
||||||
.app_name("Stardust XR")
|
.app_name("Stardust XR")
|
||||||
@@ -105,11 +102,13 @@ fn main() -> Result<()> {
|
|||||||
.spawn(move || event_loop(handle_sender, event_stop_rx))?;
|
.spawn(move || event_loop(handle_sender, event_stop_rx))?;
|
||||||
let _tokio_handle = handle_receiver.blocking_recv()?.enter();
|
let _tokio_handle = handle_receiver.blocking_recv()?.enter();
|
||||||
|
|
||||||
let mut wayland = Wayland::new(log)?;
|
#[cfg(feature = "wayland")]
|
||||||
|
let mut wayland = wayland::Wayland::new()?;
|
||||||
println!("Stardust ready!");
|
println!("Stardust ready!");
|
||||||
stereokit.run(
|
stereokit.run(
|
||||||
|sk, draw_ctx| {
|
|sk, draw_ctx| {
|
||||||
hmd::frame(sk);
|
hmd::frame(sk);
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
wayland.frame(sk);
|
wayland.frame(sk);
|
||||||
destroy_queue::clear();
|
destroy_queue::clear();
|
||||||
|
|
||||||
@@ -128,6 +127,7 @@ fn main() -> Result<()> {
|
|||||||
nodes::root::Root::logic_step(sk.time_elapsed());
|
nodes::root::Root::logic_step(sk.time_elapsed());
|
||||||
drawable::draw(sk, draw_ctx);
|
drawable::draw(sk, draw_ctx);
|
||||||
|
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
wayland.make_context_current();
|
wayland.make_context_current();
|
||||||
},
|
},
|
||||||
|_| {
|
|_| {
|
||||||
@@ -135,6 +135,7 @@ fn main() -> Result<()> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
drop(wayland);
|
drop(wayland);
|
||||||
|
|
||||||
let _ = event_stop_tx.send(());
|
let _ = event_stop_tx.send(());
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ impl EnvironmentItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_path_flex(node: &Node, _calling_client: Arc<Client>, _data: &[u8]) -> Result<Vec<u8>> {
|
fn get_path_flex(node: &Node, _calling_client: Arc<Client>, _data: &[u8]) -> Result<Vec<u8>> {
|
||||||
|
#[allow(unreachable_patterns)]
|
||||||
let path: Result<String> = match &node.item.get().unwrap().specialization {
|
let path: Result<String> = match &node.item.get().unwrap().specialization {
|
||||||
ItemType::Environment(env) => Ok(env.path.clone()),
|
ItemType::Environment(env) => Ok(env.path.clone()),
|
||||||
_ => Err(anyhow!("")),
|
_ => Err(anyhow!("")),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use crate::core::node_collections::LifeLinkedNodeList;
|
|||||||
use crate::core::registry::Registry;
|
use crate::core::registry::Registry;
|
||||||
use crate::nodes::alias::AliasInfo;
|
use crate::nodes::alias::AliasInfo;
|
||||||
use crate::nodes::fields::find_field;
|
use crate::nodes::fields::find_field;
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
use crate::wayland::panel_item::{PanelItem, ITEM_TYPE_INFO_PANEL};
|
use crate::wayland::panel_item::{PanelItem, ITEM_TYPE_INFO_PANEL};
|
||||||
use anyhow::{anyhow, ensure, Result};
|
use anyhow::{anyhow, ensure, Result};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
@@ -152,6 +153,7 @@ pub trait ItemSpecialization {
|
|||||||
|
|
||||||
pub enum ItemType {
|
pub enum ItemType {
|
||||||
Environment(EnvironmentItem),
|
Environment(EnvironmentItem),
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
Panel(PanelItem),
|
Panel(PanelItem),
|
||||||
}
|
}
|
||||||
impl Deref for ItemType {
|
impl Deref for ItemType {
|
||||||
@@ -160,6 +162,7 @@ impl Deref for ItemType {
|
|||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
match self {
|
match self {
|
||||||
ItemType::Environment(item) => item,
|
ItemType::Environment(item) => item,
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
ItemType::Panel(item) => item,
|
ItemType::Panel(item) => item,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,6 +328,7 @@ pub fn create_interface(client: &Arc<Client>) {
|
|||||||
fn type_info(name: &str) -> Result<&'static TypeInfo> {
|
fn type_info(name: &str) -> Result<&'static TypeInfo> {
|
||||||
match name {
|
match name {
|
||||||
"environment" => Ok(&ITEM_TYPE_INFO_ENVIRONMENT),
|
"environment" => Ok(&ITEM_TYPE_INFO_ENVIRONMENT),
|
||||||
|
#[cfg(feature = "wayland")]
|
||||||
"panel" => Ok(&ITEM_TYPE_INFO_PANEL),
|
"panel" => Ok(&ITEM_TYPE_INFO_PANEL),
|
||||||
_ => Err(anyhow!("Invalid item type")),
|
_ => Err(anyhow!("Invalid item type")),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::wayland::state::ClientState;
|
|||||||
use anyhow::{ensure, Result};
|
use anyhow::{ensure, Result};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use slog::Logger;
|
use slog::Drain;
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{egl::EGLContext, renderer::gles2::Gles2Renderer},
|
backend::{egl::EGLContext, renderer::gles2::Gles2Renderer},
|
||||||
reexports::wayland_server::{backend::GlobalId, Display, ListeningSocket, Resource},
|
reexports::wayland_server::{backend::GlobalId, Display, ListeningSocket, Resource},
|
||||||
@@ -63,7 +63,10 @@ pub struct Wayland {
|
|||||||
state: Arc<Mutex<WaylandState>>,
|
state: Arc<Mutex<WaylandState>>,
|
||||||
}
|
}
|
||||||
impl Wayland {
|
impl Wayland {
|
||||||
pub fn new(log: Logger) -> Result<Self> {
|
pub fn new() -> Result<Self> {
|
||||||
|
let log = ::slog::Logger::root(::slog_stdlog::StdLog.fuse(), slog::o!());
|
||||||
|
slog_stdlog::init()?;
|
||||||
|
|
||||||
let egl_raw_handles = get_sk_egl()?;
|
let egl_raw_handles = get_sk_egl()?;
|
||||||
let renderer = unsafe {
|
let renderer = unsafe {
|
||||||
Gles2Renderer::new(
|
Gles2Renderer::new(
|
||||||
|
|||||||
Reference in New Issue
Block a user