config: add app-id window criteria
This commit is contained in:
parent
6ef7655dbd
commit
da64166e82
13 changed files with 102 additions and 24 deletions
|
|
@ -1989,6 +1989,7 @@ impl ConfigProxyHandler {
|
|||
};
|
||||
match *field {
|
||||
WindowCriterionStringField::Title => mgr.title(needle),
|
||||
WindowCriterionStringField::AppId => mgr.app_id(needle),
|
||||
}
|
||||
}
|
||||
WindowCriterionIpc::Types(t) => mgr.kind(*t),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ use {
|
|||
crit_leaf::{CritLeafEvent, CritLeafMatcher},
|
||||
crit_matchers::critm_constant::CritMatchConstant,
|
||||
tlm::tlm_matchers::{
|
||||
tlmm_client::TlmMatchClient, tlmm_kind::TlmMatchKind, tlmm_string::TlmMatchTitle,
|
||||
tlmm_client::TlmMatchClient,
|
||||
tlmm_kind::TlmMatchKind,
|
||||
tlmm_string::{TlmMatchAppId, TlmMatchTitle},
|
||||
},
|
||||
},
|
||||
state::State,
|
||||
|
|
@ -29,6 +31,7 @@ bitflags! {
|
|||
TL_CHANGED_DESTROYED = 1 << 0,
|
||||
TL_CHANGED_NEW = 1 << 1,
|
||||
TL_CHANGED_TITLE = 1 << 2,
|
||||
TL_CHANGED_APP_ID = 1 << 3,
|
||||
}
|
||||
|
||||
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
|
||||
|
|
@ -48,6 +51,7 @@ pub struct RootMatchers {
|
|||
kinds: TlmRootMatcherMap<TlmMatchKind>,
|
||||
clients: CopyHashMap<CritMatcherId, Weak<TlmMatchClient>>,
|
||||
title: TlmRootMatcherMap<TlmMatchTitle>,
|
||||
app_id: TlmRootMatcherMap<TlmMatchAppId>,
|
||||
}
|
||||
|
||||
pub async fn handle_tl_changes(state: Rc<State>) {
|
||||
|
|
@ -143,6 +147,7 @@ impl TlMatcherManager {
|
|||
};
|
||||
}
|
||||
conditional!(TL_CHANGED_TITLE, title);
|
||||
conditional!(TL_CHANGED_APP_ID, app_id);
|
||||
false
|
||||
}
|
||||
|
||||
|
|
@ -210,12 +215,17 @@ impl TlMatcherManager {
|
|||
};
|
||||
}
|
||||
conditional!(TL_CHANGED_TITLE, title);
|
||||
conditional!(TL_CHANGED_APP_ID, app_id);
|
||||
}
|
||||
|
||||
pub fn title(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchTitle::new(string))
|
||||
}
|
||||
|
||||
pub fn app_id(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchAppId::new(string))
|
||||
}
|
||||
|
||||
pub fn kind(&self, kind: WindowType) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchKind::new(kind))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ use crate::{
|
|||
pub type TlmMatchString<T> = CritMatchString<ToplevelData, T>;
|
||||
|
||||
pub type TlmMatchTitle = TlmMatchString<TitleAccess>;
|
||||
pub type TlmMatchAppId = TlmMatchString<AppIdAccess>;
|
||||
|
||||
pub struct TitleAccess;
|
||||
pub struct AppIdAccess;
|
||||
|
||||
impl StringAccess<ToplevelData> for TitleAccess {
|
||||
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
|
||||
|
|
@ -21,3 +23,13 @@ impl StringAccess<ToplevelData> for TitleAccess {
|
|||
&roots.title
|
||||
}
|
||||
}
|
||||
|
||||
impl StringAccess<ToplevelData> for AppIdAccess {
|
||||
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
|
||||
f(&data.app_id.borrow())
|
||||
}
|
||||
|
||||
fn nodes(roots: &RootMatchers) -> &TlmRootMatcherMap<TlmMatchString<Self>> {
|
||||
&roots.app_id
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ use {
|
|||
client::{Client, ClientId},
|
||||
criteria::{
|
||||
CritDestroyListener, CritMatcherId,
|
||||
tlm::{TL_CHANGED_DESTROYED, TL_CHANGED_NEW, TL_CHANGED_TITLE, TlMatcherChange},
|
||||
tlm::{
|
||||
TL_CHANGED_APP_ID, TL_CHANGED_DESTROYED, TL_CHANGED_NEW, TL_CHANGED_TITLE,
|
||||
TlMatcherChange,
|
||||
},
|
||||
},
|
||||
ifs::{
|
||||
ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1,
|
||||
|
|
@ -498,11 +501,16 @@ impl ToplevelData {
|
|||
}
|
||||
|
||||
pub fn set_app_id(&self, app_id: &str) {
|
||||
*self.app_id.borrow_mut() = app_id.to_string();
|
||||
let dst = &mut *self.app_id.borrow_mut();
|
||||
if *dst == app_id {
|
||||
return;
|
||||
}
|
||||
*dst = app_id.to_string();
|
||||
for handle in self.handles.lock().values() {
|
||||
handle.send_app_id(app_id);
|
||||
handle.send_done();
|
||||
}
|
||||
self.property_changed(TL_CHANGED_APP_ID)
|
||||
}
|
||||
|
||||
pub fn set_fullscreen(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue