1
0
Fork 0
forked from wry/wry

autocommit 2022-04-01 01:44:10 CEST

This commit is contained in:
Julian Orth 2022-04-01 01:44:10 +02:00
parent ab4ac883ee
commit 2dd433aa04
32 changed files with 626 additions and 139 deletions

View file

@ -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 {

View file

@ -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)]