wayvrctl switch-set
This commit is contained in:
@@ -410,11 +410,16 @@ impl WayVRClient {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn fn_wlx_overlay_show_hide(client: WayVRClientMutex) -> anyhow::Result<()> {
|
||||
pub async fn fn_wlx_show_hide(client: WayVRClientMutex) -> anyhow::Result<()> {
|
||||
send_only!(client, &PacketClient::WlxShowHide);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn fn_wlx_switch_set(client: WayVRClientMutex, set: Option<usize>) -> anyhow::Result<()> {
|
||||
send_only!(client, &PacketClient::WlxSwitchSet(set));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn fn_wlx_modify_panel(
|
||||
client: WayVRClientMutex,
|
||||
params: packet_client::WlxModifyPanelParams,
|
||||
|
||||
@@ -68,4 +68,5 @@ pub enum PacketClient {
|
||||
WlxModifyPanel(WlxModifyPanelParams),
|
||||
WlxDeviceHaptics(usize, WlxHapticsParams),
|
||||
WlxShowHide,
|
||||
WlxSwitchSet(Option<usize>),
|
||||
}
|
||||
|
||||
@@ -50,6 +50,10 @@ where
|
||||
WayVRSignal::ShowHide => {
|
||||
app.tasks.enqueue(TaskType::Overlay(OverlayTask::ShowHide));
|
||||
}
|
||||
WayVRSignal::SwitchSet(set) => {
|
||||
app.tasks
|
||||
.enqueue(TaskType::Overlay(OverlayTask::SwitchSet(set)));
|
||||
}
|
||||
WayVRSignal::DropOverlay(overlay_id) => {
|
||||
app.tasks
|
||||
.enqueue(TaskType::Overlay(OverlayTask::Drop(OverlaySelector::Id(
|
||||
|
||||
@@ -341,10 +341,14 @@ impl Connection {
|
||||
));
|
||||
}
|
||||
|
||||
fn handle_wlx_overlay_show_hide(params: &mut TickParams) {
|
||||
fn handle_wlx_show_hide(params: &mut TickParams) {
|
||||
params.signals.send(WayVRSignal::ShowHide);
|
||||
}
|
||||
|
||||
fn handle_wlx_switch_set(params: &mut TickParams, set: Option<usize>) {
|
||||
params.signals.send(WayVRSignal::SwitchSet(set));
|
||||
}
|
||||
|
||||
fn handle_wlx_panel(
|
||||
params: &mut TickParams,
|
||||
custom_params: packet_client::WlxModifyPanelParams,
|
||||
@@ -414,7 +418,10 @@ impl Connection {
|
||||
Self::handle_wlx_device_haptics(params, device, haptics_params);
|
||||
}
|
||||
PacketClient::WlxShowHide => {
|
||||
Self::handle_wlx_overlay_show_hide(params);
|
||||
Self::handle_wlx_show_hide(params);
|
||||
}
|
||||
PacketClient::WlxSwitchSet(set) => {
|
||||
Self::handle_wlx_switch_set(params, set);
|
||||
}
|
||||
PacketClient::WlxModifyPanel(custom_params) => {
|
||||
Self::handle_wlx_panel(params, custom_params);
|
||||
|
||||
@@ -3,6 +3,7 @@ pub enum WayVRSignal {
|
||||
BroadcastStateChanged(wayvr_ipc::packet_server::WvrStateChanged),
|
||||
DeviceHaptics(usize, crate::backend::input::Haptics),
|
||||
DropOverlay(crate::windowing::OverlayID),
|
||||
SwitchSet(Option<usize>),
|
||||
ShowHide,
|
||||
CustomTask(crate::backend::task::ModifyPanelTask),
|
||||
}
|
||||
|
||||
@@ -751,7 +751,7 @@ impl<T> OverlayWindowManager<T> {
|
||||
new_set: Option<usize>,
|
||||
keep_transforms: bool,
|
||||
) {
|
||||
if new_set == self.current_set {
|
||||
if new_set == self.current_set || new_set.is_some_and(|x| x >= self.sets.len()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -766,11 +766,6 @@ impl<T> OverlayWindowManager<T> {
|
||||
}
|
||||
|
||||
if let Some(new_set) = new_set {
|
||||
if new_set >= self.sets.len() {
|
||||
log::error!("switch_to_set: new_set is out of range ({new_set:?})");
|
||||
return;
|
||||
}
|
||||
|
||||
let mut num_overlays = 0;
|
||||
let ws = &mut self.sets[new_set];
|
||||
for (id, data) in self.overlays.iter_mut().filter(|(_, d)| !d.config.global) {
|
||||
|
||||
@@ -156,14 +156,22 @@ pub async fn wlx_device_haptics(
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wlx_overlay_show_hide(state: &mut WayVRClientState) {
|
||||
pub async fn wlx_show_hide(state: &mut WayVRClientState) {
|
||||
handle_empty_result(
|
||||
WayVRClient::fn_wlx_overlay_show_hide(state.wayvr_client.clone())
|
||||
WayVRClient::fn_wlx_show_hide(state.wayvr_client.clone())
|
||||
.await
|
||||
.context("failed to trigger overlay show hide"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wlx_switch_set(state: &mut WayVRClientState, set: Option<usize>) {
|
||||
handle_empty_result(
|
||||
WayVRClient::fn_wlx_switch_set(state.wayvr_client.clone(), set)
|
||||
.await
|
||||
.context("failed to switch to set"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wlx_panel_modify(
|
||||
state: &mut WayVRClientState,
|
||||
overlay: String,
|
||||
|
||||
@@ -14,9 +14,9 @@ use wayvr_ipc::{
|
||||
};
|
||||
|
||||
use crate::helper::{
|
||||
WayVRClientState, wlx_device_haptics, wlx_input_state, wlx_overlay_show_hide, wlx_panel_modify,
|
||||
wvr_process_get, wvr_process_launch, wvr_process_list, wvr_process_terminate, wvr_window_list,
|
||||
wvr_window_set_visible,
|
||||
WayVRClientState, wlx_device_haptics, wlx_input_state, wlx_panel_modify, wlx_show_hide,
|
||||
wlx_switch_set, wvr_process_get, wvr_process_launch, wvr_process_list, wvr_process_terminate,
|
||||
wvr_window_list, wvr_window_set_visible,
|
||||
};
|
||||
|
||||
mod helper;
|
||||
@@ -164,7 +164,7 @@ async fn run_once(state: &mut WayVRClientState, args: Args) -> anyhow::Result<()
|
||||
wlx_device_haptics(state, device, intensity, duration, frequency).await;
|
||||
}
|
||||
Subcommands::ShowHide {} => {
|
||||
wlx_overlay_show_hide(state).await;
|
||||
wlx_show_hide(state).await;
|
||||
}
|
||||
Subcommands::PanelModify {
|
||||
overlay,
|
||||
@@ -191,6 +191,10 @@ async fn run_once(state: &mut WayVRClientState, args: Args) -> anyhow::Result<()
|
||||
|
||||
wlx_panel_modify(state, overlay, element, command).await;
|
||||
}
|
||||
Subcommands::SwitchSet { set_or_0: set } => {
|
||||
let set = if set <= 0 { None } else { Some((set - 1) as _) };
|
||||
wlx_switch_set(state, set).await;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -283,6 +287,10 @@ enum Subcommands {
|
||||
#[command(subcommand)]
|
||||
command: SubcommandPanelModify,
|
||||
},
|
||||
SwitchSet {
|
||||
/// Set number to switch to, 0 to hide all sets
|
||||
set_or_0: usize,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
|
||||
|
||||
Reference in New Issue
Block a user