1
0
Fork 0
forked from wry/wry

autocommit 2022-02-16 18:14:14 CET

This commit is contained in:
Julian Orth 2022-02-16 18:14:14 +01:00
parent 086f2f73f4
commit 8d0b82c37c
17 changed files with 220 additions and 42 deletions

View file

@ -1,7 +1,7 @@
use crate::_private::ipc::{ClientMessage, InitMessage, Response, ServerMessage};
use crate::_private::{bincode_ops, logging, Config, ConfigEntry, ConfigEntryGen, VERSION};
use crate::keyboard::keymap::Keymap;
use crate::{Axis, Command, Direction, InputDevice, LogLevel, ModifiedKeySym, Seat};
use crate::{Axis, Command, Direction, InputDevice, Keyboard, LogLevel, ModifiedKeySym, Seat};
use std::cell::{Cell, RefCell};
use std::collections::hash_map::Entry;
use std::collections::HashMap;
@ -140,6 +140,10 @@ impl Client {
});
}
pub fn grab(&self, kb: Keyboard, grab: bool) {
self.send(&ClientMessage::GrabKb { kb, grab });
}
pub fn focus(&self, seat: Seat, direction: Direction) {
self.send(&ClientMessage::Focus { seat, direction });
}
@ -206,8 +210,8 @@ impl Client {
}
}
pub fn get_input_devices(&self) -> Vec<InputDevice> {
let res = self.with_response(|| self.send(&ClientMessage::GetInputDevices));
pub fn get_input_devices(&self, seat: Option<Seat>) -> Vec<InputDevice> {
let res = self.with_response(|| self.send(&ClientMessage::GetInputDevices { seat }));
match res {
Response::GetInputDevices { devices } => devices,
_ => {

View file

@ -1,7 +1,7 @@
use crate::keyboard::keymap::Keymap;
use crate::keyboard::mods::Modifiers;
use crate::keyboard::syms::KeySym;
use crate::{Axis, Direction, InputDevice, LogLevel, Seat};
use crate::{Axis, Direction, InputDevice, Keyboard, LogLevel, Seat};
use bincode::{BorrowDecode, Decode, Encode};
#[derive(Encode, BorrowDecode, Debug)]
@ -64,7 +64,9 @@ pub enum ClientMessage<'a> {
seat: Seat,
},
GetSeats,
GetInputDevices,
GetInputDevices {
seat: Option<Seat>,
},
AddShortcut {
seat: Seat,
mods: Modifiers,
@ -88,6 +90,10 @@ pub enum ClientMessage<'a> {
seat: Seat,
direction: Direction,
},
GrabKb {
kb: Keyboard,
grab: bool,
},
}
#[derive(Encode, Decode, Debug)]

5
i4config/src/embedded.rs Normal file
View file

@ -0,0 +1,5 @@
use crate::Keyboard;
pub fn grab_keyboard(kb: Keyboard, grab: bool) {
get!().grab(kb, grab);
}

View file

@ -10,6 +10,7 @@ mod macros;
#[doc(hidden)]
pub mod _private;
pub mod keyboard;
pub mod embedded;
#[derive(Encode, Decode, Copy, Clone, Debug)]
pub enum LogLevel {
@ -122,6 +123,12 @@ impl Seat {
pub fn set_split(self, axis: Axis) {
get!().set_split(self, axis)
}
pub fn input_devices(self) -> Vec<InputDevice> {
let mut res = vec![];
(|| res = get!().get_input_devices(Some(self)))();
res
}
}
pub fn get_seats() -> Vec<Seat> {
@ -132,7 +139,7 @@ pub fn get_seats() -> Vec<Seat> {
pub fn input_devices() -> Vec<InputDevice> {
let mut res = vec![];
(|| res = get!().get_input_devices())();
(|| res = get!().get_input_devices(None))();
res
}