rewrite built-in wayland compositor egl → vulkan

This commit is contained in:
galister
2025-12-25 21:26:38 +09:00
parent 3b6acb3673
commit 40dc33410d
34 changed files with 923 additions and 3051 deletions

View File

@@ -37,104 +37,18 @@ fn handle_result<T: Serialize>(pretty_print: bool, result: anyhow::Result<T>) {
}
}
pub async fn wvr_display_create(
state: &mut WayVRClientState,
width: u16,
height: u16,
name: String,
scale: Option<f32>,
attach_to: packet_client::AttachTo,
) {
pub async fn wvr_window_list(state: &mut WayVRClientState) {
handle_result(
state.pretty_print,
WayVRClient::fn_wvr_display_create(
WayVRClient::fn_wvr_window_list(
state.wayvr_client.clone(),
state.serial_generator.increment_get(),
packet_client::WvrDisplayCreateParams {
width,
height,
name,
scale,
attach_to,
},
)
.await
.context("failed to create display"),
);
}
pub async fn wvr_display_list(state: &mut WayVRClientState) {
handle_result(
state.pretty_print,
WayVRClient::fn_wvr_display_list(
state.wayvr_client.clone(),
state.serial_generator.increment_get(),
)
.await
.context("failed to fetch displays"),
);
}
pub async fn wvr_display_get(
state: &mut WayVRClientState,
handle: packet_server::WvrDisplayHandle,
) {
handle_result(
state.pretty_print,
WayVRClient::fn_wvr_display_get(
state.wayvr_client.clone(),
state.serial_generator.increment_get(),
handle,
)
.await
.context("failed to fetch display"),
);
}
pub async fn wvr_display_window_list(
state: &mut WayVRClientState,
handle: packet_server::WvrDisplayHandle,
) {
handle_result(
state.pretty_print,
WayVRClient::fn_wvr_display_window_list(
state.wayvr_client.clone(),
state.serial_generator.increment_get(),
handle,
)
.await
.context("failed to list window displays"),
);
}
pub async fn wvr_display_remove(
state: &mut WayVRClientState,
handle: packet_server::WvrDisplayHandle,
) {
handle_result(
state.pretty_print,
WayVRClient::fn_wvr_display_remove(
state.wayvr_client.clone(),
state.serial_generator.increment_get(),
handle,
)
.await
.context("failed to remove display"),
);
}
pub async fn wvr_display_set_visible(
state: &mut WayVRClientState,
handle: packet_server::WvrDisplayHandle,
visible: bool,
) {
handle_empty_result(
WayVRClient::fn_wvr_display_set_visible(state.wayvr_client.clone(), handle, visible)
.await
.context("failed to set display visibility"),
)
}
pub async fn wvr_window_set_visible(
state: &mut WayVRClientState,
handle: packet_server::WvrWindowHandle,

View File

@@ -10,10 +10,9 @@ use env_logger::Env;
use wayvr_ipc::{client::WayVRClient, ipc, packet_client};
use crate::helper::{
WayVRClientState, wlx_device_haptics, wlx_input_state, wlx_panel_modify, wvr_display_create,
wvr_display_get, wvr_display_list, wvr_display_remove, wvr_display_set_visible,
wvr_display_window_list, wvr_process_get, wvr_process_launch, wvr_process_list,
wvr_process_terminate, wvr_window_set_visible,
WayVRClientState, wlx_device_haptics, wlx_input_state, wlx_panel_modify, wvr_process_get,
wvr_process_launch, wvr_process_list, wvr_process_terminate, wvr_window_list,
wvr_window_set_visible,
};
mod helper;
@@ -76,12 +75,12 @@ async fn run_batch(state: &mut WayVRClientState, fail_fast: bool) -> anyhow::Res
}
async fn parse_run_line(state: &mut WayVRClientState, line: &str) -> anyhow::Result<()> {
let mut argv = shell_words::split(&line).with_context(|| format!("parse error"))?;
let mut argv = shell_words::split(line).context("parse error")?;
// clap expects argv[0] to be the binary name
argv.insert(0, env!("CARGO_PKG_NAME").to_string());
let args = Args::try_parse_from(argv).with_context(|| format!("invalid arguments"))?;
let args = Args::try_parse_from(argv).context("invalid arguments")?;
run_once(state, args).await?;
Ok(())
@@ -95,43 +94,8 @@ async fn run_once(state: &mut WayVRClientState, args: Args) -> anyhow::Result<()
Subcommands::InputState => {
wlx_input_state(state).await;
}
Subcommands::DisplayCreate {
width,
height,
name,
scale,
} => {
wvr_display_create(
state,
width,
height,
name,
scale,
packet_client::AttachTo::None,
)
.await;
}
Subcommands::DisplayList => {
wvr_display_list(state).await;
}
Subcommands::DisplayGet { handle } => {
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
wvr_display_get(state, handle).await;
}
Subcommands::DisplayWindowList { handle } => {
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
wvr_display_window_list(state, handle).await;
}
Subcommands::DisplayRemove { handle } => {
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
wvr_display_remove(state, handle).await;
}
Subcommands::DisplaySetVisible {
handle,
visible_0_or_1,
} => {
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
wvr_display_set_visible(state, handle, visible_0_or_1 != 0).await;
Subcommands::WindowList => {
wvr_window_list(state).await;
}
Subcommands::WindowSetVisible {
handle,
@@ -221,39 +185,9 @@ enum Subcommands {
},
/// Get the positions of HMD & controllers
InputState,
/// Create a new WayVR display
DisplayCreate {
width: u16,
height: u16,
name: String,
#[arg(short, long)]
scale: Option<f32>,
//attach_to: packet_client::AttachTo,
},
/// List WayVR displays
DisplayList,
/// Retrieve information about a single WayVR display
DisplayGet {
/// A display handle JSON returned by DisplayList or DisplayCreate
handle: String,
},
/// List windows attached to a WayVR display
DisplayWindowList {
/// A display handle JSON returned by DisplayList or DisplayCreate
handle: String,
},
/// List WayVR windows
WindowList,
/// Delete a WayVR display
DisplayRemove {
/// A display handle JSON returned by DisplayList or DisplayCreate
handle: String,
},
/// Change the visibility of a WayVR display
DisplaySetVisible {
/// A display handle JSON returned by DisplayList or DisplayCreate
handle: String,
visible_0_or_1: u8,
},
// DisplaySetLayout skipped
/// Change the visibility of a window on a WayVR display
WindowSetVisible {