mirror of https://github.com/wayvr-org/wayvr.git
wayvrctl input-capture
This commit is contained in:
parent
4bde55c2d3
commit
0b8040b9ae
|
|
@ -460,6 +460,11 @@ impl WayVRClient {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn fn_wvr_input_capture(client: WayVRClientMutex, grab: bool) -> anyhow::Result<()> {
|
||||
send_only!(client, &PacketClient::WvrInputCapture(grab));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn fn_wlx_modify_panel(
|
||||
client: WayVRClientMutex,
|
||||
params: packet_client::WlxModifyPanelParams,
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ pub enum PacketClient {
|
|||
WvrProcessLaunch(Serial, WvrProcessLaunchParams),
|
||||
WvrProcessList(Serial),
|
||||
WvrProcessTerminate(packet_server::WvrProcessHandle),
|
||||
WvrInputCapture(bool),
|
||||
WlxInputState(Serial),
|
||||
WlxModifyPanel(WlxModifyPanelParams),
|
||||
WlxDeviceHaptics(usize, WlxHapticsParams),
|
||||
|
|
|
|||
|
|
@ -803,7 +803,7 @@ impl WvrServerState {
|
|||
self.close_window(window_handle);
|
||||
}
|
||||
}
|
||||
input_capture::KeyCombo::AltTab => self.alt_tab(),
|
||||
input_capture::KeyCombo::AltTab => self.alt_tab(pressed),
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
|
|
@ -852,7 +852,7 @@ impl WvrServerState {
|
|||
}
|
||||
}
|
||||
|
||||
fn alt_tab(&mut self) {
|
||||
fn alt_tab(&mut self, pressed: bool) {
|
||||
let mut windows: Vec<_> = self.wm.windows.iter().collect();
|
||||
if windows.is_empty() {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -334,6 +334,10 @@ impl Connection {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_wvr_input_capture(params: &mut TickParams, grab: bool) {
|
||||
params.wvr_server.set_input_focus(grab);
|
||||
}
|
||||
|
||||
fn handle_wlx_device_haptics(
|
||||
params: &mut TickParams,
|
||||
device: usize,
|
||||
|
|
@ -426,6 +430,9 @@ impl Connection {
|
|||
PacketClient::WvrProcessTerminate(process_handle) => {
|
||||
Self::handle_wvr_process_terminate(params, process_handle);
|
||||
}
|
||||
PacketClient::WvrInputCapture(grab) => {
|
||||
Self::handle_wvr_input_capture(params, grab);
|
||||
}
|
||||
PacketClient::WlxDeviceHaptics(device, haptics_params) => {
|
||||
Self::handle_wlx_device_haptics(params, device, haptics_params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,14 @@ pub async fn wvr_process_launch(
|
|||
)
|
||||
}
|
||||
|
||||
pub async fn wlr_input_capture(state: &mut WayVRClientState, grab: bool) {
|
||||
handle_empty_result(
|
||||
WayVRClient::fn_wvr_input_capture(state.wayvr_client.clone(), grab)
|
||||
.await
|
||||
.context("failed to change input capture"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wlx_device_haptics(
|
||||
state: &mut WayVRClientState,
|
||||
device: usize,
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ use wayvr_ipc::{
|
|||
};
|
||||
|
||||
use crate::helper::{
|
||||
WayVRClientState, wlx_device_haptics, wlx_handsfree, 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,
|
||||
WayVRClientState, wlr_input_capture, wlx_device_haptics, wlx_handsfree, 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;
|
||||
|
|
@ -200,6 +200,9 @@ async fn run_once(state: &mut WayVRClientState, args: Args) -> anyhow::Result<()
|
|||
Subcommands::Handsfree { command } => {
|
||||
wlx_handsfree(state, command.into()).await;
|
||||
}
|
||||
Subcommands::InputCapture { command } => {
|
||||
wlr_input_capture(state, matches!(command, GrabRelease::Grab)).await;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -301,6 +304,15 @@ enum Subcommands {
|
|||
#[command(subcommand)]
|
||||
command: SubcommandHandsfree,
|
||||
},
|
||||
InputCapture {
|
||||
command: GrabRelease,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
|
||||
enum GrabRelease {
|
||||
Grab,
|
||||
Release,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue