autocommit 2022-02-14 21:47:35 CET
This commit is contained in:
parent
da6b29f138
commit
290225190a
11 changed files with 191 additions and 19 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::_private::ipc::{InitMessage, Request, Response};
|
||||
use crate::_private::{bincode_ops, logging, Config, ConfigEntry, ConfigEntryGen, VERSION};
|
||||
use crate::{Direction, InputDevice, LogLevel, ModifiedKeySym, Seat};
|
||||
use crate::{Axis, Direction, InputDevice, LogLevel, ModifiedKeySym, Seat};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -171,6 +171,21 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn split(&self, seat: Seat) -> Axis {
|
||||
let res = self.with_response(|| self.send(&Request::GetSplit { seat }));
|
||||
match res {
|
||||
Response::GetSplit { axis } => axis,
|
||||
_ => {
|
||||
log::error!("Server did not send a response to a get_split request");
|
||||
Axis::Horizontal
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_split(&self, seat: Seat, axis: Axis) {
|
||||
self.send(&Request::SetSplit { seat, axis });
|
||||
}
|
||||
|
||||
pub fn create_seat(&self, name: &str) -> Seat {
|
||||
let response = self.with_response(|| self.send(&Request::CreateSeat { name }));
|
||||
match response {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::keyboard::mods::Modifiers;
|
||||
use crate::keyboard::syms::KeySym;
|
||||
use crate::{Direction, InputDevice, LogLevel, Seat};
|
||||
use crate::{Axis, Direction, InputDevice, LogLevel, Seat};
|
||||
use bincode::{BorrowDecode, Decode, Encode};
|
||||
use crate::keyboard::keymap::Keymap;
|
||||
|
||||
|
|
@ -38,6 +38,13 @@ pub enum Request<'a> {
|
|||
rate: i32,
|
||||
delay: i32,
|
||||
},
|
||||
GetSplit {
|
||||
seat: Seat,
|
||||
},
|
||||
SetSplit {
|
||||
seat: Seat,
|
||||
axis: Axis,
|
||||
},
|
||||
RemoveSeat {
|
||||
seat: Seat,
|
||||
},
|
||||
|
|
@ -81,6 +88,7 @@ pub enum Request<'a> {
|
|||
pub enum Response {
|
||||
None,
|
||||
GetSeats { seats: Vec<Seat> },
|
||||
GetSplit { axis: Axis },
|
||||
GetRepeatRate { rate: i32, delay: i32 },
|
||||
ParseKeymap { keymap: Keymap, },
|
||||
CreateSeat { seat: Seat },
|
||||
|
|
|
|||
|
|
@ -56,6 +56,21 @@ impl InputDevice {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum Axis {
|
||||
Horizontal,
|
||||
Vertical,
|
||||
}
|
||||
|
||||
impl Axis {
|
||||
pub fn other(self) -> Self {
|
||||
match self {
|
||||
Self::Horizontal => Self::Vertical,
|
||||
Self::Vertical => Self::Horizontal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Seat {
|
||||
#[doc(hidden)]
|
||||
pub fn raw(self) -> u64 {
|
||||
|
|
@ -87,15 +102,25 @@ impl Seat {
|
|||
get!().seat_set_keymap(self, keymap)
|
||||
}
|
||||
|
||||
pub fn set_repeat_rate(self, rate: i32, delay: i32) {
|
||||
get!().seat_set_repeat_rate(self, rate, delay)
|
||||
}
|
||||
|
||||
pub fn repeat_rate(self) -> (i32, i32) {
|
||||
let mut res = (25, 250);
|
||||
(|| res = get!().seat_get_repeat_rate(self))();
|
||||
res
|
||||
}
|
||||
|
||||
pub fn set_repeat_rate(self, rate: i32, delay: i32) {
|
||||
get!().seat_set_repeat_rate(self, rate, delay)
|
||||
}
|
||||
|
||||
pub fn split(self) -> Axis {
|
||||
let mut res = Axis::Horizontal;
|
||||
(|| res = get!().split(self))();
|
||||
res
|
||||
}
|
||||
|
||||
pub fn set_split(self, axis: Axis) {
|
||||
get!().set_split(self, axis)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_seats() -> Vec<Seat> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue