macros: add opaque macro
This commit is contained in:
parent
0a5b00f269
commit
9880f78ec4
16 changed files with 60 additions and 115 deletions
|
|
@ -10,13 +10,13 @@ use {
|
||||||
wl_display::WlDisplay,
|
wl_display::WlDisplay,
|
||||||
wl_registry::WlRegistry,
|
wl_registry::WlRegistry,
|
||||||
wl_surface::{WlSurface, commit_timeline::CommitTimelines},
|
wl_surface::{WlSurface, commit_timeline::CommitTimelines},
|
||||||
|
xdg_activation_token_v1::ActivationToken,
|
||||||
},
|
},
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
object::{Interface, Object, ObjectId, WL_DISPLAY_ID},
|
object::{Interface, Object, ObjectId, WL_DISPLAY_ID},
|
||||||
security_context_acceptor::AcceptorMetadata,
|
security_context_acceptor::AcceptorMetadata,
|
||||||
state::State,
|
state::State,
|
||||||
utils::{
|
utils::{
|
||||||
activation_token::ActivationToken,
|
|
||||||
asyncevent::AsyncEvent,
|
asyncevent::AsyncEvent,
|
||||||
buffd::{MsgFormatter, MsgParser, MsgParserError, OutBufferSwapchain},
|
buffd::{MsgFormatter, MsgParser, MsgParserError, OutBufferSwapchain},
|
||||||
copyhashmap::{CopyHashMap, Locked},
|
copyhashmap::{CopyHashMap, Locked},
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,12 @@ use {
|
||||||
config::handler::ConfigProxyHandler,
|
config::handler::ConfigProxyHandler,
|
||||||
ifs::wl_seat::SeatId,
|
ifs::wl_seat::SeatId,
|
||||||
state::State,
|
state::State,
|
||||||
tree::{TileState, ToplevelData},
|
tree::{TileState, ToplevelData, ToplevelIdentifier},
|
||||||
utils::{
|
utils::{
|
||||||
clonecell::CloneCell,
|
clonecell::CloneCell,
|
||||||
nice::{JAY_NO_REALTIME, dont_allow_config_so},
|
nice::{JAY_NO_REALTIME, dont_allow_config_so},
|
||||||
numcell::NumCell,
|
numcell::NumCell,
|
||||||
ptr_ext::PtrExt,
|
ptr_ext::PtrExt,
|
||||||
toplevel_identifier::ToplevelIdentifier,
|
|
||||||
unlink_on_drop::UnlinkOnDrop,
|
unlink_on_drop::UnlinkOnDrop,
|
||||||
xrd::xrd,
|
xrd::xrd,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ use {
|
||||||
tagged_acceptor::TaggedAcceptorError,
|
tagged_acceptor::TaggedAcceptorError,
|
||||||
theme::{ThemeColor, ThemeSized},
|
theme::{ThemeColor, ThemeSized},
|
||||||
tree::{
|
tree::{
|
||||||
ContainerSplit, OutputNode, TearingMode, TileState, ToplevelData, ToplevelNode,
|
ContainerSplit, OutputNode, TearingMode, TileState, ToplevelData, ToplevelIdentifier,
|
||||||
VrrMode, WorkspaceNode, toplevel_create_split, toplevel_parent_container,
|
ToplevelNode, VrrMode, WorkspaceNode, toplevel_create_split, toplevel_parent_container,
|
||||||
toplevel_set_floating, toplevel_set_workspace,
|
toplevel_set_floating, toplevel_set_workspace,
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
|
|
@ -40,7 +40,6 @@ use {
|
||||||
oserror::{OsError, OsErrorExt},
|
oserror::{OsError, OsErrorExt},
|
||||||
stack::Stack,
|
stack::Stack,
|
||||||
timer::{TimerError, TimerFd},
|
timer::{TimerError, TimerFd},
|
||||||
toplevel_identifier::ToplevelIdentifier,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bincode::Options,
|
bincode::Options,
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,8 @@ use {
|
||||||
criteria::{CritMgrExt, CritUpstreamNode, crit_leaf::CritLeafMatcher},
|
criteria::{CritMgrExt, CritUpstreamNode, crit_leaf::CritLeafMatcher},
|
||||||
egui_adapter::egui_platform::icons::ICON_OPEN_IN_NEW,
|
egui_adapter::egui_platform::icons::ICON_OPEN_IN_NEW,
|
||||||
state::State,
|
state::State,
|
||||||
tree::ToplevelData,
|
tree::{ToplevelData, ToplevelIdentifier},
|
||||||
utils::{
|
utils::{copyhashmap::CopyHashMap, static_text::StaticText},
|
||||||
copyhashmap::CopyHashMap, static_text::StaticText,
|
|
||||||
toplevel_identifier::ToplevelIdentifier,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
egui::{
|
egui::{
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,11 @@ use {
|
||||||
criteria::{CritMgrExt, CritUpstreamNode, crit_leaf::CritLeafMatcher},
|
criteria::{CritMgrExt, CritUpstreamNode, crit_leaf::CritLeafMatcher},
|
||||||
egui_adapter::egui_platform::icons::ICON_OPEN_IN_NEW,
|
egui_adapter::egui_platform::icons::ICON_OPEN_IN_NEW,
|
||||||
state::State,
|
state::State,
|
||||||
tree::{NodeId, ToplevelData, ToplevelNode, ToplevelType},
|
tree::{NodeId, ToplevelData, ToplevelIdentifier, ToplevelNode, ToplevelType},
|
||||||
utils::{
|
utils::{
|
||||||
copyhashmap::CopyHashMap,
|
copyhashmap::CopyHashMap,
|
||||||
event_listener::{EventListener, LazyEventSourceListener},
|
event_listener::{EventListener, LazyEventSourceListener},
|
||||||
static_text::StaticText,
|
static_text::StaticText,
|
||||||
toplevel_identifier::ToplevelIdentifier,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,8 @@ use {
|
||||||
},
|
},
|
||||||
ifs::wl_seat::WlSeatGlobal,
|
ifs::wl_seat::WlSeatGlobal,
|
||||||
state::State,
|
state::State,
|
||||||
tree::{NodeId, ToplevelData, ToplevelNode},
|
tree::{NodeId, ToplevelData, ToplevelIdentifier, ToplevelNode},
|
||||||
utils::{
|
utils::{copyhashmap::CopyHashMap, hash_map_ext::HashMapExt, queue::AsyncQueue},
|
||||||
copyhashmap::CopyHashMap, hash_map_ext::HashMapExt, queue::AsyncQueue,
|
|
||||||
toplevel_identifier::ToplevelIdentifier,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
jay_config::window::{ContentType, WindowType},
|
jay_config::window::{ContentType, WindowType},
|
||||||
linearize::static_map,
|
linearize::static_map,
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ use {
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
object::{Object, Version},
|
object::{Object, Version},
|
||||||
screenshoter::take_screenshot,
|
screenshoter::take_screenshot,
|
||||||
utils::{errorfmt::ErrorFmt, toplevel_identifier::ToplevelIdentifier},
|
tree::ToplevelIdentifier,
|
||||||
|
utils::errorfmt::ErrorFmt,
|
||||||
wire::{
|
wire::{
|
||||||
JayCompositorId, JayScreenshotId,
|
JayCompositorId, JayScreenshotId,
|
||||||
jay_compositor::{self, *},
|
jay_compositor::{self, *},
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,10 @@ use {
|
||||||
rect::Rect,
|
rect::Rect,
|
||||||
tree::{
|
tree::{
|
||||||
self, ContainerNode, DisplayNode, FloatNode, Node, NodeVisitor, OutputNode,
|
self, ContainerNode, DisplayNode, FloatNode, Node, NodeVisitor, OutputNode,
|
||||||
PlaceholderNode, ToplevelData, ToplevelNodeBase, ToplevelType, WorkspaceNode,
|
PlaceholderNode, ToplevelData, ToplevelIdentifier, ToplevelNodeBase, ToplevelType,
|
||||||
|
WorkspaceNode,
|
||||||
},
|
},
|
||||||
utils::{opaque::OpaqueError, opt::Opt, toplevel_identifier::ToplevelIdentifier},
|
utils::{opaque::OpaqueError, opt::Opt},
|
||||||
wire::{JayTreeQueryId, jay_tree_query::*},
|
wire::{JayTreeQueryId, jay_tree_query::*},
|
||||||
},
|
},
|
||||||
isnt::std_1::primitive::IsntStrExt,
|
isnt::std_1::primitive::IsntStrExt,
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,14 @@ use {
|
||||||
client::{Client, ClientError},
|
client::{Client, ClientError},
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
object::{Object, Version},
|
object::{Object, Version},
|
||||||
utils::activation_token::{ActivationToken, activation_token},
|
|
||||||
wire::{XdgActivationTokenV1Id, xdg_activation_token_v1::*},
|
wire::{XdgActivationTokenV1Id, xdg_activation_token_v1::*},
|
||||||
},
|
},
|
||||||
std::{cell::Cell, rc::Rc},
|
std::{cell::Cell, rc::Rc},
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
opaque!(ActivationToken, activation_token);
|
||||||
|
|
||||||
const MAX_TOKENS_PER_CLIENT: usize = 8;
|
const MAX_TOKENS_PER_CLIENT: usize = 8;
|
||||||
|
|
||||||
pub struct XdgActivationTokenV1 {
|
pub struct XdgActivationTokenV1 {
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
client::{Client, ClientError},
|
client::{Client, ClientError},
|
||||||
globals::{Global, GlobalName},
|
globals::{Global, GlobalName},
|
||||||
ifs::xdg_activation_token_v1::XdgActivationTokenV1,
|
ifs::xdg_activation_token_v1::{ActivationToken, XdgActivationTokenV1},
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
object::{Object, Version},
|
object::{Object, Version},
|
||||||
utils::{activation_token::ActivationToken, errorfmt::ErrorFmt, opaque::OpaqueError},
|
utils::{errorfmt::ErrorFmt, opaque::OpaqueError},
|
||||||
wire::{XdgActivationV1Id, xdg_activation_v1::*},
|
wire::{XdgActivationV1Id, xdg_activation_v1::*},
|
||||||
},
|
},
|
||||||
std::rc::Rc,
|
std::rc::Rc,
|
||||||
|
|
|
||||||
|
|
@ -900,3 +900,36 @@ macro_rules! dynload {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! opaque {
|
||||||
|
($ty:ident, $fun:ident) => {
|
||||||
|
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash, Ord, PartialOrd)]
|
||||||
|
pub struct $ty(crate::utils::opaque::Opaque);
|
||||||
|
|
||||||
|
unsafe impl crate::utils::clonecell::UnsafeCellCloneSafe for $ty {}
|
||||||
|
|
||||||
|
pub fn $fun() -> $ty {
|
||||||
|
$ty(crate::utils::opaque::opaque())
|
||||||
|
}
|
||||||
|
|
||||||
|
impl $ty {
|
||||||
|
pub fn to_string(self) -> arrayvec::ArrayString<{ crate::utils::opaque::OPAQUE_LEN }> {
|
||||||
|
self.0.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for $ty {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
self.0.fmt(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::str::FromStr for $ty {
|
||||||
|
type Err = crate::utils::opaque::OpaqueError;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
Ok(Self(s.parse()?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ use {
|
||||||
workspace_manager::WorkspaceManagerState,
|
workspace_manager::WorkspaceManagerState,
|
||||||
wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1,
|
wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1,
|
||||||
wp_drm_lease_device_v1::WpDrmLeaseDeviceV1Global,
|
wp_drm_lease_device_v1::WpDrmLeaseDeviceV1Global,
|
||||||
|
xdg_activation_token_v1::ActivationToken,
|
||||||
zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1,
|
zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1,
|
||||||
zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,
|
zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,
|
||||||
zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1,
|
zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1,
|
||||||
|
|
@ -107,13 +108,12 @@ use {
|
||||||
tree::{
|
tree::{
|
||||||
ContainerNode, ContainerSplit, Direction, DisplayNode, FindTreeUsecase, FloatNode,
|
ContainerNode, ContainerSplit, Direction, DisplayNode, FindTreeUsecase, FloatNode,
|
||||||
FoundNode, LatchListener, Node, NodeIds, NodeVisitorBase, OutputNode, PlaceholderNode,
|
FoundNode, LatchListener, Node, NodeIds, NodeVisitorBase, OutputNode, PlaceholderNode,
|
||||||
TearingMode, TileState, ToplevelData, ToplevelNode, ToplevelNodeBase, Transform,
|
TearingMode, TileState, ToplevelData, ToplevelIdentifier, ToplevelNode,
|
||||||
VrrMode, WorkspaceDisplayOrder, WorkspaceNode, WsMoveConfig, generic_node_visitor,
|
ToplevelNodeBase, Transform, VrrMode, WorkspaceDisplayOrder, WorkspaceNode,
|
||||||
move_ws_to_output,
|
WsMoveConfig, generic_node_visitor, move_ws_to_output,
|
||||||
},
|
},
|
||||||
udmabuf::UdmabufHolder,
|
udmabuf::UdmabufHolder,
|
||||||
utils::{
|
utils::{
|
||||||
activation_token::ActivationToken,
|
|
||||||
asyncevent::AsyncEvent,
|
asyncevent::AsyncEvent,
|
||||||
bindings::Bindings,
|
bindings::Bindings,
|
||||||
clonecell::CloneCell,
|
clonecell::CloneCell,
|
||||||
|
|
@ -128,7 +128,6 @@ use {
|
||||||
queue::AsyncQueue,
|
queue::AsyncQueue,
|
||||||
refcounted::RefCounted,
|
refcounted::RefCounted,
|
||||||
run_toplevel::RunToplevel,
|
run_toplevel::RunToplevel,
|
||||||
toplevel_identifier::ToplevelIdentifier,
|
|
||||||
},
|
},
|
||||||
video::{
|
video::{
|
||||||
dmabuf::DmaBufIds,
|
dmabuf::DmaBufIds,
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,9 @@ use {
|
||||||
NodeLayerLink, OutputNode, PlaceholderNode, WorkspaceNode,
|
NodeLayerLink, OutputNode, PlaceholderNode, WorkspaceNode,
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
array_to_tuple::ArrayToTuple,
|
array_to_tuple::ArrayToTuple, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||||
clonecell::CloneCell,
|
event_listener::LazyEventSource, hash_map_ext::HashMapExt, numcell::NumCell,
|
||||||
copyhashmap::CopyHashMap,
|
rc_eq::rc_eq, threshold_counter::ThresholdCounter,
|
||||||
event_listener::LazyEventSource,
|
|
||||||
hash_map_ext::HashMapExt,
|
|
||||||
numcell::NumCell,
|
|
||||||
rc_eq::rc_eq,
|
|
||||||
threshold_counter::ThresholdCounter,
|
|
||||||
toplevel_identifier::{ToplevelIdentifier, toplevel_identifier},
|
|
||||||
},
|
},
|
||||||
wire::{
|
wire::{
|
||||||
ExtForeignToplevelHandleV1Id, ExtImageCopyCaptureSessionV1Id, JayScreencastId,
|
ExtForeignToplevelHandleV1Id, ExtImageCopyCaptureSessionV1Id, JayScreencastId,
|
||||||
|
|
@ -55,6 +49,8 @@ use {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
opaque!(ToplevelIdentifier, toplevel_identifier);
|
||||||
|
|
||||||
tree_id!(ToplevelNodeId);
|
tree_id!(ToplevelNodeId);
|
||||||
|
|
||||||
pub trait ToplevelNode: ToplevelNodeBase {
|
pub trait ToplevelNode: ToplevelNodeBase {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
pub mod activation_token;
|
|
||||||
pub mod array;
|
pub mod array;
|
||||||
pub mod array_to_tuple;
|
pub mod array_to_tuple;
|
||||||
pub mod asyncevent;
|
pub mod asyncevent;
|
||||||
|
|
@ -60,7 +59,6 @@ pub mod string_ext;
|
||||||
pub mod syncqueue;
|
pub mod syncqueue;
|
||||||
pub mod threshold_counter;
|
pub mod threshold_counter;
|
||||||
pub mod timer;
|
pub mod timer;
|
||||||
pub mod toplevel_identifier;
|
|
||||||
pub mod tri;
|
pub mod tri;
|
||||||
pub mod unlink_on_drop;
|
pub mod unlink_on_drop;
|
||||||
pub mod vec_ext;
|
pub mod vec_ext;
|
||||||
|
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
use {
|
|
||||||
crate::utils::opaque::{OPAQUE_LEN, Opaque, OpaqueError, opaque},
|
|
||||||
arrayvec::ArrayString,
|
|
||||||
std::{
|
|
||||||
fmt::{Display, Formatter},
|
|
||||||
str::FromStr,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
|
|
||||||
pub struct ActivationToken(Opaque);
|
|
||||||
|
|
||||||
pub fn activation_token() -> ActivationToken {
|
|
||||||
ActivationToken(opaque())
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ActivationToken {
|
|
||||||
pub fn to_string(self) -> ArrayString<OPAQUE_LEN> {
|
|
||||||
self.0.to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for ActivationToken {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
self.0.fmt(f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for ActivationToken {
|
|
||||||
type Err = OpaqueError;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Ok(Self(s.parse()?))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
use {
|
|
||||||
crate::utils::{
|
|
||||||
clonecell::UnsafeCellCloneSafe,
|
|
||||||
opaque::{OPAQUE_LEN, Opaque, OpaqueError, opaque},
|
|
||||||
},
|
|
||||||
arrayvec::ArrayString,
|
|
||||||
std::{
|
|
||||||
fmt::{Display, Formatter},
|
|
||||||
str::FromStr,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash, Ord, PartialOrd)]
|
|
||||||
pub struct ToplevelIdentifier(Opaque);
|
|
||||||
|
|
||||||
unsafe impl UnsafeCellCloneSafe for ToplevelIdentifier {}
|
|
||||||
|
|
||||||
pub fn toplevel_identifier() -> ToplevelIdentifier {
|
|
||||||
ToplevelIdentifier(opaque())
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToplevelIdentifier {
|
|
||||||
pub fn to_string(self) -> ArrayString<OPAQUE_LEN> {
|
|
||||||
self.0.to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for ToplevelIdentifier {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
self.0.fmt(f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for ToplevelIdentifier {
|
|
||||||
type Err = OpaqueError;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Ok(Self(s.parse()?))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue