config: expose runtime protocol
This commit is contained in:
parent
bcc85c8b1b
commit
e3f122e903
16 changed files with 179 additions and 157 deletions
|
|
@ -1,124 +1,15 @@
|
|||
pub mod client;
|
||||
pub mod messages;
|
||||
mod logging;
|
||||
|
||||
use {
|
||||
crate::{
|
||||
Workspace,
|
||||
client::ClientMatcher,
|
||||
input::Seat,
|
||||
video::Mode,
|
||||
window::{ContentType, WindowMatcher, WindowType},
|
||||
},
|
||||
bincode::Options,
|
||||
serde::{Deserialize, Serialize},
|
||||
pub use crate::protocol::{
|
||||
ClientCriterionPayload, ClientCriterionStringField, ConfigEntry, ConfigHandler,
|
||||
DEFAULT_SEAT_NAME, GenericCriterionPayload, PollableId, ServerHandler, Unref, VERSION,
|
||||
WindowCriterionPayload, WindowCriterionStringField, WireMode,
|
||||
};
|
||||
|
||||
pub const VERSION: u32 = 1;
|
||||
|
||||
pub type ServerHandler = unsafe fn(data: *const u8, msg: &messages::ClientMessage<'_>);
|
||||
pub type ConfigHandler = unsafe fn(data: *const u8, msg: &messages::ServerMessage);
|
||||
pub type Unref = unsafe fn(data: *const u8);
|
||||
|
||||
pub struct ConfigEntry {
|
||||
pub version: u32,
|
||||
pub init: unsafe fn(
|
||||
srv_data: *const u8,
|
||||
srv_unref: Unref,
|
||||
srv_handler: ServerHandler,
|
||||
msg: messages::InitMessage,
|
||||
) -> *const u8,
|
||||
pub unref: Unref,
|
||||
pub handle_msg: ConfigHandler,
|
||||
}
|
||||
|
||||
pub fn bincode_ops() -> impl Options {
|
||||
bincode::DefaultOptions::new()
|
||||
.with_fixint_encoding()
|
||||
.with_little_endian()
|
||||
.with_no_limit()
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct WireMode {
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub refresh_millihz: u32,
|
||||
}
|
||||
|
||||
impl WireMode {
|
||||
pub fn to_mode(self) -> Mode {
|
||||
Mode {
|
||||
width: self.width,
|
||||
height: self.height,
|
||||
refresh_millihz: self.refresh_millihz,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Copy, Clone, Eq, PartialEq, Hash)]
|
||||
pub struct PollableId(pub u64);
|
||||
|
||||
pub const DEFAULT_SEAT_NAME: &str = "default";
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum GenericCriterionPayload<T> {
|
||||
Matcher(T),
|
||||
Not(T),
|
||||
List { list: Vec<T>, all: bool },
|
||||
Exactly { list: Vec<T>, num: usize },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum ClientCriterionPayload {
|
||||
Generic(GenericCriterionPayload<ClientMatcher>),
|
||||
String {
|
||||
string: String,
|
||||
field: ClientCriterionStringField,
|
||||
regex: bool,
|
||||
},
|
||||
Sandboxed,
|
||||
Uid(i32),
|
||||
Pid(i32),
|
||||
IsXwayland,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum ClientCriterionStringField {
|
||||
SandboxEngine,
|
||||
SandboxAppId,
|
||||
SandboxInstanceId,
|
||||
Comm,
|
||||
Exe,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum WindowCriterionPayload {
|
||||
Generic(GenericCriterionPayload<WindowMatcher>),
|
||||
String {
|
||||
string: String,
|
||||
field: WindowCriterionStringField,
|
||||
regex: bool,
|
||||
},
|
||||
Types(WindowType),
|
||||
Client(ClientMatcher),
|
||||
Floating,
|
||||
Visible,
|
||||
Urgent,
|
||||
SeatFocus(Seat),
|
||||
Fullscreen,
|
||||
JustMapped,
|
||||
Workspace(Workspace),
|
||||
ContentTypes(ContentType),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum WindowCriterionStringField {
|
||||
Title,
|
||||
AppId,
|
||||
Tag,
|
||||
XClass,
|
||||
XInstance,
|
||||
XRole,
|
||||
Workspace,
|
||||
pub mod messages {
|
||||
pub use crate::protocol::{
|
||||
ClientMessage, InitMessage, Response, ServerFeature, ServerMessage, V1InitMessage,
|
||||
WorkspaceSource,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue