97 lines
2.1 KiB
Rust
97 lines
2.1 KiB
Rust
|
use bitflags::bitflags;
|
||
|
use std::{
|
||
|
error::Error as StdError,
|
||
|
fmt,
|
||
|
};
|
||
|
|
||
|
pub mod embedder;
|
||
|
|
||
|
pub(crate) const XEMBED_VERSION: u32 = 0;
|
||
|
pub(crate) const XEMBED_INFO_ATOM_NAME: &str = "_XEMBED_INFO";
|
||
|
pub(crate) const XEMBED_MESSAGE_ATOM_NAME: &str = "_XEMBED";
|
||
|
|
||
|
#[allow(dead_code)]
|
||
|
pub(crate) enum XEmbedMessage {
|
||
|
EmbeddedNotify = 0,
|
||
|
WindowActivate = 1,
|
||
|
WindowDeactivate = 2,
|
||
|
RequestFocus = 3,
|
||
|
FocusIn = 4,
|
||
|
FocusOut = 5,
|
||
|
FocusNext = 6,
|
||
|
FocusPrev = 7,
|
||
|
ModalityOn = 10,
|
||
|
ModalityOff = 11,
|
||
|
RegisterAccelerator = 12,
|
||
|
UnregisterAccelerator = 13,
|
||
|
ActivateAccelerator = 14,
|
||
|
}
|
||
|
|
||
|
pub enum XEmbedFocus {
|
||
|
Current = 0,
|
||
|
First = 1,
|
||
|
Last = 2,
|
||
|
}
|
||
|
|
||
|
bitflags! {
|
||
|
struct XEmbedFlags: u32 {
|
||
|
const MAPPED = (1 << 0);
|
||
|
}
|
||
|
|
||
|
struct XEmbedModifier: u32 {
|
||
|
const SHIFT = (1 << 0);
|
||
|
const CONTROL = (1 << 1);
|
||
|
const ALT = (1 << 2);
|
||
|
const SUPER = (1 << 3);
|
||
|
const HYPER = (1 << 4);
|
||
|
}
|
||
|
|
||
|
struct XEmbedAcceleratorFlags: u32 {
|
||
|
const OVERLOADED = (1 << 0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[derive(Debug)]
|
||
|
pub enum Error {
|
||
|
ProtocolError(String),
|
||
|
Xcb(xcb::Error),
|
||
|
ClientDestroyed,
|
||
|
}
|
||
|
|
||
|
impl fmt::Display for Error {
|
||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||
|
match self {
|
||
|
Self::ProtocolError(reason) => write!(f, "XEMBED: Protocol error: {}", reason),
|
||
|
Self::Xcb(err) => write!(f, "XEMBED: {}", err),
|
||
|
Self::ClientDestroyed => write!(f, "XEMBED: client destroyed"),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl StdError for Error {
|
||
|
fn source(&self) -> Option<&(dyn StdError + 'static)> {
|
||
|
match self {
|
||
|
Self::Xcb(err) => Some(err),
|
||
|
_ => None,
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl From<xcb::Error> for Error {
|
||
|
fn from(error: xcb::Error) -> Self {
|
||
|
Self::Xcb(error)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl From<xcb::ProtocolError> for Error {
|
||
|
fn from(error: xcb::ProtocolError) -> Self {
|
||
|
Self::Xcb(xcb::Error::Protocol(error))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl From<xcb::ConnError> for Error {
|
||
|
fn from(error: xcb::ConnError) -> Self {
|
||
|
Self::Xcb(xcb::Error::Connection(error))
|
||
|
}
|
||
|
}
|