autocommit 2022-04-01 01:44:10 CEST
This commit is contained in:
parent
ab4ac883ee
commit
2dd433aa04
32 changed files with 626 additions and 139 deletions
|
|
@ -5,7 +5,7 @@ use crate::_private::{bincode_ops, logging, Config, ConfigEntry, ConfigEntryGen,
|
|||
use crate::input::{AccelProfile, Capability, InputDevice};
|
||||
use crate::keyboard::keymap::Keymap;
|
||||
use crate::theme::Color;
|
||||
use crate::{Axis, Command, Direction, LogLevel, ModifiedKeySym, Seat};
|
||||
use crate::{Axis, Command, Direction, LogLevel, ModifiedKeySym, Seat, Workspace};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -199,6 +199,21 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_workspace(&self, name: &str) -> Workspace {
|
||||
let res = self.with_response(|| self.send(&ClientMessage::GetWorkspace { name }));
|
||||
match res {
|
||||
Response::GetWorkspace { workspace } => workspace,
|
||||
_ => {
|
||||
log::error!("Server did not send a response to a get_workspace request");
|
||||
Workspace(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show_workspace(&self, seat: Seat, workspace: Workspace) {
|
||||
self.send(&ClientMessage::ShowWorkspace { seat, workspace });
|
||||
}
|
||||
|
||||
pub fn split(&self, seat: Seat) -> Axis {
|
||||
let res = self.with_response(|| self.send(&ClientMessage::GetSplit { seat }));
|
||||
match res {
|
||||
|
|
@ -337,6 +352,17 @@ impl Client {
|
|||
self.send(&ClientMessage::SetTransformMatrix { device, matrix })
|
||||
}
|
||||
|
||||
pub fn device_name(&self, device: InputDevice) -> String {
|
||||
let res = self.with_response(|| self.send(&ClientMessage::GetDeviceName { device }));
|
||||
match res {
|
||||
Response::GetDeviceName { name } => name,
|
||||
_ => {
|
||||
log::error!("Server did not send a response to a get_device_name request");
|
||||
String::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_capability(&self, device: InputDevice, cap: Capability) -> bool {
|
||||
let res = self.with_response(|| self.send(&ClientMessage::HasCapability { device, cap }));
|
||||
match res {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::keyboard::keymap::Keymap;
|
|||
use crate::keyboard::mods::Modifiers;
|
||||
use crate::keyboard::syms::KeySym;
|
||||
use crate::theme::Color;
|
||||
use crate::{Axis, Direction, LogLevel, Seat};
|
||||
use crate::{Axis, Direction, LogLevel, Seat, Workspace};
|
||||
use bincode::{BorrowDecode, Decode, Encode};
|
||||
|
||||
#[derive(Encode, BorrowDecode, Debug)]
|
||||
|
|
@ -157,6 +157,16 @@ pub enum ClientMessage<'a> {
|
|||
device: InputDevice,
|
||||
matrix: [[f64; 2]; 2],
|
||||
},
|
||||
GetDeviceName {
|
||||
device: InputDevice,
|
||||
},
|
||||
GetWorkspace {
|
||||
name: &'a str,
|
||||
},
|
||||
ShowWorkspace {
|
||||
seat: Seat,
|
||||
workspace: Workspace,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug)]
|
||||
|
|
@ -172,6 +182,8 @@ pub enum Response {
|
|||
GetTitleHeight { height: i32 },
|
||||
GetBorderWidth { width: i32 },
|
||||
HasCapability { has: bool },
|
||||
GetDeviceName { name: String },
|
||||
GetWorkspace { workspace: Workspace },
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Debug)]
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ impl InputDevice {
|
|||
pub fn set_transform_matrix(self, matrix: [[f64; 2]; 2]) {
|
||||
get!().set_transform_matrix(self, matrix);
|
||||
}
|
||||
|
||||
pub fn name(self) -> String {
|
||||
get!(String::new()).device_name(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
|
|
|
|||
|
|
@ -134,6 +134,10 @@ impl Seat {
|
|||
pub fn toggle_floating(self) {
|
||||
get!().toggle_floating(self);
|
||||
}
|
||||
|
||||
pub fn show_workspace(self, workspace: Workspace) {
|
||||
get!().show_workspace(self, workspace)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_seats() -> Vec<Seat> {
|
||||
|
|
@ -201,3 +205,10 @@ impl Command {
|
|||
get!().spawn(self);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub struct Workspace(pub u64);
|
||||
|
||||
pub fn get_workspace(name: &str) -> Workspace {
|
||||
get!(Workspace(0)).get_workspace(name)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue