config: rename criterion payload types
This commit is contained in:
parent
a8176b96c3
commit
f9e8d614ce
4 changed files with 75 additions and 75 deletions
|
|
@ -42,8 +42,8 @@ use {
|
|||
},
|
||||
jay_config::{
|
||||
_private::{
|
||||
ClientCriterionIpc, ClientCriterionStringField, GenericCriterionIpc, PollableId,
|
||||
ConfigHandler, Unref, WindowCriterionIpc, WindowCriterionStringField, WireMode,
|
||||
ClientCriterionPayload, ClientCriterionStringField, GenericCriterionPayload, PollableId,
|
||||
ConfigHandler, Unref, WindowCriterionPayload, WindowCriterionStringField, WireMode,
|
||||
messages::{ClientMessage, Response, ServerMessage, WorkspaceSource},
|
||||
},
|
||||
Axis, Direction, Workspace,
|
||||
|
|
@ -114,21 +114,21 @@ pub(super) struct ConfigProxyHandler {
|
|||
|
||||
pub client_matcher_ids: NumCell<u64>,
|
||||
pub client_matchers:
|
||||
CopyHashMap<ClientMatcher, Rc<CachedCriterion<ClientCriterionIpc, Client>>>,
|
||||
pub client_matcher_cache: CriterionCache<ClientCriterionIpc, Client>,
|
||||
CopyHashMap<ClientMatcher, Rc<CachedCriterion<ClientCriterionPayload, Client>>>,
|
||||
pub client_matcher_cache: CriterionCache<ClientCriterionPayload, Client>,
|
||||
pub client_matcher_leafs: CopyHashMap<ClientMatcher, Rc<ClmLeafMatcher>>,
|
||||
pub window_matcher_ids: NumCell<u64>,
|
||||
pub window_matchers:
|
||||
CopyHashMap<WindowMatcher, Rc<CachedCriterion<WindowCriterionIpc, ToplevelData>>>,
|
||||
pub window_matcher_cache: CriterionCache<WindowCriterionIpc, ToplevelData>,
|
||||
CopyHashMap<WindowMatcher, Rc<CachedCriterion<WindowCriterionPayload, ToplevelData>>>,
|
||||
pub window_matcher_cache: CriterionCache<WindowCriterionPayload, ToplevelData>,
|
||||
pub window_matcher_leafs: CopyHashMap<WindowMatcher, Rc<TlmLeafMatcher>>,
|
||||
pub window_matcher_std_kinds: Rc<TlmUpstreamNode>,
|
||||
pub window_matcher_no_auto_focus:
|
||||
CopyHashMap<WindowMatcher, Rc<CachedCriterion<WindowCriterionIpc, ToplevelData>>>,
|
||||
CopyHashMap<WindowMatcher, Rc<CachedCriterion<WindowCriterionPayload, ToplevelData>>>,
|
||||
pub window_matcher_initial_tile_state: CopyHashMap<
|
||||
WindowMatcher,
|
||||
(
|
||||
Rc<CachedCriterion<WindowCriterionIpc, ToplevelData>>,
|
||||
Rc<CachedCriterion<WindowCriterionPayload, ToplevelData>>,
|
||||
TileState,
|
||||
),
|
||||
>,
|
||||
|
|
@ -2072,7 +2072,7 @@ impl ConfigProxyHandler {
|
|||
fn get_client_matcher(
|
||||
&self,
|
||||
matcher: ClientMatcher,
|
||||
) -> Result<Rc<CachedCriterion<ClientCriterionIpc, Client>>, CphError> {
|
||||
) -> Result<Rc<CachedCriterion<ClientCriterionPayload, Client>>, CphError> {
|
||||
self.client_matchers
|
||||
.get(&matcher)
|
||||
.ok_or(CphError::ClientMatcherDoesNotExist(matcher))
|
||||
|
|
@ -2080,23 +2080,23 @@ impl ConfigProxyHandler {
|
|||
|
||||
fn sort_generic_matcher<T, K>(
|
||||
&self,
|
||||
generic: &mut GenericCriterionIpc<T>,
|
||||
generic: &mut GenericCriterionPayload<T>,
|
||||
key: impl FnMut(&T) -> K,
|
||||
) where
|
||||
K: Ord,
|
||||
{
|
||||
match generic {
|
||||
GenericCriterionIpc::List { list, .. } | GenericCriterionIpc::Exactly { list, .. } => {
|
||||
GenericCriterionPayload::List { list, .. } | GenericCriterionPayload::Exactly { list, .. } => {
|
||||
list.sort_by_key(key)
|
||||
}
|
||||
GenericCriterionIpc::Matcher(_) | GenericCriterionIpc::Not(_) => {}
|
||||
GenericCriterionPayload::Matcher(_) | GenericCriterionPayload::Not(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_generic_matcher<Crit, Matcher, Mgr>(
|
||||
&self,
|
||||
mgr: &Mgr,
|
||||
generic: &GenericCriterionIpc<Matcher>,
|
||||
generic: &GenericCriterionPayload<Matcher>,
|
||||
upstream: &mut Vec<Rc<CachedCriterion<Crit, Mgr::Target>>>,
|
||||
get_matcher: impl Fn(&Matcher) -> Result<Rc<CachedCriterion<Crit, Mgr::Target>>, CphError>,
|
||||
) -> Result<Rc<dyn CritUpstreamNode<Mgr::Target>>, CphError>
|
||||
|
|
@ -2111,16 +2111,16 @@ impl ConfigProxyHandler {
|
|||
Ok(node)
|
||||
};
|
||||
let node = match generic {
|
||||
GenericCriterionIpc::Matcher(m) => get_matcher(m)?.node.clone(),
|
||||
GenericCriterionIpc::Not(m) => mgr.not(&get_upstream(m)?),
|
||||
GenericCriterionIpc::List { list, all } => {
|
||||
GenericCriterionPayload::Matcher(m) => get_matcher(m)?.node.clone(),
|
||||
GenericCriterionPayload::Not(m) => mgr.not(&get_upstream(m)?),
|
||||
GenericCriterionPayload::List { list, all } => {
|
||||
let mut m = Vec::with_capacity(list.len());
|
||||
for c in list {
|
||||
m.push(get_upstream(c)?);
|
||||
}
|
||||
mgr.list(&m, *all)
|
||||
}
|
||||
GenericCriterionIpc::Exactly { list, num } => {
|
||||
GenericCriterionPayload::Exactly { list, num } => {
|
||||
let mut m = Vec::with_capacity(list.len());
|
||||
for c in list {
|
||||
m.push(get_upstream(c)?);
|
||||
|
|
@ -2133,9 +2133,9 @@ impl ConfigProxyHandler {
|
|||
|
||||
fn handle_create_client_matcher(
|
||||
&self,
|
||||
mut criterion: ClientCriterionIpc,
|
||||
mut criterion: ClientCriterionPayload,
|
||||
) -> Result<(), CphError> {
|
||||
if let ClientCriterionIpc::Generic(generic) = &mut criterion {
|
||||
if let ClientCriterionPayload::Generic(generic) = &mut criterion {
|
||||
self.sort_generic_matcher(generic, |m| m.0);
|
||||
}
|
||||
let id = ClientMatcher(self.client_matcher_ids.fetch_add(1));
|
||||
|
|
@ -2150,10 +2150,10 @@ impl ConfigProxyHandler {
|
|||
let mgr = &self.state.cl_matcher_manager;
|
||||
let mut upstream = vec![];
|
||||
let matcher = match &criterion {
|
||||
ClientCriterionIpc::Generic(m) => {
|
||||
ClientCriterionPayload::Generic(m) => {
|
||||
self.create_generic_matcher(mgr, m, &mut upstream, |m| self.get_client_matcher(*m))?
|
||||
}
|
||||
ClientCriterionIpc::String {
|
||||
ClientCriterionPayload::String {
|
||||
string,
|
||||
field,
|
||||
regex,
|
||||
|
|
@ -2175,10 +2175,10 @@ impl ConfigProxyHandler {
|
|||
ClientCriterionStringField::Exe => mgr.exe(needle),
|
||||
}
|
||||
}
|
||||
ClientCriterionIpc::Sandboxed => mgr.sandboxed(),
|
||||
ClientCriterionIpc::Uid(p) => mgr.uid(*p),
|
||||
ClientCriterionIpc::Pid(p) => mgr.pid(*p),
|
||||
ClientCriterionIpc::IsXwayland => mgr.is_xwayland(),
|
||||
ClientCriterionPayload::Sandboxed => mgr.sandboxed(),
|
||||
ClientCriterionPayload::Uid(p) => mgr.uid(*p),
|
||||
ClientCriterionPayload::Pid(p) => mgr.pid(*p),
|
||||
ClientCriterionPayload::IsXwayland => mgr.is_xwayland(),
|
||||
};
|
||||
let cached = Rc::new(CachedCriterion {
|
||||
crit: criterion.clone(),
|
||||
|
|
@ -2225,7 +2225,7 @@ impl ConfigProxyHandler {
|
|||
fn get_window_matcher(
|
||||
&self,
|
||||
matcher: WindowMatcher,
|
||||
) -> Result<Rc<CachedCriterion<WindowCriterionIpc, ToplevelData>>, CphError> {
|
||||
) -> Result<Rc<CachedCriterion<WindowCriterionPayload, ToplevelData>>, CphError> {
|
||||
self.window_matchers
|
||||
.get(&matcher)
|
||||
.ok_or(CphError::WindowMatcherDoesNotExist(matcher))
|
||||
|
|
@ -2233,9 +2233,9 @@ impl ConfigProxyHandler {
|
|||
|
||||
fn handle_create_window_matcher(
|
||||
&self,
|
||||
mut criterion: WindowCriterionIpc,
|
||||
mut criterion: WindowCriterionPayload,
|
||||
) -> Result<(), CphError> {
|
||||
if let WindowCriterionIpc::Generic(generic) = &mut criterion {
|
||||
if let WindowCriterionPayload::Generic(generic) = &mut criterion {
|
||||
self.sort_generic_matcher(generic, |m| m.0);
|
||||
}
|
||||
let id = WindowMatcher(self.window_matcher_ids.fetch_add(1));
|
||||
|
|
@ -2250,10 +2250,10 @@ impl ConfigProxyHandler {
|
|||
let mgr = &self.state.tl_matcher_manager;
|
||||
let mut upstream = vec![];
|
||||
let matcher = match &criterion {
|
||||
WindowCriterionIpc::Generic(m) => {
|
||||
WindowCriterionPayload::Generic(m) => {
|
||||
self.create_generic_matcher(mgr, m, &mut upstream, |m| self.get_window_matcher(*m))?
|
||||
}
|
||||
WindowCriterionIpc::String {
|
||||
WindowCriterionPayload::String {
|
||||
string,
|
||||
field,
|
||||
regex,
|
||||
|
|
@ -2275,21 +2275,21 @@ impl ConfigProxyHandler {
|
|||
WindowCriterionStringField::Workspace => mgr.workspace(needle),
|
||||
}
|
||||
}
|
||||
WindowCriterionIpc::Types(t) => mgr.kind(*t),
|
||||
WindowCriterionIpc::Client(c) => {
|
||||
WindowCriterionPayload::Types(t) => mgr.kind(*t),
|
||||
WindowCriterionPayload::Client(c) => {
|
||||
self.state.cl_matcher_manager.rematch_all(&self.state);
|
||||
mgr.client(&self.state, &self.get_client_matcher(*c)?.node)
|
||||
}
|
||||
WindowCriterionIpc::Floating => mgr.floating(),
|
||||
WindowCriterionIpc::Visible => mgr.visible(),
|
||||
WindowCriterionIpc::Urgent => mgr.urgent(),
|
||||
WindowCriterionIpc::SeatFocus(seat) => mgr.seat_focus(&*self.get_seat(*seat)?),
|
||||
WindowCriterionIpc::Fullscreen => mgr.fullscreen(),
|
||||
WindowCriterionIpc::JustMapped => mgr.just_mapped(),
|
||||
WindowCriterionIpc::Workspace(w) => mgr.workspace(CritLiteralOrRegex::Literal(
|
||||
WindowCriterionPayload::Floating => mgr.floating(),
|
||||
WindowCriterionPayload::Visible => mgr.visible(),
|
||||
WindowCriterionPayload::Urgent => mgr.urgent(),
|
||||
WindowCriterionPayload::SeatFocus(seat) => mgr.seat_focus(&*self.get_seat(*seat)?),
|
||||
WindowCriterionPayload::Fullscreen => mgr.fullscreen(),
|
||||
WindowCriterionPayload::JustMapped => mgr.just_mapped(),
|
||||
WindowCriterionPayload::Workspace(w) => mgr.workspace(CritLiteralOrRegex::Literal(
|
||||
self.get_workspace(*w)?.to_string(),
|
||||
)),
|
||||
WindowCriterionIpc::ContentTypes(t) => mgr.content_type(*t),
|
||||
WindowCriterionPayload::ContentTypes(t) => mgr.content_type(*t),
|
||||
};
|
||||
let cached = Rc::new(CachedCriterion {
|
||||
crit: criterion.clone(),
|
||||
|
|
@ -2319,7 +2319,7 @@ impl ConfigProxyHandler {
|
|||
}
|
||||
let upstream = self.get_window_matcher(matcher)?;
|
||||
let mut node = upstream.node.clone();
|
||||
if !upstream.any(&|crit| matches!(crit, WindowCriterionIpc::Types(_))) {
|
||||
if !upstream.any(&|crit| matches!(crit, WindowCriterionPayload::Types(_))) {
|
||||
let list = [self.window_matcher_std_kinds.clone(), node];
|
||||
node = self.state.tl_matcher_manager.list(&list, true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue