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(())
|
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(
|
pub async fn fn_wlx_modify_panel(
|
||||||
client: WayVRClientMutex,
|
client: WayVRClientMutex,
|
||||||
params: packet_client::WlxModifyPanelParams,
|
params: packet_client::WlxModifyPanelParams,
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ pub enum PacketClient {
|
||||||
WvrProcessLaunch(Serial, WvrProcessLaunchParams),
|
WvrProcessLaunch(Serial, WvrProcessLaunchParams),
|
||||||
WvrProcessList(Serial),
|
WvrProcessList(Serial),
|
||||||
WvrProcessTerminate(packet_server::WvrProcessHandle),
|
WvrProcessTerminate(packet_server::WvrProcessHandle),
|
||||||
|
WvrInputCapture(bool),
|
||||||
WlxInputState(Serial),
|
WlxInputState(Serial),
|
||||||
WlxModifyPanel(WlxModifyPanelParams),
|
WlxModifyPanel(WlxModifyPanelParams),
|
||||||
WlxDeviceHaptics(usize, WlxHapticsParams),
|
WlxDeviceHaptics(usize, WlxHapticsParams),
|
||||||
|
|
|
||||||
|
|
@ -803,7 +803,7 @@ impl WvrServerState {
|
||||||
self.close_window(window_handle);
|
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();
|
let mut windows: Vec<_> = self.wm.windows.iter().collect();
|
||||||
if windows.is_empty() {
|
if windows.is_empty() {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -334,6 +334,10 @@ impl Connection {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn handle_wvr_input_capture(params: &mut TickParams, grab: bool) {
|
||||||
|
params.wvr_server.set_input_focus(grab);
|
||||||
|
}
|
||||||
|
|
||||||
fn handle_wlx_device_haptics(
|
fn handle_wlx_device_haptics(
|
||||||
params: &mut TickParams,
|
params: &mut TickParams,
|
||||||
device: usize,
|
device: usize,
|
||||||
|
|
@ -426,6 +430,9 @@ impl Connection {
|
||||||
PacketClient::WvrProcessTerminate(process_handle) => {
|
PacketClient::WvrProcessTerminate(process_handle) => {
|
||||||
Self::handle_wvr_process_terminate(params, 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) => {
|
PacketClient::WlxDeviceHaptics(device, haptics_params) => {
|
||||||
Self::handle_wlx_device_haptics(params, 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(
|
pub async fn wlx_device_haptics(
|
||||||
state: &mut WayVRClientState,
|
state: &mut WayVRClientState,
|
||||||
device: usize,
|
device: usize,
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ use wayvr_ipc::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::helper::{
|
use crate::helper::{
|
||||||
WayVRClientState, wlx_device_haptics, wlx_handsfree, wlx_input_state, wlx_panel_modify,
|
WayVRClientState, wlr_input_capture, wlx_device_haptics, wlx_handsfree, wlx_input_state,
|
||||||
wlx_show_hide, wlx_switch_set, wvr_process_get, wvr_process_launch, wvr_process_list,
|
wlx_panel_modify, wlx_show_hide, wlx_switch_set, wvr_process_get, wvr_process_launch,
|
||||||
wvr_process_terminate, wvr_window_list, wvr_window_set_visible,
|
wvr_process_list, wvr_process_terminate, wvr_window_list, wvr_window_set_visible,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod helper;
|
mod helper;
|
||||||
|
|
@ -200,6 +200,9 @@ async fn run_once(state: &mut WayVRClientState, args: Args) -> anyhow::Result<()
|
||||||
Subcommands::Handsfree { command } => {
|
Subcommands::Handsfree { command } => {
|
||||||
wlx_handsfree(state, command.into()).await;
|
wlx_handsfree(state, command.into()).await;
|
||||||
}
|
}
|
||||||
|
Subcommands::InputCapture { command } => {
|
||||||
|
wlr_input_capture(state, matches!(command, GrabRelease::Grab)).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -301,6 +304,15 @@ enum Subcommands {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: SubcommandHandsfree,
|
command: SubcommandHandsfree,
|
||||||
},
|
},
|
||||||
|
InputCapture {
|
||||||
|
command: GrabRelease,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
|
||||||
|
enum GrabRelease {
|
||||||
|
Grab,
|
||||||
|
Release,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
|
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue