implement spawn positioning

This commit is contained in:
galister
2026-01-09 00:59:50 +09:00
parent 437840fecb
commit 9fc5e8c8b0
8 changed files with 36 additions and 10 deletions

View File

@@ -169,7 +169,7 @@ impl View {
//radio_orientation.set_value(orientation_mode.as_ref())?; //radio_orientation.set_value(orientation_mode.as_ref())?;
//tasks.push(Task::SetOrientation(orientation_mode)); //tasks.push(Task::SetOrientation(orientation_mode));
let pos_mode = PosMode::Floating; let pos_mode = PosMode::Anchored;
// TODO: configurable defaults ? // TODO: configurable defaults ?
//radio_pos.set_value(pos_mode.as_ref())?; //radio_pos.set_value(pos_mode.as_ref())?;
//tasks.push(Task::SetPos(pos_mode)); //tasks.push(Task::SetPos(pos_mode));
@@ -359,7 +359,7 @@ impl View {
}; };
let pos_mode = match params.pos_mode { let pos_mode = match params.pos_mode {
PosMode::Floating => PositionMode::Anchor, PosMode::Floating => PositionMode::Float,
PosMode::Anchored => PositionMode::Anchor, PosMode::Anchored => PositionMode::Anchor,
PosMode::Static => PositionMode::Static, PosMode::Static => PositionMode::Static,
}; };

View File

