1
0
Fork 0
forked from wry/wry

config: add keyboard-focus window criteria

This commit is contained in:
Julian Orth 2025-05-01 18:43:54 +02:00
parent eb172e9d8c
commit 91c948b219
15 changed files with 95 additions and 4 deletions

View file

@ -15,11 +15,13 @@ use {
tlmm_client::TlmMatchClient,
tlmm_floating::TlmMatchFloating,
tlmm_kind::TlmMatchKind,
tlmm_seat_focus::TlmMatchSeatFocus,
tlmm_string::{TlmMatchAppId, TlmMatchTitle},
tlmm_urgent::TlmMatchUrgent,
tlmm_visible::TlmMatchVisible,
},
},
ifs::wl_seat::WlSeatGlobal,
state::State,
tree::{NodeId, ToplevelData, ToplevelNode},
utils::{
@ -44,6 +46,7 @@ bitflags! {
TL_CHANGED_FLOATING = 1 << 4,
TL_CHANGED_VISIBLE = 1 << 5,
TL_CHANGED_URGENT = 1 << 6,
TL_CHANGED_SEAT_FOCI = 1 << 7,
}
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
@ -67,6 +70,7 @@ pub struct RootMatchers {
clients: CopyHashMap<CritMatcherId, Weak<TlmMatchClient>>,
title: TlmRootMatcherMap<TlmMatchTitle>,
app_id: TlmRootMatcherMap<TlmMatchAppId>,
seat_foci: TlmRootMatcherMap<TlmMatchSeatFocus>,
}
pub async fn handle_tl_changes(state: Rc<State>) {
@ -129,6 +133,10 @@ impl TlMatcherManager {
}
}
pub fn has_seat_foci(&self) -> bool {
self.matchers.seat_foci.is_not_empty()
}
pub fn has_no_interest(&self, data: &ToplevelData, change: TlMatcherChange) -> bool {
!self.has_interest(data, change)
}
@ -175,6 +183,7 @@ impl TlMatcherManager {
}
conditional!(TL_CHANGED_TITLE, title);
conditional!(TL_CHANGED_APP_ID, app_id);
conditional!(TL_CHANGED_SEAT_FOCI, seat_foci);
fixed_conditional!(TL_CHANGED_FLOATING, floating);
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
fixed_conditional!(TL_CHANGED_URGENT, urgent);
@ -244,6 +253,7 @@ impl TlMatcherManager {
}
conditional!(TL_CHANGED_TITLE, title);
conditional!(TL_CHANGED_APP_ID, app_id);
conditional!(TL_CHANGED_SEAT_FOCI, seat_foci);
fixed_conditional!(TL_CHANGED_FLOATING, floating);
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
fixed_conditional!(TL_CHANGED_URGENT, urgent);
@ -276,6 +286,10 @@ impl TlMatcherManager {
pub fn urgent(&self) -> Rc<TlmUpstreamNode> {
self.urgent[true].clone()
}
pub fn seat_focus(&self, seat: &WlSeatGlobal) -> Rc<TlmUpstreamNode> {
self.root(TlmMatchSeatFocus::new(seat.id()))
}
}
impl CritTarget for ToplevelData {

View file

@ -20,6 +20,7 @@ macro_rules! fixed_root_criterion {
pub mod tlmm_client;
pub mod tlmm_floating;
pub mod tlmm_kind;
pub mod tlmm_seat_focus;
pub mod tlmm_string;
pub mod tlmm_urgent;
pub mod tlmm_visible;

View file

@ -0,0 +1,28 @@
use crate::{
criteria::{
crit_graph::CritRootCriterion,
tlm::{RootMatchers, TlmRootMatcherMap},
},
ifs::wl_seat::SeatId,
tree::ToplevelData,
};
pub struct TlmMatchSeatFocus {
id: SeatId,
}
impl TlmMatchSeatFocus {
pub fn new(id: SeatId) -> TlmMatchSeatFocus {
Self { id }
}
}
impl CritRootCriterion<ToplevelData> for TlmMatchSeatFocus {
fn matches(&self, data: &ToplevelData) -> bool {
data.seat_foci.contains(&self.id)
}
fn nodes(roots: &RootMatchers) -> Option<&TlmRootMatcherMap<Self>> {
Some(&roots.seat_foci)
}
}