feat: add wayvrctl ipc for overlay show hide (#338)

This commit is contained in:
Amos Wong
2026-01-04 20:53:47 +08:00
committed by GitHub
parent 36f64c5027
commit dd3486f06b
7 changed files with 41 additions and 1 deletions

View File

@@ -495,6 +495,13 @@ impl WayVRClient {
Ok(()) Ok(())
} }
pub async fn fn_wlx_overlay_show_hide(
client: WayVRClientMutex,
) -> anyhow::Result<()> {
send_only!(client, &PacketClient::WlxShowHide);
Ok(())
}
pub async fn fn_wlx_modify_panel( pub async fn fn_wlx_modify_panel(
client: WayVRClientMutex, client: WayVRClientMutex,
params: packet_client::WlxModifyPanelParams, params: packet_client::WlxModifyPanelParams,

View File

@@ -86,4 +86,5 @@ pub enum PacketClient {
WlxInputState(Serial), WlxInputState(Serial),
WlxModifyPanel(WlxModifyPanelParams), WlxModifyPanel(WlxModifyPanelParams),
WlxDeviceHaptics(usize, WlxHapticsParams), WlxDeviceHaptics(usize, WlxHapticsParams),
WlxShowHide,
} }

View File

@@ -236,6 +236,18 @@ pub async fn wlx_device_haptics(
) )
} }
pub async fn wlx_overlay_show_hide(
state: &mut WayVRClientState,
) {
handle_empty_result(
WayVRClient::fn_wlx_overlay_show_hide(
state.wayvr_client.clone(),
)
.await
.context("failed to trigger overlay show hide"),
)
}
pub async fn wlx_panel_modify( pub async fn wlx_panel_modify(
state: &mut WayVRClientState, state: &mut WayVRClientState,
overlay: String, overlay: String,

View File

@@ -10,7 +10,7 @@ use env_logger::Env;
use wayvr_ipc::{client::WayVRClient, ipc, packet_client}; use wayvr_ipc::{client::WayVRClient, ipc, packet_client};
use crate::helper::{ use crate::helper::{
WayVRClientState, wlx_device_haptics, wlx_input_state, wlx_panel_modify, wvr_display_create, WayVRClientState, wlx_overlay_show_hide, 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_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_display_window_list, wvr_process_get, wvr_process_launch, wvr_process_list,
wvr_process_terminate, wvr_window_set_visible, wvr_process_terminate, wvr_window_set_visible,
@@ -169,6 +169,10 @@ async fn run_once(state: &mut WayVRClientState, args: Args) -> anyhow::Result<()
} => { } => {
wlx_device_haptics(state, device, intensity, duration, frequency).await; wlx_device_haptics(state, device, intensity, duration, frequency).await;
} }
Subcommands::ShowHide {
} => {
wlx_overlay_show_hide(state).await;
}
Subcommands::PanelModify { Subcommands::PanelModify {
overlay, overlay,
element, element,
@@ -293,6 +297,8 @@ enum Subcommands {
#[arg(short, long, default_value = "0.1")] #[arg(short, long, default_value = "0.1")]
frequency: f32, frequency: f32,
}, },
/// Toggle overlay show or hide
ShowHide,
/// Apply a modification to a panel element /// Apply a modification to a panel element
PanelModify { PanelModify {
/// The name of the overlay (XML file name without extension) /// The name of the overlay (XML file name without extension)

View File

@@ -165,6 +165,10 @@ where
app.tasks app.tasks
.enqueue(TaskType::Input(InputTask::Haptics { device, haptics })); .enqueue(TaskType::Input(InputTask::Haptics { device, haptics }));
} }
WayVRSignal::ShowHide => {
app.tasks
.enqueue(TaskType::Overlay(OverlayTask::ShowHide));
}
WayVRSignal::DropOverlay(overlay_id) => { WayVRSignal::DropOverlay(overlay_id) => {
app.tasks app.tasks
.enqueue(TaskType::Overlay(OverlayTask::Drop(OverlaySelector::Id( .enqueue(TaskType::Overlay(OverlayTask::Drop(OverlaySelector::Id(

View File

@@ -522,6 +522,12 @@ impl Connection {
)); ));
} }
fn handle_wlx_overlay_show_hide(
params: &mut TickParams
) {
params.signals.send(WayVRSignal::ShowHide);
}
fn handle_wlx_panel( fn handle_wlx_panel(
params: &mut TickParams, params: &mut TickParams,
custom_params: packet_client::WlxModifyPanelParams, custom_params: packet_client::WlxModifyPanelParams,
@@ -624,6 +630,9 @@ impl Connection {
PacketClient::WlxDeviceHaptics(device, haptics_params) => { PacketClient::WlxDeviceHaptics(device, haptics_params) => {
Self::handle_wlx_device_haptics(params, device, haptics_params); Self::handle_wlx_device_haptics(params, device, haptics_params);
} }
PacketClient::WlxShowHide => {
Self::handle_wlx_overlay_show_hide(params);
}
PacketClient::WlxModifyPanel(custom_params) => { PacketClient::WlxModifyPanel(custom_params) => {
Self::handle_wlx_panel(params, custom_params); Self::handle_wlx_panel(params, custom_params);
} }

View File

@@ -16,5 +16,6 @@ pub enum WayVRSignal {
Haptics(crate::backend::input::Haptics), Haptics(crate::backend::input::Haptics),
DeviceHaptics(usize, crate::backend::input::Haptics), DeviceHaptics(usize, crate::backend::input::Haptics),
DropOverlay(crate::windowing::OverlayID), DropOverlay(crate::windowing::OverlayID),
ShowHide,
CustomTask(crate::backend::task::ModifyPanelTask), CustomTask(crate::backend::task::ModifyPanelTask),
} }