@@ -13,7 +13,7 @@ pub struct Handshake {
pub client_name: String, pub client_name: String,
} }
#[derive(Debug, Clone, Deserialize, Serialize)] #[derive(Debug, Clone, Copy, Deserialize, Serialize)]
pub enum PositionMode { pub enum PositionMode {
Float, Float,
Anchor, Anchor,

View File

@@ -32,7 +32,7 @@ use std::{
}; };
use time::get_millis; use time::get_millis;
use vulkano::image::view::ImageView; use vulkano::image::view::ImageView;
use wayvr_ipc::packet_server; use wayvr_ipc::{packet_client::PositionMode, packet_server};
use wgui::gfx::WGfx; use wgui::gfx::WGfx;
use wlx_capture::frame::Transform; use wlx_capture::frame::Transform;
use wlx_common::desktop_finder::DesktopFinder; use wlx_common::desktop_finder::DesktopFinder;
@@ -300,15 +300,16 @@ impl WvrServerState {
}; };
// Size, icon & fallback title comes from process // Size, icon & fallback title comes from process
let ([size_x, size_y], fallback_title, icon, is_cage) = let ([size_x, size_y], pos, fallback_title, icon, is_cage) =
match wvr_server.processes.get(&process_handle) { match wvr_server.processes.get(&process_handle) {
Some(Process::Managed(p)) => ( Some(Process::Managed(p)) => (
p.resolution, p.resolution,
p.pos_mode,
Some(p.app_name.clone()), Some(p.app_name.clone()),
p.icon.as_ref().cloned(), p.icon.as_ref().cloned(),
p.exec_path.ends_with("cage"), p.exec_path.ends_with("cage"),
), ),
_ => ([1920, 1080], None, None, false), _ => ([1920, 1080], PositionMode::Float, None, None, false),
}; };
let window_handle = wvr_server.wm.create_window( let window_handle = wvr_server.wm.create_window(
@@ -373,6 +374,7 @@ impl WvrServerState {
window_handle, window_handle,
icon, icon,
[size_x, size_y], [size_x, size_y],
pos,
) )
.context("Could not create WvrWindow overlay") .context("Could not create WvrWindow overlay")
.inspect_err(|e| log::warn!("{e:?}")) .inspect_err(|e| log::warn!("{e:?}"))
@@ -571,6 +573,7 @@ impl WvrServerState {
args: &[&str], args: &[&str],
env: &[(&str, &str)], env: &[(&str, &str)],
resolution: [u32; 2], resolution: [u32; 2],
pos_mode: PositionMode,
working_dir: Option<&str>, working_dir: Option<&str>,
icon: Option<&str>, icon: Option<&str>,
userdata: HashMap<String, String>, userdata: HashMap<String, String>,
@@ -606,6 +609,7 @@ impl WvrServerState {
.collect(), .collect(),
icon: icon.map(Arc::from), icon: icon.map(Arc::from),
resolution, resolution,
pos_mode,
})); }));
self.signals.send(WayVRSignal::BroadcastStateChanged( self.signals.send(WayVRSignal::BroadcastStateChanged(

View File

@@ -1,6 +1,6 @@
use std::{collections::HashMap, io::Read, sync::Arc}; use std::{collections::HashMap, io::Read, sync::Arc};
use wayvr_ipc::packet_server; use wayvr_ipc::{packet_client, packet_server};
use crate::gen_id; use crate::gen_id;
@@ -15,6 +15,7 @@ pub struct WayVRProcess {
pub env: Vec<(String, String)>, pub env: Vec<(String, String)>,
pub working_dir: Option<String>, pub working_dir: Option<String>,
pub resolution: [u32; 2], pub resolution: [u32; 2],
pub pos_mode: packet_client::PositionMode,
pub icon: Option<Arc<str>>, pub icon: Option<Arc<str>>,
pub userdata: HashMap<String, String>, pub userdata: HashMap<String, String>,

View File

@@ -244,6 +244,7 @@ impl Connection {
&args_vec, &args_vec,
&env_vec, &env_vec,
packet_params.resolution, packet_params.resolution,
packet_params.pos_mode,
None, None,
packet_params.icon.as_deref(), packet_params.icon.as_deref(),
packet_params.userdata, packet_params.userdata,

View File

@@ -365,6 +365,7 @@ impl DashInterface<AppState> for DashInterfaceLive {
&args_vec, &args_vec,
&env_vec, &env_vec,
params.resolution, params.resolution,
params.pos_mode,
None, None,
params.icon.as_deref(), params.icon.as_deref(),
params.userdata, params.userdata,

View File

@@ -1,3 +1,4 @@
use chrono_tz::PST8PDT;
use glam::{Affine2, Affine3A, Quat, Vec2, Vec3, vec2, vec3}; use glam::{Affine2, Affine3A, Quat, Vec2, Vec3, vec2, vec3};
use smithay::{ use smithay::{
desktop::PopupManager, desktop::PopupManager,
@@ -7,6 +8,7 @@ use std::{ops::RangeInclusive, sync::Arc};
use vulkano::{ use vulkano::{
buffer::BufferUsage, image::view::ImageView, pipeline::graphics::color_blend::AttachmentBlend, buffer::BufferUsage, image::view::ImageView, pipeline::graphics::color_blend::AttachmentBlend,
}; };
use wayvr_ipc::packet_client::PositionMode;
use wgui::{ use wgui::{
components::button::ComponentButton, components::button::ComponentButton,
event::EventCallback, event::EventCallback,
@@ -58,21 +60,32 @@ pub fn create_wl_window_overlay(
window: wayvr::window::WindowHandle, window: wayvr::window::WindowHandle,
icon: Arc<str>, icon: Arc<str>,
size: [u32; 2], size: [u32; 2],
pos_mode: PositionMode,
) -> anyhow::Result<OverlayWindowConfig> { ) -> anyhow::Result<OverlayWindowConfig> {
let scale = size[0].max(size[1]) as f32 / 1920.0; let scale = size[0].max(size[1]) as f32 / 1920.0;
let curve_scale = size[0] as f32 / 1920.0; let curve_scale = size[0] as f32 / 1920.0;
let z_dist = if matches!(pos_mode, PositionMode::Anchor) {
0.0
} else {
-0.95
};
Ok(OverlayWindowConfig { Ok(OverlayWindowConfig {
name: name.clone(), name: name.clone(),
default_state: OverlayWindowState { default_state: OverlayWindowState {
grabbable: true, grabbable: true,
interactable: true, interactable: true,
positioning: Positioning::Floating, positioning: match pos_mode {
PositionMode::Float => Positioning::Floating,
PositionMode::Anchor => Positioning::Anchored,
PositionMode::Static => Positioning::Static,
},
curvature: Some(0.15 * curve_scale), curvature: Some(0.15 * curve_scale),
transform: Affine3A::from_scale_rotation_translation( transform: Affine3A::from_scale_rotation_translation(
Vec3::ONE * scale, Vec3::ONE * scale,
Quat::IDENTITY, Quat::IDENTITY,
vec3(0.0, 0.0, -0.95), vec3(0.0, 0.0, z_dist),
), ),
..OverlayWindowState::default() ..OverlayWindowState::default()
}, },

View File

@@ -204,7 +204,13 @@ impl OverlayWindowConfig {
hand, align_to_hmd, .. hand, align_to_hmd, ..
} => (app.input_state.pointers[hand as usize].pose, align_to_hmd), } => (app.input_state.pointers[hand as usize].pose, align_to_hmd),
Positioning::Anchored => (app.anchor, false), Positioning::Anchored => (app.anchor, false),
Positioning::Static => return, Positioning::Static => {
if hard_reset {
(app.input_state.hmd, false)
} else {
return;
}
}
}; };
if hard_reset { if hard_reset {