Merge remote-tracking branch 'origin/wlvk' into next-dash-interface
[skip ci]
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::{collections::HashMap, rc::Rc};
|
||||
|
||||
use wayvr_ipc::{packet_client::WvrProcessLaunchParams, packet_server::WvrDisplayHandle};
|
||||
use wayvr_ipc::packet_client::WvrProcessLaunchParams;
|
||||
use wgui::{
|
||||
assets::AssetPath,
|
||||
components::{button::ComponentButton, checkbox::ComponentCheckbox},
|
||||
@@ -246,10 +246,6 @@ impl View {
|
||||
env,
|
||||
exec: String::from(exec),
|
||||
name: desktop_file.name,
|
||||
target_display: WvrDisplayHandle {
|
||||
generation: 12345, // stub
|
||||
idx: 12345,
|
||||
},
|
||||
args,
|
||||
userdata,
|
||||
})?;
|
||||
|
||||
@@ -26,21 +26,11 @@ pub enum AttachTo {
|
||||
pub struct WvrProcessLaunchParams {
|
||||
pub name: String,
|
||||
pub exec: String,
|
||||
pub target_display: packet_server::WvrDisplayHandle,
|
||||
pub env: Vec<String>,
|
||||
pub args: String,
|
||||
pub userdata: HashMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct WvrDisplayCreateParams {
|
||||
pub width: u16,
|
||||
pub height: u16,
|
||||
pub name: String,
|
||||
pub scale: Option<f32>,
|
||||
pub attach_to: AttachTo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct WlxHapticsParams {
|
||||
pub intensity: f32,
|
||||
|
||||
@@ -19,12 +19,6 @@ pub struct Disconnect {
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
||||
pub struct WvrDisplayHandle {
|
||||
pub idx: u32,
|
||||
pub generation: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
||||
pub struct WvrProcessHandle {
|
||||
pub idx: u32,
|
||||
@@ -37,15 +31,6 @@ pub struct WvrWindowHandle {
|
||||
pub generation: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct WvrDisplay {
|
||||
pub width: u16,
|
||||
pub height: u16,
|
||||
pub name: String,
|
||||
pub visible: bool,
|
||||
pub handle: WvrDisplayHandle,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct WvrWindow {
|
||||
pub size_x: u32,
|
||||
@@ -55,11 +40,6 @@ pub struct WvrWindow {
|
||||
pub process_handle: WvrProcessHandle,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct WvrDisplayList {
|
||||
pub list: Vec<WvrDisplay>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct WvrWindowList {
|
||||
pub list: Vec<WvrWindow>,
|
||||
@@ -91,12 +71,6 @@ pub struct StackingOptions {
|
||||
pub margins_rest: Margins,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub enum WvrDisplayWindowLayout {
|
||||
Tiling,
|
||||
Stacking(StackingOptions),
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
|
||||
pub enum WvrStateChanged {
|
||||
ProcessCreated,
|
||||
|
||||
@@ -105,7 +105,6 @@ pub async fn wvr_process_launch(
|
||||
exec: String,
|
||||
name: String,
|
||||
env: Vec<String>,
|
||||
target_display: packet_server::WvrDisplayHandle,
|
||||
args: String,
|
||||
userdata: HashMap<String, String>,
|
||||
) {
|
||||
@@ -118,7 +117,6 @@ pub async fn wvr_process_launch(
|
||||
env,
|
||||
exec,
|
||||
name,
|
||||
target_display,
|
||||
args,
|
||||
userdata,
|
||||
},
|
||||
|
||||
@@ -119,11 +119,10 @@ async fn run_once(state: &mut WayVRClientState, args: Args) -> anyhow::Result<()
|
||||
exec,
|
||||
name,
|
||||
env,
|
||||
target_display,
|
||||
args,
|
||||
} => {
|
||||
let handle = serde_json::from_str(&target_display).context("Invalid target_display")?;
|
||||
wvr_process_launch(state, exec, name, env, handle, args, HashMap::new()).await;
|
||||
let env = env.split(",").map(|s| s.to_string()).collect::<Vec<_>>();
|
||||
wvr_process_launch(state, exec, name, env, args, HashMap::new()).await;
|
||||
}
|
||||
Subcommands::Haptics {
|
||||
device,
|
||||
@@ -211,9 +210,10 @@ enum Subcommands {
|
||||
ProcessLaunch {
|
||||
exec: String,
|
||||
name: String,
|
||||
env: Vec<String>,
|
||||
/// A display handle JSON returned by DisplayList or DisplayCreate
|
||||
target_display: String,
|
||||
/// Enviroment variables, separated by comma
|
||||
#[arg(default_value = "")]
|
||||
env: String,
|
||||
#[arg(default_value = "")]
|
||||
args: String,
|
||||
},
|
||||
/// Trigger haptics on the user's controller
|
||||
|
||||
@@ -492,6 +492,7 @@ pub fn openxr_run(show_by_default: bool, headless: bool) -> Result<(), BackendEr
|
||||
}
|
||||
#[cfg(feature = "openvr")]
|
||||
TaskType::OpenVR(_) => {}
|
||||
#[cfg(feature = "wayvr")]
|
||||
TaskType::WayVR(_action) => { /* TODO */ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ impl compositor::CompositorHandler for Application {
|
||||
}
|
||||
}
|
||||
Some(BufferType::Shm) => {
|
||||
with_buffer_contents(&buffer, |data, size, buf| {
|
||||
let _ = with_buffer_contents(&buffer, |data, size, buf| {
|
||||
if let Ok(image) =
|
||||
self.image_importer.import_shm(data, size, buf)
|
||||
{
|
||||
|
||||
@@ -16,10 +16,10 @@ use smithay::{
|
||||
output::{Mode, Output},
|
||||
reexports::wayland_server::{self, backend::ClientId, protocol::wl_buffer},
|
||||
wayland::{
|
||||
compositor::{self, SurfaceData},
|
||||
compositor::{self, SurfaceData, with_states},
|
||||
dmabuf::{DmabufFeedbackBuilder, DmabufState},
|
||||
selection::data_device::DataDeviceState,
|
||||
shell::xdg::{ToplevelSurface, XdgShellState},
|
||||
shell::xdg::{ToplevelSurface, XdgShellState, XdgToplevelSurfaceData},
|
||||
shm::ShmState,
|
||||
},
|
||||
};
|
||||
@@ -45,6 +45,7 @@ use crate::{
|
||||
},
|
||||
graphics::WGfxExtras,
|
||||
ipc::{event_queue::SyncEventQueue, ipc_server, signal::WayVRSignal},
|
||||
overlays::wayvr::create_wl_window_overlay,
|
||||
state::AppState,
|
||||
subsystem::hid::{MODS_TO_KEYS, WheelDelta},
|
||||
windowing::{OverlayID, OverlaySelector},
|
||||
@@ -312,7 +313,34 @@ impl WayVR {
|
||||
.borrow_mut()
|
||||
.create_window(&toplevel, process_handle);
|
||||
|
||||
//TODO: create overlay
|
||||
let title: Arc<str> = with_states(toplevel.wl_surface(), |states| {
|
||||
states
|
||||
.data_map
|
||||
.get::<XdgToplevelSurfaceData>()
|
||||
.and_then(|t| t.lock().unwrap().title.clone())
|
||||
.map(|t| t.into())
|
||||
.unwrap_or_else(|| format!("P{}", client.pid).into())
|
||||
});
|
||||
|
||||
app.tasks.enqueue(TaskType::Overlay(OverlayTask::Create(
|
||||
OverlaySelector::Nothing,
|
||||
Box::new(move |app: &mut AppState| {
|
||||
Some(
|
||||
create_wl_window_overlay(
|
||||
title,
|
||||
app.xr_backend,
|
||||
app.wayland_server.as_ref().unwrap().clone(),
|
||||
window_handle,
|
||||
)
|
||||
.inspect_err(|e| {
|
||||
log::error!("Could not add wayland client overlay: {e:?}")
|
||||
})
|
||||
.ok()?,
|
||||
)
|
||||
}),
|
||||
)));
|
||||
|
||||
//TODO: populate window_to_overlay
|
||||
|
||||
app.wayvr_signals.send(WayVRSignal::BroadcastStateChanged(
|
||||
packet_server::WvrStateChanged::WindowCreated,
|
||||
@@ -346,6 +374,8 @@ impl WayVR {
|
||||
if let Some(process) = self.state.processes.get_mut(&process_handle) {
|
||||
process.terminate();
|
||||
}
|
||||
|
||||
//TODO: force drop related overlays
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -540,9 +570,11 @@ pub struct SurfaceBufWithImage {
|
||||
}
|
||||
|
||||
impl SurfaceBufWithImage {
|
||||
#[allow(invalid_value)]
|
||||
fn apply_to_surface(self, surface_data: &SurfaceData) {
|
||||
let container = surface_data.data_map.get_or_insert(|| unsafe {
|
||||
SurfaceBufWithImageContainer {
|
||||
// safe because we're replacing right after
|
||||
inner: RefCell::new(MaybeUninit::uninit().assume_init()),
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ pub struct ScreenBackend {
|
||||
}
|
||||
|
||||
impl ScreenBackend {
|
||||
pub fn new_raw(
|
||||
pub(super) fn new_raw(
|
||||
name: Arc<str>,
|
||||
xr_backend: XrBackend,
|
||||
capture: Box<dyn WlxCapture<WlxCaptureIn, WlxCaptureOut>>,
|
||||
|
||||
@@ -3,7 +3,10 @@ use smithay::wayland::compositor::with_states;
|
||||
use std::{cell::RefCell, collections::HashMap, rc::Rc, sync::Arc};
|
||||
use vulkano::image::view::ImageView;
|
||||
use wgui::gfx::WGfx;
|
||||
use wlx_common::overlays::{BackendAttrib, BackendAttribValue, StereoMode};
|
||||
use wlx_common::{
|
||||
overlays::{BackendAttrib, BackendAttribValue, StereoMode},
|
||||
windowing::{OverlayWindowState, Positioning},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
backend::{
|
||||
@@ -15,13 +18,14 @@ use crate::{
|
||||
ipc::{event_queue::SyncEventQueue, signal::WayVRSignal},
|
||||
overlays::screen::capture::ScreenPipeline,
|
||||
state::{self, AppState},
|
||||
subsystem::hid::WheelDelta,
|
||||
subsystem::{hid::WheelDelta, input::KeyboardFocus},
|
||||
windowing::{
|
||||
OverlayID,
|
||||
backend::{
|
||||
FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender,
|
||||
ui_transform,
|
||||
},
|
||||
window::{OverlayCategory, OverlayWindowConfig},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -44,6 +48,35 @@ impl WayVRData {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_wl_window_overlay(
|
||||
name: Arc<str>,
|
||||
xr_backend: XrBackend,
|
||||
wayvr: Rc<RefCell<WayVRData>>,
|
||||
window: wayvr::window::WindowHandle,
|
||||
) -> anyhow::Result<OverlayWindowConfig> {
|
||||
Ok(OverlayWindowConfig {
|
||||
name: name.clone(),
|
||||
default_state: OverlayWindowState {
|
||||
grabbable: true,
|
||||
interactable: true,
|
||||
positioning: Positioning::Floating,
|
||||
curvature: Some(0.15),
|
||||
transform: Affine3A::from_scale_rotation_translation(
|
||||
Vec3::ONE,
|
||||
Quat::IDENTITY,
|
||||
vec3(0.0, 0.0, -0.4),
|
||||
),
|
||||
..OverlayWindowState::default()
|
||||
},
|
||||
keyboard_focus: Some(KeyboardFocus::WayVR),
|
||||
category: OverlayCategory::WayVR,
|
||||
show_on_spawn: true,
|
||||
..OverlayWindowConfig::from_backend(Box::new(WayVRBackend::new(
|
||||
name, xr_backend, wayvr, window,
|
||||
)?))
|
||||
})
|
||||
}
|
||||
|
||||
pub struct WayVRBackend {
|
||||
name: Arc<str>,
|
||||
pipeline: Option<ScreenPipeline>,
|
||||
@@ -59,7 +92,7 @@ pub struct WayVRBackend {
|
||||
}
|
||||
|
||||
impl WayVRBackend {
|
||||
pub fn new(
|
||||
fn new(
|
||||
name: Arc<str>,
|
||||
xr_backend: XrBackend,
|
||||
wayvr: Rc<RefCell<WayVRData>>,
|
||||
|
||||
@@ -532,6 +532,7 @@ impl<T> OverlayWindowManager<T> {
|
||||
match selector {
|
||||
OverlaySelector::Id(id) => Some(*id),
|
||||
OverlaySelector::Name(name) => self.lookup(name),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,6 +552,7 @@ impl<T> OverlayWindowManager<T> {
|
||||
let id = match selector {
|
||||
OverlaySelector::Id(id) => *id,
|
||||
OverlaySelector::Name(name) => self.lookup(name)?,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
let ret_val = self.overlays.remove(id);
|
||||
|
||||
@@ -15,6 +15,7 @@ new_key_type! {
|
||||
pub enum OverlaySelector {
|
||||
Id(OverlayID),
|
||||
Name(Arc<str>),
|
||||
Nothing,
|
||||
}
|
||||
|
||||
pub const Z_ORDER_TOAST: u32 = 71;
|
||||
|
||||
Reference in New Issue
Block a user