config: allow mapping input devices to outputs
This commit is contained in:
parent
efdca4de49
commit
86e283d255
18 changed files with 420 additions and 13 deletions
|
|
@ -129,6 +129,15 @@ impl JayInput {
|
|||
.map(uapi::as_bytes)
|
||||
.unwrap_or_default(),
|
||||
});
|
||||
if let Some(output) = data.data.output.get() {
|
||||
if let Some(output) = output.get() {
|
||||
self.client.event(InputDeviceOutput {
|
||||
self_id: self.id,
|
||||
id: data.id.raw(),
|
||||
output: &output.connector.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn device(&self, id: u32) -> Result<Rc<DeviceHandlerData>, JayInputError> {
|
||||
|
|
@ -389,6 +398,32 @@ impl JayInputRequestHandler for JayInput {
|
|||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn map_to_output(&self, req: MapToOutput<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.or_error(|| {
|
||||
let dev = self.device(req.id)?;
|
||||
match req.output {
|
||||
Some(output) => {
|
||||
let namelc = output.to_ascii_lowercase();
|
||||
let c = self
|
||||
.client
|
||||
.state
|
||||
.root
|
||||
.outputs
|
||||
.lock()
|
||||
.values()
|
||||
.find(|c| c.global.connector.name.to_ascii_lowercase() == namelc)
|
||||
.cloned();
|
||||
match c {
|
||||
Some(c) => dev.set_output(Some(&c.global)),
|
||||
_ => return Err(JayInputError::OutputNotConnected),
|
||||
}
|
||||
}
|
||||
_ => dev.set_output(None),
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
@ -418,5 +453,7 @@ pub enum JayInputError {
|
|||
ClientMemError(#[from] ClientMemError),
|
||||
#[error("Could not parse keymap")]
|
||||
XkbCommonError(#[from] XkbCommonError),
|
||||
#[error("Output is not connected")]
|
||||
OutputNotConnected,
|
||||
}
|
||||
efrom!(JayInputError, ClientError);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ use {
|
|||
zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1,
|
||||
DynDataSource, IpcError,
|
||||
},
|
||||
wl_output::WlOutputGlobal,
|
||||
wl_seat::{
|
||||
gesture_owner::GestureOwnerHolder,
|
||||
kb_owner::KbOwnerHolder,
|
||||
|
|
@ -1163,4 +1164,17 @@ impl DeviceHandlerData {
|
|||
seat.handle_xkb_state_change(&old.borrow(), &new.borrow());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_output(&self, output: Option<&WlOutputGlobal>) {
|
||||
match output {
|
||||
None => {
|
||||
log::info!("Removing output mapping of {}", self.device.name());
|
||||
self.output.take();
|
||||
}
|
||||
Some(o) => {
|
||||
log::info!("Mapping {} to {}", self.device.name(), o.connector.name);
|
||||
self.output.set(Some(o.opt.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue