config: add keyboard-focus window criteria
This commit is contained in:
parent
eb172e9d8c
commit
91c948b219
15 changed files with 95 additions and 4 deletions
|
|
@ -2000,6 +2000,7 @@ impl ConfigProxyHandler {
|
|||
WindowCriterionIpc::Floating => mgr.floating(),
|
||||
WindowCriterionIpc::Visible => mgr.visible(),
|
||||
WindowCriterionIpc::Urgent => mgr.urgent(),
|
||||
WindowCriterionIpc::SeatFocus(seat) => mgr.seat_focus(&*self.get_seat(*seat)?),
|
||||
};
|
||||
let cached = Rc::new(CachedCriterion {
|
||||
crit: criterion.clone(),
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
28
src/criteria/tlm/tlm_matchers/tlmm_seat_focus.rs
Normal file
28
src/criteria/tlm/tlm_matchers/tlmm_seat_focus.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
ifs::wl_seat::WlSeatGlobal, tree::Node, utils::clonecell::CloneCell,
|
||||
xwayland::XWaylandEvent,
|
||||
criteria::tlm::TL_CHANGED_SEAT_FOCI, ifs::wl_seat::WlSeatGlobal, tree::Node,
|
||||
utils::clonecell::CloneCell, xwayland::XWaylandEvent,
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
|
@ -61,6 +61,18 @@ impl KbOwner for DefaultKbOwner {
|
|||
}
|
||||
|
||||
fn set_kb_node(&self, seat: &Rc<WlSeatGlobal>, node: Rc<dyn Node>, serial: u64) {
|
||||
macro_rules! notify_matcher {
|
||||
($node:expr, $data:ident, $block:expr) => {
|
||||
if let Some(tl) = $node.clone().node_toplevel() {
|
||||
let $data = tl.tl_data();
|
||||
$block;
|
||||
if seat.state.tl_matcher_manager.has_seat_foci() {
|
||||
$data.property_changed(TL_CHANGED_SEAT_FOCI);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let old = seat.keyboard_node.get();
|
||||
if old.node_id() == node.node_id() {
|
||||
return;
|
||||
|
|
@ -70,6 +82,7 @@ impl KbOwner for DefaultKbOwner {
|
|||
seat.state.xwayland.queue.push(XWaylandEvent::ActivateRoot);
|
||||
}
|
||||
old.node_on_unfocus(seat);
|
||||
notify_matcher!(old, data, data.seat_foci.remove(&seat.id));
|
||||
if old.node_seat_state().unfocus(seat) {
|
||||
old.node_active_changed(false);
|
||||
}
|
||||
|
|
@ -79,6 +92,7 @@ impl KbOwner for DefaultKbOwner {
|
|||
}
|
||||
// log::info!("focus {}", node.node_id());
|
||||
node.clone().node_on_focus(seat);
|
||||
notify_matcher!(node, data, data.seat_foci.set(seat.id, ()));
|
||||
seat.keyboard_node_serial.set(serial);
|
||||
seat.keyboard_node.set(node.clone());
|
||||
seat.tablet_on_keyboard_node_change();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use {
|
|||
ext_image_copy::ext_image_copy_capture_session_v1::ExtImageCopyCaptureSessionV1,
|
||||
jay_screencast::JayScreencast,
|
||||
jay_toplevel::JayToplevel,
|
||||
wl_seat::{NodeSeatState, collect_kb_foci, collect_kb_foci2},
|
||||
wl_seat::{NodeSeatState, SeatId, collect_kb_foci, collect_kb_foci2},
|
||||
wl_surface::WlSurface,
|
||||
},
|
||||
rect::Rect,
|
||||
|
|
@ -324,6 +324,7 @@ pub struct ToplevelData {
|
|||
pub slf: Weak<dyn ToplevelNode>,
|
||||
pub destroyed: CopyHashMap<CritMatcherId, Weak<dyn CritDestroyListener<ToplevelData>>>,
|
||||
pub changed_properties: Cell<TlMatcherChange>,
|
||||
pub seat_foci: CopyHashMap<SeatId, ()>,
|
||||
}
|
||||
|
||||
impl ToplevelData {
|
||||
|
|
@ -370,6 +371,7 @@ impl ToplevelData {
|
|||
slf: slf.clone(),
|
||||
destroyed: Default::default(),
|
||||
changed_properties: Default::default(),
|
||||
seat_foci: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue